0

Promotions -> shopping cart price rules -> conditions tab, there are cart attribute option like the shipping country,shipping state/province. I also want the shipping city. How to get that shipping city in the dropdown.

Thanks,

2 Answers 2

2

Rewrite /app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php file with some local module and change these lines

public function loadAttributeOptions()
    {
        $attributes = array(
            'base_subtotal' => Mage::helper('salesrule')->__('Subtotal'),
            'total_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
            'weight' => Mage::helper('salesrule')->__('Total Weight'),
            'payment_method' => Mage::helper('salesrule')->__('Payment Method'),
            'shipping_method' => Mage::helper('salesrule')->__('Shipping Method'),
            'postcode' => Mage::helper('salesrule')->__('Shipping Postcode'),
            'region' => Mage::helper('salesrule')->__('Shipping Region'),
            'region_id' => Mage::helper('salesrule')->__('Shipping State/Province'),
            'country_id' => Mage::helper('salesrule')->__('Shipping Country'),
        );
        $this->setAttributeOption($attributes);
        return $this;
    } 

to

public function loadAttributeOptions()
    {
        $attributes = array(
            'base_subtotal' => Mage::helper('salesrule')->__('Subtotal'),
            'total_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
            'weight' => Mage::helper('salesrule')->__('Total Weight'),
            'payment_method' => Mage::helper('salesrule')->__('Payment Method'),
            'shipping_method' => Mage::helper('salesrule')->__('Shipping Method'),
            'postcode' => Mage::helper('salesrule')->__('Shipping Postcode'),
            'region' => Mage::helper('salesrule')->__('Shipping Region'),
            'region_id' => Mage::helper('salesrule')->__('Shipping State/Province'),
            'country_id' => Mage::helper('salesrule')->__('Shipping Country'),
            'city' => Mage::helper('salesrule')->__('Shipping City'),
        );
        $this->setAttributeOption($attributes);
        return $this;
    }
1
  • 1
    Hi, a better way is to use salesrule_rule_condition_combine event to add additional address attributes Commented Nov 12, 2014 at 6:39
0

For magento2 users you can modify following file

vendor\magento\module-sales-rule\Model\Rule\Condition\Address.php

but make sure you create file in app folder for modification

app/code/Companyname/Module/Model/Rule/Condition/Address.php

search same function name

public function loadAttributeOptions()

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.