- Posts: 18
- Thank you received: 2
onAfterCartUpdate infinite loop
11 years 4 months ago - 11 years 4 months ago #202335
by Head
onAfterCartUpdate infinite loop was created by Head
-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.5.x
Hello,
this is probably very easy for you developers of Hikashop, but I'am stuck.
We've written a very simple Plugin to automaticaly add a product on after the cart gets updated, that creates an infinite loop
EDIT: Sorry for not setting the right forum category.
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.5.x
Hello,
this is probably very easy for you developers of Hikashop, but I'am stuck.
We've written a very simple Plugin to automaticaly add a product on after the cart gets updated, that creates an infinite loop
Code:
public function onAfterCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force){
//die(print_r($product_id));
//if( $product_id != '17962' ){ Does not work because $product_id is an Array, and the id is either the "real" product id, or the id from the table "hikashop_cart_product", which I do not know
$c = $cartClass->loadFullCart();
if( count($c->products) ){
$sum = 0;
foreach($c->products as $i => $product){
if( !empty($product->length) ){ // if product has custom field "length"
$sum += $product->cart_product_quantity - 1; // that "- 1" is willed...
}
}
$cartClass->update('17962', $sum); // infinite loop
}
//}
}
EDIT: Sorry for not setting the right forum category.
Last edit: 11 years 4 months ago by Head.
Please Log in or Create an account to join the conversation.
11 years 4 months ago #202345
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic onAfterCartUpdate infinite loop
Hi,
It will be better to use the "onBeforeCareUpdate" in order to be able to modify the quantity dynamically before the cart is updated in the database.
Regards,
It will be better to use the "onBeforeCareUpdate" in order to be able to modify the quantity dynamically before the cart is updated in the database.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Time to create page: 0.202 seconds