How to make BOGO script have minimum spend + discount the lowest items in each grouped price

MiaAus
New Member
3 0 0

Hi, 

I am wanting to create a script for the following promotion: Buy 1, Get 1 free. Applies to selected collections only, minimum spend of $100 required. 

The items placed in the cart should be grouped in order of prices in pairs, then the free item should be the cheapest in the pair. The collections would be determined by the tags. 

 

I've tried the several of the script examples found in the help centre but they don't work fully as I need it to. 

Either:

  • they do not enforce the minimum spend, or
  • the script randomly selects which item is to be discounted, or
  • if there are 4 items from the selected collections eligible for the offer in the cart, only 1 item is being discounted instead of 2, or
  • if it applies on 2 items, it only applies on the 2 lowest prices of the group of 4 instead of grouping similar priced items in pairs (in this example) and discounting the lowest out of each pair. Example, 4 items are $62, $56, $52, $46. The $56 and $46 items should be free in the Buy 1, Get 1 Free script. 

I've tried to mix and match from different examples as well but they don't really work. 

I'd also like for this script to work if it was "Buy 2, Get 3rd Free" for example. 

The automatic discount doesn't allow to have both the minimum spend and minimum qty purchased and it also applies the discount only on the lowest items instead of the lowest in the groups of similar prices. So I can't use this unfortunately. 

0 Likes

Hi @MiaAus,

I think I can help create a script for you.

Most of this seems straightforward, but the part I need clarification on is:

  • "items placed in the cart should be grouped in order of prices in pairs"
  • "grouping similar priced items in pairs"

Is there a way in the product configuration (like SKU, type, vendor, etc) or a line item property you are using to "grouping similar priced items in pairs"? Or is it literally just "any item with a price ending in a 6 should be grouped with all other items with a price ending in 6". 


Also, the Script Editor scripts do not have access to the collection of a product. You will either need to add tags to the product itself, or supply the collection name/tag as a line item property in the cart.


Looking forward to your response,
Matthew

Playwright | Create Shopify Scripts without writing code | https://playwrightapp.com
- Was my reply helpful? Please Like and Accept Solution.
- Need help with a custom Shopify script? Email me at matthew@playwrightapp.com

0 Likes
MiaAus
New Member
3 0 0

Hi @playwright-matt , 

Thank you for your reply and your offer to help. 

Yes, I use different tags to already file products in different categories depending on what I would like the different offers to be and therefore the script to do. 

So for the first condition - the minimum spend: Lets say that I have about 13 different tags. 10 of them would count towards the minimum spend of $100 after discount (in this example). 3 of them cannot count towards the minimum spend of $100. 

Then the second condition - Buy 1 of X collection, Get 1 of X collection free: I have 4 of those 10 tags that would be discount-eligible (X collection). So buy 1 item of one of those 4 tags, get another item of one of those 4 tags for free. They don't have to be the exact same item as long as they are items that have one of those 4 tags. 

In terms of groupings, ideally I would like the cart to organise the items with the 4 discount-eligible tags in order of price (highest to lowest), then apply the discount to every 2nd for this example. (If the offer changed to Buy 2, Get 3rd free, then it would apply the discount to every 3rd item with the discount-eligible tag). 

I hope I have answered your questions but would happy clarify further if needed. 

To note that in my 'perfect scripting world', I'd really like to re-use the script but change the conditions if possible

0 Likes

@MiaAus, thanks for the additional explanation.

I still come back to this portion of your requirements: "...ideally I would like the cart to organise the items with the 4 discount-eligible tags in order of price (highest to lowest), then apply the discount to every 2nd for this example (or 3rd in a Buy 2 get 1 free scenario)."

From a technical point of view, this feels a bit error prone and somewhat hard to test. It's not impossible, but is likely to break with small changes to the script or product configurations. My goal is to provide scripts that are robust and reliable. Thus, I would recommend some other way of "grouping" the items or determining which one gets the discount.

Any thoughts on that?

Playwright | Create Shopify Scripts without writing code | https://playwrightapp.com
- Was my reply helpful? Please Like and Accept Solution.
- Need help with a custom Shopify script? Email me at matthew@playwrightapp.com

0 Likes
MiaAus
New Member
3 0 0

@playwright-matt, thank you for your reply. 

Unfortunately no, there are no other way of grouping that would work since the discount should apply to the lowest price of the Nth item as per what the promo refers to. Meaning, if it's Buy 1, Get 1 at a discount, the discount should apply to every 2nd item in order of the price. If it's Buy 2, Get the 3rd at a discount, then the discount should apply to every 2nd item in order of the price. And so on. 

0 Likes