Limit order quantity by category or add additional shipping charge by category in Magento -


i have issue magento.

i have category customers can buy 1 product category per order. have set settings such 1 item can added in product settings. however, if customer goes category, still able add product in category. selects product category a, can return category select product b. want @ times, order, can buy 1 product category a.

if not possible, wish add additional shipping charge if more 1 product chosen category.

does have solution this?

see magento: limit 3 products category per order

create observer event checkout_cart_product_add_after

     <events>         <checkout_cart_product_add_after>             <observers>                 <enableduplicateproductstatus>                     <type>singleton</type>                     <class>limitcartproductbycategory/observer</class>                     <method>cartlimit</method>                 </enableduplicateproductstatus>             </observers>         </checkout_cart_product_add_after>     </events> 

create: app/code/local/magepal/limitcartproductbycategory/model/observer.php

class magepal_limitcartproductbycategory_model_observer  {      public function cartlimit(varien_event_observer  $observer)     {         $category_ids = array();          $quote = mage::getsingleton('checkout/session')->getquote();         foreach($quote->getallvisibleitems() $item){               $product = mage::getmodel('catalog/product')->load($item->getid());               $product_category_ids = explode(",", $product->getcategoryids());               //$product_category_ids = $product->getcategoryids();                array_push($category_ids, $product_category_ids);         }          $justadded = $observer->getquoteitem();           $productjustadded = mage::getmodel('catalog/product')->load($justadded->getid());          //total category id in $category_ids         //if $productjustadded->getcategoryids exist in $category_ids,          //then check see if category id count greater 3         // if true add error msg , try setting qty 0          return $this;     } } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -