What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Headless: Displaying Automatic Discount prices

Headless: Displaying Automatic Discount prices

TylerKnapp
Visitor
2 0 0

Issue:

Displaying the discounted price of a product that qualifies for an automatic discount on a custom frontend

 

Summary:

We are looking for guidance on displaying the sales price of a product that belongs to a collection that falls under an automatic discount. We wonder if there is a way to do this without using the Admin API.

 

Example:

The seller has created an automatic discount that reduces the price for all products that fall under the collection "Beach" by 20%

 

On our product index page (custom Next.js app), the sales price needs to have a strikethrough with the discounted price next to it. Is this possible through the Storefront API? 

 

Reply 1 (1)

RococoDigital
Shopify Partner
13 1 11

Automatic discounts are available in the storefront API under checkout -> lineItems -> discountAllocations but these are specific to the customer rather than the product so I'm not sure how you could get them to display on the product page.

 

The normal way to display a price with a strikethrough on product pages would be using the compareAtPrice.