Magento – Admin only coupon code

promotions

We have a coupon-less discount for customers placing their first order. For various reasons these customers fail the checkout from time to time and we need to put their failed order through for them, in the admin.

We have a discount with coupon code that we can put in for them, however, there is the risk that this discount code gets widely known for some reason or other. Therefore we would like this particular coupon code to work for admin orders only.

Currently, I don't have any ideas or workarounds on how to make a coupon 'admin only'. Any ideas?

Best Answer

You could just use Mage::app()->getStore()->isAdmin() within the logic where the coupon validity is checked.

You could do it in

Checkout/controllers/CartController.php     couponPostAction()
SalesRule/Model/Validator.php               _canProcessRule()

The latter would probably be preferred, you could just extend the class and add a conditional statement and return false.

Then add an attribute to the coupon model for whether it can be used in the frontend or not.

Eg.

protected function _canProcessRule($rule, $address) 
{

  ...

  if ( Mage::app()->getStore()->isAdmin() && $rule->hasAdminOnly() ) {
    return false;
  }

The above is just pseudo(ish) code, correct to suit your needs.

Related Topic