I am looking for a way to have a coupon code that can only be used through code and not be allowed to be used in the cart. I am programmatically adding the coupon code to the cart when the user is redirected to the site through a 3rd party system to a hidden url. This way the coupon code can not be distributed on the net and only used when coming from the 3rd party system.

Any idea how I can do this?

1 Answer 1


So I assume you've got an information in customer session or quote when he comes from the 3rd party system.

You can hook into event sales_validator_process at frontend area and cancel a specific coupon (or even go further and set it as a condition).

An observer method could look something like this:

public function cancelCouponForFrontendArea(Varien_Event_Observer $observer) {
    /* @var $rule Mage_SalesRule_Model_Rule */
    $rule = $observer->getEvent()->getRule();
     * @var $quote Mage_Sales_Model_Quote
    $couponCode = $rule->getCode();
    if ($couponCode === 'RTL25OFF') { // or another if statement like if(Mage::getSingleton('customer/session')->getIsFromThirdPartySystem())
        $quote = $observer->getQuote();


Module's config event observer:

  • That works perfectly and only 5 minutes to implement!!!
    – Trevor Orr
    Feb 3, 2017 at 21:11

Your Answer

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

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