- Posts: 156
- Thank you received: 0
Clearing cart when only "Free" items left in cart?
14 years 11 months ago #26807
by Rickhavoc
Clearing cart when only "Free" items left in cart? was created by Rickhavoc
I would like to automatically clear the cart if everything in the cart is free. How can this be done? does the hikashop have a clear function?
Please Log in or Create an account to join the conversation.
14 years 11 months ago #26821
by nicolas
Replied by nicolas on topic Re: Clearing cart when only "Free" items left in cart?
You can use such php code to clear the cart:
$class = hikashop_get('class.cart');
if($class->hasCart()){
$class->delete($class->cart->cart_id);
}
$class = hikashop_get('class.cart');
if($class->hasCart()){
$class->delete($class->cart->cart_id);
}
Please Log in or Create an account to join the conversation.
14 years 11 months ago - 14 years 11 months ago #26846
by Rickhavoc
Replied by Rickhavoc on topic Re: Clearing cart when only "Free" items left in cart?
this code as is is activated when the cart only has Free items in it? as in i deleted everything else and only items that are free are left. they are not being displayed in the cart but the cart still comes up with the final total of 0.0. we are hiding the items but they are still in the cart.
Last edit: 14 years 11 months ago by Rickhavoc.
Please Log in or Create an account to join the conversation.
14 years 11 months ago #26847
by nicolas
Replied by nicolas on topic Re: Clearing cart when only "Free" items left in cart?
No. It cleans the cart all the time.
You need to loop on the products in the cart to see whether the products are free or not before using it.
You need to loop on the products in the cart to see whether the products are free or not before using it.
Please Log in or Create an account to join the conversation.
14 years 11 months ago #27055
by Rickhavoc
Replied by Rickhavoc on topic Re: Clearing cart when only "Free" items left in cart?
how would i loop them through the items in the cart? got example where all i would to do is call the function to be called?
Please Log in or Create an account to join the conversation.
14 years 11 months ago #27062
by nicolas
Replied by nicolas on topic Re: Clearing cart when only "Free" items left in cart?
It's really not complicated... Here is an example:
$free = true;
foreach($this->rows as $i => $row){
if(!empty($row->prices)) $free = false;
}
if($free){
//do something
}
$free = true;
foreach($this->rows as $i => $row){
if(!empty($row->prices)) $free = false;
}
if($free){
//do something
}
Please Log in or Create an account to join the conversation.
Time to create page: 0.246 seconds