1

I have a shopping cart rule, Buy product with SKU XXXXX and get Product with SKU YYYYY discounted. I want to automatically add Y product to cart when X product is added.

What I've tried Creating an observer for updateCartAfter

public function updateCartAfter($observer){

Getting the Applied rules

$appliedRuleIds = Mage::getSingleton('checkout/session')->getQuote()->getAppliedRuleIds();

Getting the promo SKUs for the rules applied

foreach($myrules as $key => $value){
    $promoSkus[$key] = $value['promo_sku'];
}

The problem is that my rule is only applied to the shopping cart when the Promo Item (Y) is already in the cart.

I want the rule to be applied when Product X is added so I can pull the promo item(Y) SKU from the rule and add it to the cart automatically. If there's a better way to do this please let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.