0

I am trying to add free product for specific category, Customer can add only one free product in the cart for specific category. I tried to add shopping cart price rule as

Condition: If total quantity less than 1 for a subselection of items in cart matching ALL of these conditions: Category is 5

Action: If ALL of these conditions are TRUE : Category is 5

But it doesn't work.

And I tried another way by custom coding: get total items by category, if it is greater than count of 1, show haserror message in cart page. This also not working, I don't know exactly where to put this calculation.

Any idea? Help me.

migrated from stackoverflow.com Jan 17 '16 at 18:04

This question came from our site for professional and enthusiast programmers.

  • Can you post the related code ? – Avijit Gupta Jan 8 '16 at 7:11
  • @AvijitGupta: I write a custom code to find out total products in the specific category; Mage/CatalogInventory/Model/Stock/Item.php Mage::getModel('catalog/category')->load($this->getProduct()->getCategoryIds('5'))->getName(); like this, I got the category name by loop, – Lavanya Jan 8 '16 at 7:27
  • Exactly what I need: Only one product customer can add in the cart. I want to write code to relate this, so if i get the total count of item in the category, i can restrict with error : if ($totalItemByCategory>1) { $result->setHasError(true) ->setMessage( Mage::helper('cataloginventory')->__('You cannot add one more free item in the cart.', '') ) ->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.')) return $result; } – Lavanya Jan 8 '16 at 7:30
0

Magento default didn't provide for free product in Shopping Cart Price Rules. You need to find a plug-in for this.

Here cheapest one that I used before.

This one is compatible up to Magento 1.9.2

Then, you can set free product based on which categories.

enter image description here

  • I added the category too, it doesn't work, if I want to edit code, which page should I edit? – Lavanya Jan 8 '16 at 7:00
  • @Lavanya Do you already install this plug-in? – D3ad L0cK Jan 8 '16 at 7:08
  • No. Its not free plugin, suggest me free plugin. – Lavanya Jan 8 '16 at 7:12
  • But we have Shpping cart price rule option in magento itself. I am using Magento 1.7.0.2 – Lavanya Jan 8 '16 at 7:13
  • @Lavanya I'm already find out free plug-in for this. I cannot fin out any other one. All are not free. Paid version :( – D3ad L0cK Jan 8 '16 at 7:14

Your Answer

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

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