user1801579
user1801579

Reputation: 31

Magento Shopping Cart Rule - Is this combination possible

Hoping some one can help me with a Magento Rule - is this rule even possible

I have numerous products of numerous sizes all part of the same category.

Each product regardless of size costs £3.98 - If a buyer buys 3 products of the same category regardless of the product or size they get it for £9.99. If they buy 4 products, they get 3 of them for 9.99 but pay full price for the 4th...Every group of 3 is £9.99

I have a rule created that seems to work perfect if a Customer buys 3 / 6 / 9 items of the same product and same size...However if they mix and match it doesn't work (though they are the same category)

The rule is:

IF ALL of these conditions are TRUE: If total quantity equals or greater than 3 for a subselection of items in cart matching ALL of these conditions: Category is 4

I have also set the Discount Qty Step to be 3

* UPDATE *

Thanks for your reply - I have tried to implement what you suggest and have got so far as to where I get the category id of the added products. I'm unsure how to set the price the previous products so it will be an automatically discounted price

$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
$itemPrice = "3.33";

foreach ($cartItems as $items) {
    $product = $items->getProduct();
    $prodCats = $product->getCategoryIds();
    if (in_array('4', $prodCats)) {
        $itemQty = $items->getQty();
    }

    $totalItems += $itemQty;
}

So what I want to do is apply a discount for multiple of 3's for any product that has a category_id of 4...The price will be 3.33 instead of the normal 3.99

Upvotes: 0

Views: 822

Answers (1)

Gerard de Visser
Gerard de Visser

Reputation: 8050

You need event - observer approach for this, that will give you the flexibility you need. You can build an observer that catches the add-to-cart event sales_quote_add_item and put your logic there.

Following code within your observer function will point you in the right direction:

// Get products in cart:

$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
    $itemSku = $item->getSku();
    $itemQty = $item->getQty();
}

// Added product:

$item = $observer->getEvent()->getQuoteItem();
$itemQty = $item->getQty();
$itemSku = $item->getSku();

// Change price of added product:

$item->setOriginalCustomPrice($newPrice);

Good luck!

Upvotes: 0

Related Questions