Search code examples
phpmagentomagento-1.9

Magento per customer discount based on qty


I need to apply a discount to certain products based on a per customer discount table but part of this is that there are quantity price breaks for each item in the table on a per customer basis.

What observer is best to hook into in order to apply this discount when the item is added to the cart AND if the qty in the cart is later updated?


Solution

  • To set your code when item added to cart, you can used this observer

    <events>
        <checkout_cart_save_before> 
           <observers>
             <checkout_cart_save_before_handler> 
                <type>model</type> 
                <class>Vendor_Extension_Model_Observer</class> 
                <method>AddToCartBefore</method>  
             </checkout_cart_save_before_handler>
           </observers>
        </checkout_cart_save_before>
    </events>
    

    If any item update from cart, you can used this event.

    <events>
      <checkout_cart_update_items_before>
        <observers>
          <checkout_cart_update_items_before_handler> 
            <class>Vendor_Extension_Model_Observer</class> 
            <method>UpdateCartBefore</method>  
          </checkout_cart_update_items_before_handler>
        </observers>
      </checkout_cart_update_items_before>
    </events>