Automatic Discount on Product page

I am trying to display automatic discounts on the product page, but when the page refreshes it duplicates the item in the cart.

2 Likes

Hey @sohail_shahzad, welcome to the developer community!

To help us (or anyone else passing by) dig into this, we’ll need a bit more detail. Our community FAQ covers what to include when posting, but the short version is:

  • How are you displaying the automatic discount on the product page? (Liquid, JavaScript, a theme app extension, a Shopify Function, etc.)
  • Can you share the relevant code with any PII removed?
  • Steps to reproduce the duplication. Does it happen on every page refresh, or only under certain conditions?
  • Any error messages in the browser console or network tab?

The cart duplication on refresh sounds like it could be an unintentional cart add firing on page load, but that’s just a guess without seeing the implementation.

2 Likes

Hi @sohail_shahzad

it is normal issue. Did you chat with the support team?

Hey @sohail_shahzad, this usually happens when the auto-discount logic re-runs on page reload and re-adds the product instead of checking the existing cart state.

If you’re using JS/AJAX to apply the discount, make sure you’re validating whether the item already exists in the cart before triggering the add-to-cart again.

Also worth checking if the script is firing multiple times (especially on page load or via event listeners).

Can you share how you’re implementing the discount (theme code, app, or function)? That’ll make it easier to pinpoint.

1 Like