Add new Action to the existing Shopping Cart Price Rules Actions

Add new Action to the existing Shopping Cart Price Rules Actions

August 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Add new Action to the existing Shopping Cart Price Rules Actions

Extending Magento Shopping Cart Price Rules: Adding Custom Actions

Adding new actions to the existing shopping cart price rules is a common customization requirement for many Magento stores. This allows you to provide more advanced promotional offers, but it can be challenging if you’re new to Magento’s core file structure and module development.

Understanding the Default Actions

Before we begin, let’s understand the default actions available in the Magento admin panel:

  1. By Percent Action: Applies a percentage discount to the product price.
  2. By Fixed Action: Applies a fixed amount discount to the product price.
  3. Cart Fixed Action: Applies a fixed amount discount to the entire cart.
  4. Buy X Get Y Free Action: Allows customers to buy a certain quantity of items and get some free (discounted by their price).
  5. Get Percent X Max Y Action: Applies a percentage discount to the total cart, but limits it to a maximum fixed amount.

Adding a New Custom Action

To add a new custom action, we need to follow these steps:

  1. Create the required files in your local codepool:

    • /app/code/local/Mage1/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php
    • /app/code/local/Mage1/SalesRule/Model/Rule.php
  2. Update the config.xml files for your new module:

    In Mage1/Adminhtml/etc/config.xml, rewrite the Actions block and the Rule model:

    <config>
        ...
        <global>
            <blocks>
                <adminhtml>
                    <rewrite>
                        <promo_quote_edit_tab_actions>Mage1_Adminhtml_Block_Promo_Quote_Edit_Tab_Actions</promo_quote_edit_tab_actions>
                    </rewrite>
                </adminhtml>
            </blocks>
        ...
    

    In Mage1/SalesRule/etc/config.xml, rewrite the Validator model:

    <config>
        ...
        <models>
            <salesrule>
                <rewrite>
                    <validator>Mage1_SalesRule_Model_Validator</validator>
                </rewrite>
            </salesrule>
        ...
    
  3. Implement the new action in Actions.php:

    Open Mage1/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php and add your custom option to the $options array of the simple_action field:

    $fieldset->addField('simple_action', 'select', array(
        ...
        'options'    => array(
            // Add your new action here, e.g.:
            Mage_SalesRule_Model_Rule::CUSTOM_ACTION = Mage::helper('salesrule')->__('Your Custom Action'),
            ...
        ),
    ));
    
  4. Update the Rule.php file:

    In Mage1/SalesRule/Model/Rule.php, add your new action constant:

    const CUSTOM_ACTION = 'custom_action';
    
  5. Implement the logic in Validator.php:

    Open Mage1/SalesRule/Model/Validator.php and create a case for your custom action in the process method:

    public function process(Mage_Sales_Model_Quote_Item_Abstraction $item) {
        switch ($rule->getSimpleAction()) {
            ...
            case Mage_SalesRule_Model_Rule::CUSTOM_ACTION:
                // Implement your custom logic here
                break;
        }
    }
    

Conclusion

Adding a new action to the Magento shopping cart price rules requires careful file manipulation and an understanding of Magento’s module structure. By following this guide, you should be able to extend the default actions with your own custom functionality without affecting core functionalities.

Remember that Magento development involves working directly with the core files, so it requires a deep understanding of the platform’s architecture. Always make sure to test your changes thoroughly and consider using version control systems like Git for easier tracking and rollback if needed.

For more advanced Magento development techniques and best practices, I recommend checking out the resources available at LaravelCompany.com. They offer a wide range of tutorials and guides on Magento development, from basic customizations to complex module development.

Checkout Catalog Extensions Admin

Our network