Product prices are wrong after returning to product page from cart page.

Have you ever seen your product price increase or start higher than it should after returning back to a product from the cart page?

As long as your calculation does not rely on the product base price this will generally not be a problem. If your calculation uses the base price of the product either through the product_price variable or through the “Add Product Base Price to Option Price” setting, your product price may be wrong after returning to the product from the cart page.

This happens as a result of your cart.liquid page linking back to the product variant originally added to cart instead of the base product.

When you return to the product page you are actually on a variant of the product not the main product itself.

You can see this when hovering over the link to the product in your cart and in the page url after going back to the product.

This is technically not a problem with Option Price Calculator and instead that of how your Store Template links back to products added to cart.

Option Price Calculator already removes product variant query parameters from product links in items added to slideout cart, popup add to cart window and new products added to cart. Refreshing the page will cause your store template to take over and change these links.

What we need to do is change the way your theme links to products.


There are a few ways of fixing this.

Here is the easy one:

replace {{ item.url }} with {{ item.product.url}}

  1. Open your theme editor.
    Online Store -> Themes -> Action -> Edit Code
  2. Search for cart.liquid theme file
  3. Open cart.liquid
  4. Search for the following for loop {% for item in cart.items %} or {%- for item in cart.items -%}
    (Formatting may vary slightly)
  5. Replace {{ item.url }} with {{ item.product.url}}

Another solution if the above does not work.

  1. Open your theme editor.
    Online Store -> Themes -> Action -> Edit Code
  2. Search for cart.liquid theme file
  3. Open cart.liquid
  4. Search for the following for loop {% for item in cart.items %} or {%- for item in cart.items -%}
    (Formatting may vary slightly)
  1. Find any code with {{ item.url }}

    We need to change {{ item.url }}

    this will be the link to the product just added to cart and will include the v=43975973294 parameter representing the product variant added to cart.

  2. Add the following code at the top and inside the for loop:

    {% assign product_url = item.url | split: ‘?variant=’ %}

    Technical background knowledge you might not care about:
    This code will split the item URL into an array with two element. The first part will contain the url without the variant. The second part will contain the variant id. the text ?variant= will be removed.

    Example:
    product_url = [“https://option-price-calculator.myshopify.com/products/custom-computer”,”42466722644128″]

  3. Replace each occurrence of {{ item.url }} with {{ product_url[0] }}

    The cart.liquid page count have additional references to {{ item.url }}. Make sure to only replace the one related to your cart table. Typically, this will be a link for the image and a link for the product title.