- Posts: 431
- Thank you received: 22
PHP Warning: Creating default object from empty value
5 years 9 months ago #326950
by mojweb
PHP Warning: Creating default object from empty value was created by mojweb
-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.23
-- PHP version -- : 7.3.24
This is filing my error log almost every second:
PHP Warning: Creating default object from empty value in administrator/components/com_hikashop/classes/currency.php on line 2505
-- Joomla version -- : 3.9.23
-- PHP version -- : 7.3.24
This is filing my error log almost every second:
PHP Warning: Creating default object from empty value in administrator/components/com_hikashop/classes/currency.php on line 2505
Please Log in or Create an account to join the conversation.
5 years 9 months ago #326970
by nicolas
Replied by nicolas on topic PHP Warning: Creating default object from empty value
Hi,
Please try to add the code:
after the code:
in the file administrator/components/com_hikashop/classes/currency.php and it should hopefully fix the warning message.
Please report the result so that we can add the modification for the next version of HikaShop.
That way you won't have to redo the modification after the next update and others won't get the warning in the future.
Please try to add the code:
Code:
else
$payment->taxes[$tax->tax_namekey] = new stdClass();
Code:
if(is_object($tax))
$payment->taxes[$tax->tax_namekey] = clone($tax);
Please report the result so that we can add the modification for the next version of HikaShop.
That way you won't have to redo the modification after the next update and others won't get the warning in the future.
Please Log in or Create an account to join the conversation.
5 years 9 months ago #326980
by mojweb
Replied by mojweb on topic PHP Warning: Creating default object from empty value
Now I have Warning: Creating default object from empty value in administrator/components/com_hikashop/classes/currency.php on line 2507
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327047
by nicolas
Replied by nicolas on topic PHP Warning: Creating default object from empty value
Mmm. That means we probably don't have the same code on the same line.
Could you edit the file administrator/components/com_hikashop/classes/currency.php on your website and tell me what you have around the line 2507 and which one is the line 2507
Could you edit the file administrator/components/com_hikashop/classes/currency.php on your website and tell me what you have around the line 2507 and which one is the line 2507
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327049
by mojweb
Replied by mojweb on topic PHP Warning: Creating default object from empty value
From line 2499 to line 2519
Code:
if($payment->payment_price_with_tax != $payment->payment_price) {
if(!isset($payment->taxes) && isset($total->prices[$k]->taxes) && is_array($total->prices[$k]->taxes)) {
$payment->taxes = array();
$tax = reset($total->prices[$k]->taxes);
if(is_object($tax))
$payment->taxes[$tax->tax_namekey] = clone($tax);
$payment->taxes[$tax->namekey]->tax_amount = $payment->payment_price_with_tax - $payment->payment_price;
$payment->taxes[$tax->namekey]->amount = $payment->payment_price;
}
if(!empty($payment->taxes)) {
foreach($payment->taxes as $tax) {
if(isset($total->prices[$k]->taxes[$tax->tax_namekey])) {
$total->prices[$k]->taxes[$tax->tax_namekey]->tax_amount += $tax->tax_amount;
$total->prices[$k]->taxes[$tax->tax_namekey]->amount += $tax->amount;
} else
$total->prices[$k]->taxes[$tax->tax_namekey] = clone($tax);
}
}
}
}
}
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327055
by nicolas
Replied by nicolas on topic PHP Warning: Creating default object from empty value
Hi,
Ok. I think I've found the issue.
Change the code:
to:
in there and it should work fine.
Ok. I think I've found the issue.
Change the code:
Code:
if(is_object($tax))
$payment->taxes[$tax->tax_namekey] = clone($tax);
$payment->taxes[$tax->namekey]->tax_amount = $payment->payment_price_with_tax - $payment->payment_price;
$payment->taxes[$tax->namekey]->amount = $payment->payment_price;
Code:
if(is_object($tax) && !empty($tax->tax_namekey)) {
$payment->taxes[$tax->tax_namekey] = clone($tax);
$payment->taxes[$tax->tax_namekey]->tax_amount = $payment->payment_price_with_tax - $payment->payment_price;
$payment->taxes[$tax->tax_namekey]->amount = $payment->payment_price;
}
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327121
by mojweb
Replied by mojweb on topic PHP Warning: Creating default object from empty value
Ok that code solved first problem, but now another
PHP Warning: Invalid argument supplied for foreach() in administrator/components/com_hikashop/classes/cart.php on line 2630
Form line 2629 (after code update) I have
PHP Warning: Invalid argument supplied for foreach() in administrator/components/com_hikashop/classes/cart.php on line 2630
Form line 2629 (after code update) I have
Code:
$cart = $this->get($cart_id);
foreach($cart->cart_products as &$cart_product) {
if($cart_product->cart_product_quantity == 0 || (is_string($cart_product->cart_product_id) && substr($cart_product->cart_product_id, 0, 1) == 'p'))
continue;
if(!$this->compareCartProducts($p, $cart_product, null, $fields))
continue;
$p['id'] = (int)$cart_product->cart_product_id;
$cart_products = array($p);
return $this->updateProduct($cart_id, $cart_products);
}
return $this->addProduct($cart_id, $data);
}
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327151
by nicolas
Replied by nicolas on topic PHP Warning: Creating default object from empty value
Hi,
Ah yes, a check is missing there.
Change that whole code to:
and it will remove that warning.
Ah yes, a check is missing there.
Change that whole code to:
Code:
$cart = $this->get($cart_id);
if(!empty($cart->cart_products)) {
foreach($cart->cart_products as &$cart_product) {
if($cart_product->cart_product_quantity == 0 || (is_string($cart_product->cart_product_id) && substr($cart_product->cart_product_id, 0, 1) == 'p'))
continue;
if(!$this->compareCartProducts($p, $cart_product, null, $fields))
continue;
$p['id'] = (int)$cart_product->cart_product_id;
$cart_products = array($p);
return $this->updateProduct($cart_id, $cart_products);
}
}
return $this->addProduct($cart_id, $data);
}
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327174
by mojweb
Replied by mojweb on topic PHP Warning: Creating default object from empty value
Solved. No warning any more. Thank you.
I have one other, but is about os map plugin.
PHP Warning: Parameter 1 to xmap_com_hikashop::getTree() expected to be a reference, value given in administrator/components/com_osmap/library/alledia/osmap/Helper/General.php on line 396
I have one other, but is about os map plugin.
PHP Warning: Parameter 1 to xmap_com_hikashop::getTree() expected to be a reference, value given in administrator/components/com_osmap/library/alledia/osmap/Helper/General.php on line 396
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327177
by nicolas
Replied by nicolas on topic PHP Warning: Creating default object from empty value
Hi,
You can edit the file plugins/xmap/com_hikashop/com_hikashop.php and change the line:
function getTree( &$xmap, &$parent, &$params ){
to:
function getTree( $xmap, &$parent, &$params ){
and it should fix the problem.
You can edit the file plugins/xmap/com_hikashop/com_hikashop.php and change the line:
function getTree( &$xmap, &$parent, &$params ){
to:
function getTree( $xmap, &$parent, &$params ){
and it should fix the problem.
Please Log in or Create an account to join the conversation.
5 years 9 months ago #327356
by mojweb
Replied by mojweb on topic PHP Warning: Creating default object from empty value
Solved this to.
Thank you nicolas
Thank you nicolas
Please Log in or Create an account to join the conversation.
Time to create page: 0.272 seconds