I think I have the right place to post this. I'm trying to customize OC 1.5.6.1, specifically the Add To Cart controller, but I'm having a very hard time trying to do something.
Can someone please help me out? I'm trying to limit Add To Cart on a specific group of Products (which I match by Product_ID), that group of products can ONLY ALLOW A MAXIMUM OF 1 PRODUCT be added to the cart. So, I tried adding some code to catalog->controller->checkout->cart.php (right after $product_info= at top of public function add()) as follows:
Code: Select all
// BGS - MAKE SURE ONLY 1 DIGITAL PRODUCT IN CART
$bgsalreadydigital = 0;
$arrdigital = array(66, 67, 71, 72);
if (in_array($product_id, $arrdigital)) {
// DIGITAL PRODUCT - CHECK TO MAKE SURE NO OTHERS EXIST IN CART
if ($this->cart->hasProducts()) {
$this->data['products'] = array();
$products = $this->cart->getProducts();
foreach ($products as $product) {
if (in_array($product['order_product_id'], $arrdigital)) {
$bgsalreadydigital = 1;
break;
}
}
}
}
Code: Select all
if ( $bgsalreadydigital ) {
// BGS NOTIFY ONLY 1 DIGITAL PRODUCT ALLOWED IN CART
$this->data['attention'] = "Only One Digital Product is Allowed in Cart at one time!";
$json['error']['warning'] = "Only One Digital Product is Allowed in Cart at one time!";
$this->response->setOutput(json_encode($json));
// END BGS NOTIFY ONLY 1 DIGITAL PRODUCT ALLOWED IN CART
} else {
Then I found the actual controller exists over in: system->library->cart.php
Should I be modifying that core file, or am I correct in modifying catalog->controller->checkout->cart.php? And, finally, if that is the right module to be modifying, why is my code getting ignored?
Thanks for any help in advance,
-Brett