Magento Cart Rule BUG - Wrongly applied when "less than" and configurable product

273 views Asked by At

I just found out that Magento seems to have a bug since 1.8 relating to cart rules.

let's say we have some configurable products and want to add a "discount" for a specific product if the qty is less then 50. In my case it a surcharge not a discount (you can easily add negative discount so it'll get surcharge by changing two files see http://php.quicoto.com/extra-fee-shopping-cart-price-rules-magento/).

so what does magento do?

1) checks if rule is valid for that product 2) if not it checks if it is a configurable product, then takes the first simple product, and check the rule against that.

in this case true cause qty is less then 50 ( cause this simple product is not even in cart.... )

extending the rule by a "less then 50 and more then 1" didn't worked.

    $product = $object->getProduct();
    if (!($product instanceof Mage_Catalog_Model_Product)) {
        $product = Mage::getModel('catalog/product')->load($object->getProductId());
    } 
    // here, everythign correct. $valid is false cause item is less then x times in cart..
    $valid = parent::validate($object);  



// this part makes no sense, cause he's checking on a child which is not in cart.
     /** /
     if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
        $children = $object->getChildren();
        $valid = $children && $this->validate($children[0]);
    }/**/

this small snippet is related to it, and in my eyes it doesn't make any sense. why the rule should be checked against the first product of a configurable one? why randomly check the rule against some other product?

does anyone has an idea about that?

my solution for now, just comment this line out ... ;-) and the rule get applied as it should.

greets felix

here's an image about the rule in magento backend

1

There are 1 answers

3
Igor On

Looks like $object is instance of Mage_Sales_Quote_Item. If so, it explains why rule is being checked against first child - because it is the only child of configurable product in cart. It can't be more than one child of particular configurable product item in the cart at the same time