Magento Asked by Chad C. Davis on January 8, 2021
Consider the following snippet from my populated Magento CE 1.9.0.1 cart:
I have two test cart rules in play here:
As you can see both rules are coming up valid and are being applied even though after Rule #1 the subtotal (with discount) is less than 100.00. The desired action would be that Rule #2 does not validate because with Rule #1 in play the customer would be spending less than 100.00.
I have fought this issue in a number of ways to no avail. If it can be solved through rule configuration or other configuration I haven’t been able to figure out what that is.
If it can be solved by modifying code can someone point me in the right direction? One thing I tried as a proof-of-concept was to add a new attribute option of “Base Subtotal with Discount” to the Cart Attributes by modifying:
/app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php
class Mage_SalesRule_Model_Rule_Condition_Address extends Mage_Rule_Model_Condition_Abstract
{
public function loadAttributeOptions()
{
$attributes = array(
'base_subtotal_with_discount' => 'Subtotal with Discount',
'base_subtotal' => Mage::helper('salesrule')->__('Subtotal'),
'total_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
'weight' => Mage::helper('salesrule')->__('Total Weight'),
Here I blindly added the first attribute key in that array “base_subtotal_with_discount” simply based on finding that string elsewhere in the code alongside the string ‘base_subtotal’. I was hoping I would get lucky and that would resolve to what I needed but unfortunately it does not. I haven’t been able to figure out where upstream I would define “base_subtotal_with_discount” so that I can use it.
You are half way there. You added the attribute to be validated, but you haven't crafted the validation action that uses the attribute.
If you look at the sales rule configuration in the backend, the third tab on the left has an action, which contains a form specifying where the discount should be applied on. That's where a new option should be for subtotal after discount.
You do this by rewriting and extending Mage_SalesRule. This is one of the few resources I've been able to find that explains some of the complexities involved.
Answered by Melvyn on January 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP