Page 1 of 1

Upgrading from Frozen

Posted: Fri Aug 22, 2025 11:41 am
by puddlec
possible looking to upgrade from frozen. running on php 7.1
made a huge amount of changes to get it to work the way we needed to.

most things look the same, so should be easy enough to convert (i hope)

the only major change i'm struggling with is the checkout

one of the key things is adding another box to the checkout_shipping to record the delivery date on selected products.
which works it out based on the products weight.
e.g. if the product weight is 1 then show a box showing a calendar
if its products weight is 2 then just show text saying delivery will be in x days

this is what i used to find what product has the height weight

Code: Select all

	  $products = $cart->get_products(); // get the basket contents
for ($i=0, $n=sizeof($products); $i<$n; $i++) { //loop through the basket contents
$test .= $products[$i]['weight']; // get the 'weight' of the product - radio buttons in admin save the days option as the weight so it can be used here	
} // end loop
$arr2 = str_split($test,4); // spilt the resulting info so it can be used below
$blah = max($arr2); // find the highest value so we can use it below

but getting a error
Fatal error: Uncaught Error: Cannot use object of type Product as array
the line in question is

Code: Select all

$test .= $products[$i]['weight']; 

Re: Upgrading from Frozen

Posted: Fri Aug 22, 2025 11:57 am
by burt

Code: Select all

$products = $cart->get_products();
foreach ($products as $product) {
  echo $product->get('weight');
}
Does this Product object collect weight ?

To see a full Product object, to determine that;

Code: Select all

$products = $cart->get_products();
foreach ($products as $product) {
  echo '<pre>';
  print_r($product);
  echo '</pre>';
}

Re: Upgrading from Frozen

Posted: Fri Aug 22, 2025 1:14 pm
by puddlec
thanks for that, got it working eventually,

just a few cases of me being an idiot, with removing the old code