
Originally Posted by
lankeeyankee
PHP Code:
if ($products[$i]['id'] == $gift->fields['products_id']) { // gift already in cart
$gift_exists = $gift->fields['products_id'];
and add this right below:
PHP Code:
$cart->remove($gift->fields['products_id']);
Disregard this part of the modification. Do NOT insert the above line, it will not work right, but still do insert the first line in my last post. This is the correct modification in it's entirety again:
Still in includes/modules/pages/shopping_cart/main_template_vars.php, find this line:
PHP Code:
$num_in_cart = $_SESSION['cart']->show_total();
and insert right above it:
PHP Code:
$cart = $_SESSION['cart'];
Go down the file and find this line:
PHP Code:
else {
$near_limit = 0;
}
and insert this right after:
PHP Code:
if ($products[$i]['id'] == $gift->fields['products_id'] && $num_in_cart < $gift->fields['threshold']){ $cart->remove($gift->fields['products_id']); zen_redirect(zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL')); }
I have tested and retested and retested and it works as expected. If the cart value changes and falls below the threshold and a free gift is in the cart it will automatically be removed.
The only issue that I can see right now is if a coupon or order total discount such as quantity discount is used during checkout and that brings the cart down below the threshold, the gift will not be removed. I am going to check into that to see what I need to do to change it. If anyone wants to chip in an opinion on how to do it, I am all ears!