Put the following code into /includes/extra_cart_actions/one_per_cart.php; you'll need to edit the ONE_PER_CART_PRODUCT_IDS value to reflect the product_ids of your restricted items:
Code:<?php /** * Extra shopping Cart actions supported. * * The main cart actions supported by the current shoppingCart class. * * NOTE: Many of the defines used in this module have been included by * class.init_quote.php's inclusion of /includes/quotes_status_array.php. * */ define('ONE_PER_CART_PRODUCT_IDS', '14,4,6,11,15'); /*Identify the product_ids of the products that must be ordered separately*/ define('ERROR_ONE_PER_CART', 'Sorry, but you can\'t add "%s" to an order that already contains another item.'); define('ERROR_ONE_PER_CART_COMBINE', 'Sorry, but you can\'t add another item to an order that already contains "%s".'); switch ($_GET['action']) { case 'add_product': $onePerCartIDs = explode (',', ONE_PER_CART_PRODUCT_IDS); $inCartName = ''; foreach ($onePerCartIDs as $theID) { if ($theID == $_POST['products_id']) { if ($_SESSION['cart']->count_contents() > 0) { $error = true; $messageStack->add('product_info', sprintf(ERROR_ONE_PER_CART, zen_get_products_name((int)$_POST['products_id']))); } } elseif ($_SESSION['cart']->in_cart_mixed($theID) != 0) { $inCartName = zen_get_products_name($theID); } } if (!$error && $inCartName != '') { $error = true; $messageStack->add('product_info', sprintf(ERROR_ONE_PER_CART_COMBINE, $inCartName)); } } if ($error) { unset($_GET['action']); } break; }


Reply With Quote
