# Discount combinations

> What the AndOr goal bar and volume table show when a product sale meets a spend or quantity discount, with worked numbers.

Source: https://backtrackhq.com/docs/developers/combinations/

When a product is on sale and a second discount could also apply, the
volume table and the goal bar have to choose what to show. This page
explains what they show, with worked numbers.

The volume table shows a price only when checkout is certain to give
it. Showing less is allowed. Showing more is a bug. The goal bar works
a little differently. See [The goal bar](#4-the-goal-bar).

## The example product

All examples use one board:

- Regular price: $749.95.
- A product discount called "Summer sale" takes 20% off, so the board
  sells for $599.96.

The numbers are an illustration. Your own prices work the same way.

## Combining is a setting on both discounts

Every Shopify discount has **Combinations** settings. Two discounts apply
together only when each one allows the other's type. If one says no,
Shopify applies whichever saves the shopper more, never both.

AndOr reads these settings at every sync, so the widgets know which
discounts combine. When it can't tell, it treats them as not combined.

| Sale and second discount | Volume table | Goal bar |
|---|---|---|
| Combine | prices tiers from the sale price | measures from the after-sale subtotal |
| Don't combine | shows only tiers that beat the sale | hides while a sale line is in the cart and no tier applies |

## 1. Spend ladder, not combined

The spend ladder is an order discount: 10% off at $1,000, 30% off at
$2,000. It does not combine with the sale.

The volume table shows only the tiers that beat the sale, priced from the
regular price:

| Row | Compared with the sale | Shown |
|---|---|---|
| Spend $1,000+, 10% off | 10% loses to 20% | hidden |
| Spend $2,000+, 30% off | 30% beats 20% | $524.97 each |

At $1,000 checkout keeps the sale, so the board costs $599.96. A row
saying "10% off, $674.96" would be wrong.

- **A shown row never over-promises.** The 30% comes off the whole cart.
  The sale takes at most 20% off part of it.
- **A hidden row can under-promise.** One sale board plus $900 of
  full-price items is $1,649.95 at regular prices. 10% of that is about
  $165, more than the sale's $149.99, so checkout pays the 10%. The
  table hid that row. That is allowed: it says less, never more.
- **A fixed-amount sale** compares money, not percentages. With $150 off
  the board, a 20% tier ($149.99) does not beat it and 21% ($157.49)
  does.

If no row is left, the table does not show.

## 2. Spend ladder, combined

Now both discounts allow each other. Shopify measures the threshold
after the sale, then takes the percentage off the after-sale subtotal.

With 10% off at $1,000 and 20% off at $2,000:

- 2 boards: $1,199.92 after the sale. Checkout takes 10% off ($119.99).
  Total $1,079.93.
- 1 board plus $299.70 of full-price items: $1,049.65 at regular prices,
  but $899.66 after the sale. That is under $1,000, so no order discount
  applies.

So the table prices each row from the sale price:

| Row | Price each |
|---|---|
| Spend $1,000+, 10% off | $599.96 x 0.9 = $539.96 |
| Spend $2,000+, 20% off | $599.96 x 0.8 = $479.97 |

## 3. Quantity ladder beside the sale

A quantity ladder is a product discount: buy 2+ for 10% off, buy 4+ for
25% off. Two product discounts meet on the same line, and by default
Shopify gives each line only the better one.

| Row | Compared with the sale | Shown |
|---|---|---|
| Buy 2+, 10% off | 10% loses to 20% | hidden |
| Buy 4+, 25% off | 25% beats 20% | $749.95 x 0.75 = $562.46 |

A product with its own quantity ladder shows that ladder in the table.
The storewide spend ladder is on the goal bar.

## Ties are hidden

A 20% sale and a 20% spend tier: the row would read "Spend $2,000+, 20%
off, $599.96". The price is right, but one board already costs $599.96.
The row tells the shopper to spend $2,000 for nothing, so it hides. On
a tie, checkout keeps the sale.

## Stacking hides the table

On Shopify Plus, a 20% sale and "buy 4+, 25% off" can both be allowed to
stack on one line. When they can, the table hides.

## 4. The goal bar

When goals compete, AndOr shows one bar so shoppers always see a goal.

- **"Unlocked" only when checkout applied it.** The bar says "You've
  unlocked 10%" only when the cart shows that checkout applied the tier.
- **Combined: measured after the sale.** The distance is the tier's
  threshold minus the subtotal after the sale.

### When the sale does not combine, the bar hides

If the cart holds a sale line that is not known to combine with the spend
ladder, and Shopify has applied no tier, the bar hides. Nothing takes its
place.

Why: when the two do not combine, reaching a tier only swaps the sale for
the tier. The shopper could spend much more and save next to nothing.

The bar comes back when Shopify applies a tier, or when the sale lines
leave the cart. An empty cart, a cart of full-price items and a cart
whose sales combine all show the bar as normal.

Right after an add, the bar keeps its last print until `/cart.js`
answers. If it must hide, it shrinks to one line: "A discount in your
cart can't be combined with order discounts." The line names the other
discount when it can. The shopper's next press or key collapses it.

### Which sale is on the line

Another discount can win a line instead of the known sale, for example a
30% discount for new customers that does not combine. A line counts as
combined only when its discount is the known sale. Free shipping steps
are not checked this way, because shipping discounts apply only once the
shopper enters an address.

### Discounts that combine share one bar

When order discounts, free shipping and a free gift all combine, the app
merges them into one bar with a milestone each. For example: free
shipping at $50, 10% off at $75, a free gift at $120.

- Each milestone names only the reward that starts there.
- The sentence names the next reward: "You're $15.00 away from 10% off".
- Once a milestone is reached, the unlocked line names every reward held.

### Two goal discounts that do not combine

Say one goal pays 5% at $50 and another pays free shipping plus 10% at
$75, and they do not combine. Checkout keeps only one. AndOr still shows
one bar. At some amounts that bar can
name a different reward than the one checkout pays. For exact numbers,
let the goal discounts combine.

## Summary

| Surface | Rule | Can it over-promise? |
|---|---|---|
| Table, spend, not combined | only tiers beating the sale, regular price | no |
| Table, spend, combined | tier off the sale price | no |
| Table, quantity ladder | only tiers beating the sale, per line | no |
| Table, both allow stacking | hidden | no |
| Goal bar, "unlocked" | only when checkout applied it | no |
| Goal bar, sale not combined | hidden until a tier is applied | no |
| Goal bar, rival goal discount | always one bar | yes, it can name a different reward |

Pasted Liquid cannot see the sale or `/cart.js`. Use the blocks or the
`<andor-goal>` and `<andor-tiers>` tags. They follow every rule here.

## A discount only some shoppers get

A discount can be limited to new customers or a customer tag. The
storefront cannot know who is shopping, so the table and the goal bar
cannot tell whether it wins. For those shoppers, they may be wrong.

Example: a 30% discount for new customers won every guest cart. A "Spend
$1,000+, 10% off" row never applied for guests, because 30% was always
bigger.

## For the merchant

For exact numbers, let the sale and the spend discount combine: in each
discount, under **Combinations**, allow the other type. The app's
**Storefront display** page shows a **Not combined with** badge on both
rows when a sale and a spend discount do not combine. See
["Can't be combined" notes](https://backtrackhq.com/docs/help/cant-be-combined/).
