I've created observer method for salesrule_validator_process event. How can I access coupon code and whole cart to check, if there are specific products in cart? If it found products with a specific criteria how to disable applying entered coupon?

  • Why just not to disable the products with given criteria in the shopping cart rile?
    – Amasty
    Aug 18, 2014 at 19:13

2 Answers 2


The event salesrule_validator_process passes most of the objects that you are looking for.

Mage::dispatchEvent('salesrule_validator_process', array(
    'rule'    => $rule,
    'item'    => $item,
    'address' => $address,
    'quote'   => $quote,
    'qty'     => $qty,
    'result'  => $result,

Here you have the quote (which is the cart). In your method your can call $observer->getQuote().

You can then loop through the items attached to the quote and perform your checks.


In your observer

public function myCouponObserver($event){
  //get quote
  $quote = $event->getQuote();

Get all item (parent)

$cartItems = $quote->getAllVisibleItems();

foreach ($cartItems as $item) {
    //check for sku
    if($item->getSku() == 'xyz'){


To get Coupon

$coupon_code = $quote->getCouponCode();

To remove coupon


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.