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.
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.
I think I can help create a script for you.
Most of this seems straightforward, but the part I need clarification on is:
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,
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 🙂
@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-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.
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...By Ollie Jul 28, 2022