# Buy One X Get One X free?

Thread began 7/29/2014 4:20 am by Nathon Jones Web Design | Last modified 7/08/2015 5:25 pm by Ray Borduin | 894 views | 8 replies |

## 7/29/2014 4:20 am  |  #1 Nathon Jones Web Design

### Buy One X Get One X free?

How can I apply a discount rule to achieve a buy one (of x) get one (of x) free but only on particular products?
Thank you.
NJ

## 7/29/2014 11:13 am  |  #2 Jason ByrnesWebAssist

That can get a little tricky. I'll need a little further clarification on how you want this to work.

In other words, if they order 4 of a product the discount applies to, should the discount be for 2 free or only 1 free and the other 3 at regular price?

where the discount applies to multiple products, do you want it to work that if they order 1 each of 2 products the discount applies to, they should get one of them free? is the discount applied to the aggregate of products it applies to or only at a product by product basis?

## 7/31/2014 11:01 am  |  #3 Nathon Jones Web Design

No, it's purely buy one of X, get one of X free regardless of quantity or other items that may be on offer. Product by product basis.
Thank you
NJ

## 7/31/2014 11:23 am  |  #4 Jason ByrnesWebAssist

but what is X?

so if they buy 4 of product A and 3 of product B, they should get one each of product A and B for free?

## 7/31/2014 11:49 am  |  #5 Nathon Jones Web Design

They buy 1 of product X, they get 1 product X free (X being one product!).

Thank you
NJ

## 7/31/2014 12:45 pm  |  #6 Jason ByrnesWebAssist

you will need another cart column to mark the items that should get the discount. for example sakes, lets say the column is named:

for items the discount applies to set the column value to 1 in the add to cart, and 0 for items the discount does not apply to

then a calcualtion to calculate the discount amount using an abs() condition:

abs([buy1Get1] == '1' && [Quantity] >= '2')?[Price]:0

Then create a discount to apply the discount:
triggers:
Subtotal for any column:
subtotal of column 'buy1Get1Discount' > 0

calculation:
subtotal of column 'buy1Get1Discount' plus 0

## 11/14/2014 5:44 am  |  #7 Nathon Jones Web Design

Rather than a column specific to buy1Get1, is it possible to create a column that stores an identifier (int) for a range of different offers and then have the discount rule only apply if a product is set to it's corresponding identifier?

So we'd have an 'offers' table in our database:
offerID offertitle offergraphic
1 Buy One Get One Free bogof.jpg
2 10% Discount 10percentoff.jpg
etc

...and then apply the discount calculation if, in the calculation, the correct condition is met?

Considering our 'offers' table above, would I simply change the calculation to?:
abs([offerID] == '1' && [Quantity] >= '2')?[Price]:0

What is this part doing?:
?[Price]:0

I'd appreciate some clarification on the calculation and also what we'd need to do to change that calculation to offer a % discount.

Thank you
NJ

## 11/14/2014 12:50 pm  |  #8 Jason ByrnesWebAssist

Yes, you could do that , you would need to add the offerID column to the cart object and in the add to cart button set it to store the offer ID for the specific product

the calculation:
abs([offerID] == '1' && [Quantity] >= '2')?[Price]:0

would set the discount to be the value of [Price] if the offerID is 1 and the quantity is >= 2

the calculation is ternary expression, basically it is a shorthand if statement in the form of:

(Question)?true:false

so lets take an item with the following settings:
Price: 10
offerID:1
quantity: 1

the calculation
abs([offerID] == '1' && [Quantity] >= '2')?[Price]:0

would return 0 because the Quantity is not equal to or greater than 2. the question returns false and 0 is the false part of the calculation.

now set the product as:
Price: 10
offerID:1
quantity: 2

the calculation:
abs([offerID] == '1' && [Quantity] >= '2')?[Price]:0

the question is now true, so returns 10, that is the value of [Price], which is the true part of the calculation

increase quantity to 3 or above, it still returns 10

to create a calculation to apply a 10% discount, the calculation would be:
abs([offerID] == '2')?([Price] * 0.1):0

on this calculation, the product settings:
Price: 10
offerID:2
quantity: 2

would return 1 (10 * 0.1 = 1)

you could add a quantity check in there if you like:
abs([offerID] == '2' && [Quantity] >= '2')?([Price] * 0.1):0

so it only applies if the quantity is greater than or equal 2

or you could add the quantity into the calculation so that an item with quantity 3 would return 3 instead of 1:
abs([offerID] == '2' && [Quantity] >= '2')?(([Price] * [Quantity]) * 0.1):0

(10 * 3 = 30) * 0.1 = 3

## 7/08/2015 4:24 pm  |  #9 pledge204907

For a true Buy One Get One Free this calculation should work:

abs([offerID] == '1' && [Quantity] >= '2')?([Price] * floor([Quantity] / 2)):0

## Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

## Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

## Everything else!

Close Window

Account or customer service questions?

Need technical support?

Content

Layout

Ease of use

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Window

## We were unable to retrieve the attached file

Close Window

### Attach and remove files

• Text Formatting
• Insert Element
• Block Formatting
• Cancel
Close Window

Close Window

#### This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --