Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Tiered Pricing on Individual Quantities (and Display)

Tiered Pricing on Individual Quantities (and Display)

InspireConsult
New Member
5 0 0

Hey Everyone! 


Currently running the Tiered Pricing Script found here: 

https://help.shopify.com/en/manual/checkout-settings/script-editor/examples/line-item-scripts#:~:tex...

 

Things that arent working: 

  1. Seems to apply a discount in the TESTING area of the script if just ONE condition is met, for example customer has 2 of product Z and 1 of product Y then it will still discount and show quantity discounts for both (It should only show quantity discount for product Z based on current logic of Min 2.) NOTE: They could select 2 different Flavours or Sizes of a MAIN PRODUCT and I would still want them to get the discount, so basically we want it applied to include variants of a product in the quantity calculations, but not very obviously different products. 

  2. After publishing, its not working on the site at all, I am worried an old currency app has changed the subtotal and totals fields in terms of JS handles? Am I missing a step here? 

 

Custom development:

 

After getting the above working I need to build a table on the front end of the site, below the add to cart buttons, to show this discount opportunity to the customer. I've attached below an example of one that I think would work well. It would show:

Quanitity Examples - Discount % - Resulting Line Item Price

 

Thanks in advance team! 

 

 

 

 

 

Replies 9 (9)

VictoryStore
Tourist
10 0 2

I haven't had issues with it discriminating appropriately between line items within a cart. Best guess is that your product selectors are casting a wider net than you intend, but hard to know without seeing what your inputs are for the PRODUCT_DISCOUNT_TIERS section.

As for the table showing the customer the discounts, I put together a really crude table for ours like this:

<table>
<tbody>
<tr>
<th></th>
<th style="color: white; font-weight: bold;">Standard</th>
<th style="color: white; font-weight: bold;">X Large</th>
</tr>
<tr>
<td style="font-weight: bold;">2 - 4</td>
<td>$30</td>
<td>$35</td>
</tr>
<tr style="background-color: #f1f1f1;">
<td style="font-weight: bold;">5 - 24</td>
<td>$28</td>
<td>$33</td>
</tr>
<tr>
<td style="font-weight: bold;">25 - 34</td>
<td>$23</td>
<td>$28</td>
</tr>
<tr style="background-color: #f1f1f1;">
<td style="font-weight: bold;">35+</td>
<td>$20</td>
<td>$25</td>
</tr>
</tbody>
</table>

Which ends up looking like this on the front end:

price table.JPG

 

InspireConsult
New Member
5 0 0

Thanks for your reply! We moved to an alternative script I found online, unfortunately now this one is TOO restrictive, where it is requiring a customer to select multiples of the EXACT size/flavour. Ideally, we want them to be rewarded with a discount on the same item in ANY flavour where they purchase two or more of. I have included the script below, surely there would be a balance we could run between the two scripts. It's very strange that the original Shopify script provided wasn't working as intended. 

 

Again, here is the script below we are CURRENTLY running - I have implemented a similar HTML table also, thanks for your feedback on this: 

 

DISCOUNTS_BY_QUANTITY = {
3 => 10,
2 => 5,
}

Input.cart.line_items.each do |line_item|
next if line_item.variant.product.gift_card?

quantity, discount = DISCOUNTS_BY_QUANTITY.find do |quantity, _|
line_item.quantity >= quantity
end
next unless discount

message = "#{discount}% off when buying at least #{quantity}."
line_item.change_line_price(
line_item.line_price * (Decimal.new(1) - discount.to_d / 100),
message: message,
)
end

Output.cart = Input.cart

 

VictoryStore
Tourist
10 0 2

Ah, I see, that honestly seems a little tough. Since each variant is is its own line item, you need concatenate all the variants for a given product into a single array before running the discount math on it. That's a bit beyond my level of script editing, but if you know someone good with Ruby, that's what I'd request. Otherwise, honestly, it might be worth the cost to pay for one of those quantity discount apps.

YOURslipmat
New Member
5 0 0

I had the same complex pricing issues, but installed a volume pricing app and the job was done.

Tried several apps, and would highly recommend these folks;

https://custom-pricing.shopacado.com/

InspireConsult
New Member
5 0 0

Tried all available apps (including the one you mentioned) but found them very slow and buggy. It didn't like our discount code field in our cart (before checkout) and was erroring. 

 

Scripts are the way to go and HTML table (which is working) - ill keep working through the script issues and report back. 

 

 

Open to other suggestions also 

YOURslipmat
New Member
5 0 0

Hey m8,

There is a option page in the app which allowes you to turn those discount code fields off, or design/customize it (colors, fonts, etc).

InspireConsult
New Member
5 0 0

Nah man that app sucks. I have had plenty of custom apps built previously and it is laggy, glitchy, and the ui/ux is average at best. 

YOURslipmat
New Member
5 0 0

Well.. thats a subjective matter I suppose 😃.

 

 

InspireConsult
New Member
5 0 0

There is nothing subjective about an app that does not do what it states. or negatively impacts site performance. 

I am here for assistance with a script. Please stay on topic.