1

I hope you can help me out on this one :) I've tried different ways of achieving this but up untill now with no luck. I'm starting to doubt if maybe the apply coupon button isn't working or the price simply doesn't get updated.. Or most likely: that my combination of conditions are just not correct, hah :)

So, I have tried to set conditions with categories and I've tried it with sku's. The idea is that if a customer buys one (or multiple) products in a specific category, that they'll get another product for free.

In this example below, I chose the option to add a percentage of discount - 100%. The product below at the Actions section is the one that should get 100% discount. The ones in the condition section should be in the cart in order to apply this discount. I've also tried a fixed amount, which was the entire price of the product. Also tried to set both the percentage and price discount options to less than the total amount of the product to see if that could possibly work. None of them with any success.

Example 1: Conditions:

If ALL of these conditions are TRUE :

If total quantity equals or greater than 1 for a subselection of items in cart matching ALL of these conditions: Category is 00

Actions: Percent of product price discount = 100, max qty discount is applied to 1

If ALL of these conditions are TRUE :

Category is 11

Also tried this with sku's, or at the condition part with - If an item is FOUND in the cart with ALL of these conditions true: - instead of the quantity rule. Also tried to change ALL to ANY.

Example 2, the sku version:

If ALL of these conditions are TRUE :

If total quantity equals or greater than 1 for a subselection of items in cart matching ALL of these conditions: SKU is one of poduct1, product2, ...

If ALL of these conditions are TRUE :

Category is 11

I've possible tried other combinations too, but I kind of lost track of all these combinations that I've tried, hah.

I'm wondering how I can achieve this with the rule combinations.. If even possible. Or is the above correct and is it something else?

Am I even in the correct direction to achieve this discount rule thing?

closed as off-topic by Fabian Schmengler, 7ochem, saravanavelu, Mufaddal, Marius Aug 21 '15 at 11:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced OR seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Fabian Schmengler, 7ochem, saravanavelu, Mufaddal, Marius
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Okay, in case anyone is looking to achieve the same. Nothing is wrong with the above. I have set a fixed amount discount (full product price) and have used the sku version. The problem was that the line "<?php echo $this->getChildHtml('coupon') ?>" was on the wrong place in my code, so none of the coupons worked. If this line is in its default location, everything works just fine (I have an entire modified version though, so had to search :) ) – Suus Jan 26 '14 at 16:58
  • Another option is adding a new action to the shopping cart price rules, "add product as a gift". There is a small, free extension that does this for you: github.com/code4business/freeproduct (Disclaimer: I was involved in the development of this extension) – Fabian Schmengler Aug 21 '15 at 10:01
  • magento.stackexchange.com/questions/85592/… go with This URL Perfect Solustion – SURENDER SINGH Jan 8 '18 at 8:03
1

You can get all the items in cart

$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
    $productId = $item->getProduct()->getId();
    $productPrice = $item->getProduct()->getPrice();
}

Then you can check if your condition is justified, which means if you have required product in cart, then you can add your free product to cart dynamically.

$product_model = Mage::getModel('catalog/product');
$productid = $product_model->getIdBySku($_sku);
$my_product = $product_model->load($productid);
$qty_value = 1;

//Add to cart code
$cart = Mage::getModel('checkout/cart');
$cart->init();
$cart->addProduct($my_product, array('qty' => $qty_value));
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
  • Okay great, i still have to try this one out, but is there also an option to attach/combine this with magento's coupon codes? Or do you reckon that its easier to simply write an own "if entered coupon code matches, perform all of the actions" code? I thought i was close with the cart rules above, hah – Suus Jan 21 '14 at 18:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.