Fixed Price Sales Rules (Coupons)

Did you know Magento 1.x supports “fixed price” sales rules (ex, Coupons) out of the box? Not many people do and there’s a reason for that. There is a one-line bug that has been left unfixed for over 4 years now. Here is a workaround to allow you to use them:
Add the following to an Observer:

public function workaroundForFixedPricedSalesRules($observer)
{
    $form = $observer->getEvent()->getForm();
    $rule_actions_fieldset = $form->getElements()->searchById('action_fieldset');
    $simpleAction = $rule_actions_fieldset->getElements()->searchById('simple_action');
    $values = $simpleAction->getValues();
    $values[] = array(
        'value' => Mage_SalesRule_Model_Rule::TO_FIXED_ACTION,
        'label' => Mage::helper('salesrule')->__('To Fixed Amount'),
    );
    $simpleAction->setValues($values);
    return $this;
}

 

In your config.xml, add this to the section:

<adminhtml_block_salesrule_actions_prepareform>
    <observers>
        <admin_salesrule_tofixed>
            <type>singleton</type>
            <class>NAMESPACE_MODUELNAME_Model_Observer</class>
            <method>workaroundForFixedPricedSalesRules</method>
        </admin_salesrule_tofixed>
    </observers>
</adminhtml_block_salesrule_actions_prepareform>

Now login to the Admin panel, go to Promotions->Shopping Cart Rules and find “To Fixed Amount” available in the dropdown on the Actions tab. This will allow you to create a rule that forces the price of a product (or group of products) to a specific price regardless of what the current price is (unless, of course, the price is lower than your new rule’s price). This means that you could have a rule that says “French Fries are always $1.99 when the customer enters code FRIES at checkout” and you don’t have to worry about what the current price is for French Fries (as opposed to trying to set a percent off and hoping that someone doesn’t decide to set the price to $2.00 breaking your percent off coupon’s intent).

Comments !

blogroll

social