Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Add ‘is divisible by’ to price rules conditions
 
flowstack
Sr. Member
 
Avatar
Total Posts:  159
Joined:  2008-01-30
London, United Kingdom
 

This would be a handy condition when doing 3 for 2 or BOGOF offers.

At the moment, to do a 3 for 2 offer you have to do:

If ALL of these conditions are TRUE:
    If 
an item is FOUND in the cart with ANY of these conditions true:
        
Quantity in cart is 3
        Quantity in cart is 6
        Quantity in cart is 9
        
<< insert more if needed >>

Obviously this is a pain.

Ideally I could do this:

If ALL of these conditions are TRUE:
    If 
an item is FOUND in the cart with ANY of these conditions true:
        
Quantity in cart is divisible by 3
 
Magento Community Magento Community
Magento Community
Magento Community
 
sdfsdfdsfsdf
Magento Team
 
Total Posts:  4
Joined:  2008-01-18
 

This is a very interesting suggestion, as it is a shopping cart price rule that many Magento users will likely want to enable. Your suggestion of ‘is divisible by’ certainly is a shortcut for having to enter each number manually (3, 6, 9, etc.). However, this would not actually be the best condition to enter in order to create a “buy 3 get one free” rule. With either of the condition sets shown here, the rule will only account for orders containing exactly 3, 6, 9 etc. items. Most Magento users would probably not want to penalize the customer for purchasing 4 items, or 10 items, because you always want to encourage your customers to buy more products, but in this case they would receive no discount at all. This issue needs further attention, as this is such a common marketing tactic.

Assuming you want your rule to apply to all quantities, currently the best way to create a “buy 3 get one free” rule that applies to each factor of 3 would be to create a separate rule for each factor. The first rule would be for quantity greater than or equal to 3 and less than or equal to five, with a fixed amount discount equal to the price of one quantity of that product. The second rule would be for quantity between 6 and 8 with a fixed amount discount equal to the price of two quantities of that product, and so on.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

We’ve added for next release “Buy X get Y free” rule action, which will work the following way:

Buy 3 get 1 free:
1-30 free
4
-61 free
7
-92 free
...

Buy 5 get 2 free:
1-5  0 free
6    
1 free
7
-12 2 free
13   
3 free
14
-194 free
20   
5 free
...
Maximum quantity for discount is still available.

Also, fixed discount for whole shopping cart action was added.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GPutignano
Sr. Member
 
Avatar
Total Posts:  214
Joined:  2007-11-03
Lauria - Italy
 

I don’t understand the above rules.
About ‘is divisible by’ rule I’m agree because we sell wines bottles and packaging is for 6 bottles. For this quantity we optimize the packaging costs and we can make a discount to the customer.

 
Magento Community Magento Community
Magento Community
Magento Community
 
flowstack
Sr. Member
 
Avatar
Total Posts:  159
Joined:  2008-01-30
London, United Kingdom
 

@Moshe - Thanks! Glad to know are suggestions are being incorporated to make the product even greater.

@Garrone - Sounds like you want a discount if someone buys an exactly multiple of 6 bottles. Maybe a modulus rule is needed. E.g. If numbers of items in cart % 6 = 0, then give discount.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GPutignano
Sr. Member
 
Avatar
Total Posts:  214
Joined:  2007-11-03
Lauria - Italy
 
Flowstack - 18 March 2008 02:09 AM

@Garrone - Sounds like you want a discount if someone buys an exactly multiple of 6 bottles. Maybe a modulus rule is needed. E.g. If numbers of items in cart % 6 = 0, then give discount.

Yes, as you said in the first topic.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@Garrone: in 0.9.17740 you can set:

Apply: Percent of product price discount
Discount Qty Step: 6

and it will apply discount amount for packs of 6

 
Magento Community Magento Community
Magento Community
Magento Community
 
GPutignano
Sr. Member
 
Avatar
Total Posts:  214
Joined:  2007-11-03
Lauria - Italy
 

I get an error, however it’s a very good possibility.

Fatal error: Call to a member function getFrontendInput() on a non-object in /home/tradizio/domains/tradizionidelsud.it/public_html/shop/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php on line 142

 
Magento Community Magento Community
Magento Community
Magento Community
 
flowstack
Sr. Member
 
Avatar
Total Posts:  159
Joined:  2008-01-30
London, United Kingdom
 

Very cool Moshe, thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
seDev
Member
 
Total Posts:  51
Joined:  2008-01-22
 
Garrone - 21 March 2008 12:53 AM

I get an error, however it’s a very good possibility.

Fatal error: Call to a member function getFrontendInput() on a non-object in /home/tradizio/domains/tradizionidelsud.it/public_html/shop/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php on line 142

I get this error also, any time I try to select one of the 3 “Cart Item Attributes”. It happens with any Checkout Price Rule I try to create in ver. 0.9.17740.

Séamus

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@Garrone: please replace with attached file: app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php
Which attributes did you use in your price rule?

@seDev: you can’t be getting the same error when using Checkout Price rules, because the error above applies only to catalog price rules.
Could you please paste your error message?

File Attachments
Product.php  (File Size: 8KB - Downloads: 247)
 
Magento Community Magento Community
Magento Community
Magento Community
 
seDev
Member
 
Total Posts:  51
Joined:  2008-01-22
 

Hi Moshe,

Here is the error:

Fatal error: Call to a member function getFrontendInput() on a non-object in /home/auth5t0/public_html/UK/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php on line 142

Thanks for your help,

Séamus

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@seDev: could you try the file attached?

 
Magento Community Magento Community
Magento Community
Magento Community
 
seDev
Member
 
Total Posts:  51
Joined:  2008-01-22
 

Hi Moshe,

I replaced the file and now I get this error:

Fatal error: Call to a member function usesSource() on a non-object in /home/auth5t0/public_html/UK/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php on line 97

(I cleared the cache just in case.)

Thanks,

Séamus

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@seDev: I’ve reuploaded the file to same post, could you please try again?

 
Magento Community Magento Community
Magento Community
Magento Community
 
seDev
Member
 
Total Posts:  51
Joined:  2008-01-22
 

That worked!

Thanks very much, Moshe.

Séamus

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2