Try this for the replacement for the add_product clause (it worked by me!). Essentially, I restructured the clause to first check to see if there's a download among the options and, if so, check to see if there's an instance already in the cart (in which case a redirect to the goto page occurs with no additional cart processing) or if there's not to reduce the quantity to 1 (with message) and let the base add_product processing perform its magic.
Code:
/*---- Add a product to cart ----
**
** If a product is being added to the cart (with a quantity greater than 0) and that product has attributes (the $_POST['id'] array
** is set), then if either that product is already in the cart -OR- if the quantity to be added is greater than 1,
** check each of the attributes being added to see if there is a download/virtual product amongst them. If so,
** don't allow the duplicate download/virtual product to be added to the cart ... or just add 1 if this is the original add.
*/
case 'add_product':
//-bof-v1.1.1c
if (isset($_POST['products_id']) && $_POST['cart_quantity'] > 0 && isset($_POST['id']) && is_array($_POST['id'])) {
foreach($_POST['id'] as $option => $value) {
if (ldProductIsDownload ($_POST['products_id'], $option, $value)) {
if ($_SESSION['cart']->in_cart(zen_get_uprid($_POST['products_id'], $_POST['id']))) {
$messageStack->add_session('header', sprintf(ERROR_MAXIMUM_DOWNLOADS, zen_get_products_name($_POST['products_id'])), 'caution');
zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
} elseif ($_POST['cart_quantity'] > 1) {
$_POST['cart_quantity'] = 1;
$messageStack->add_session('header', sprintf(ERROR_MAXIMUM_DOWNLOADS, zen_get_products_name($_POST['products_id'])), 'caution');
}
break;
}
}
}
//-eof-v1.1.1c
break;
:
Bookmarks