Hello Everyone,
I updated code to reflect the minimum quantity with multiplier affect to my product page and cart page, but I am having issues when I am trying to add qty 12 in product page it shows as qty 1 in cart page. If I press plus sign the qty 12 and it’s multiples appear, I would like to show the quantity shown in product page to cart page. Please guide on fixing this issue. I have shown down below both codes updated on product and cart liquid pages
Product page code
<Input {% assign tags = product.tags | join: ‘,’ %}
{% if tags contains ‘minimum-quantity-’ %}
{% assign minimum_quantity = tags | replace: ‘minimum-quantity-’, ‘’ | plus: ‘minimum-quantity-’ %}
{% else %}
{% assign minimum_quantity = 1 %}
{% endif %}
{% assign multiple_quantity = 1 %}
{% for tag in product.tags %}
{% if tag contains ‘multiple-quantity-’ %}
{% assign multiple_quantity = tag | replace: ‘multiple-quantity-’, ‘’ | plus: ‘multiple-quantity-’ %}
{% endif %}
{% endfor %}
Main-cart-items.;iquid
<Input {% assign tags = item.product.tags | join: ‘,’ %}
{% if tags contains ‘minimum-quantity-’ %}
{% assign minimum_quantity = tags | replace: ‘minimum-quantity-’, ‘’ | plus: ‘minimum-quantity-’ %}
{% else %}
{% assign minimum_quantity = 1 %}
{% endif %}
{% assign multiple_quantity = 1 %}
{% for tag in item.product.tags %}
{% if tag contains ‘multiple-quantity-’ %}
{% assign multiple_quantity = tag | replace: ‘multiple-quantity-’, ‘’ | plus: ‘multiple-quantity-’ %}
{% endif %}
{% endfor %}
<input class=“quantity__input”
type=“number”
name=“updates[{{ item.index}}]”
value=“{{ item.quantity }}”
min=“{{ minimum_quantity }}”
step=“{{ multiple_quantity }}”
aria-label=“{{ ‘products.product.quantity.input_label’ | t: product: item.product.title | escape }}”
id=“Quantity-{{ item.index | plus: 1 }}”
data-index=“{{ item.index | plus: 1 }}”
Thanks!
Hello @poorna123
It looks like the issue might be with the value attribute in the input tag on the product page. Currently, you are setting the value to be the minimum quantity. You should update this to also check for the quantity value that was selected by the customer, like so:
{% assign selected_quantity = 1 %}
{% if quantity > minimum_quantity %}
{% assign selected_quantity = quantity %}
{% endif %}
This will ensure that the selected quantity is displayed in the cart page instead of always showing the minimum quantity.
You can also check our ready app, I think that is helpful and easy to integrate,
https://apps.shopify.com/purchase-limit?
The issue you’re experiencing with the quantity not showing correctly in the cart page when adding 12 as the quantity on the product page is likely due to the minimum and multiple quantity logic. Currently, the minimum quantity and multiple quantity are being set based on the product’s tags. However, the logic for calculating the minimum and multiple quantities seems to be incorrect.
To fix this issue, you can update the code as follows:
Product page code:
{% assign minimum_quantity = 1 %}
{% assign multiple_quantity = 1 %}
{% for tag in product.tags %}
{% if tag contains 'minimum-quantity-' %}
{% assign minimum_quantity = tag | replace: 'minimum-quantity-', '' | plus: 0 %}
{% elsif tag contains 'multiple-quantity-' %}
{% assign multiple_quantity = tag | replace: 'multiple-quantity-', '' | plus: 0 %}
{% endif %}
{% endfor %}
Main-cart-items.liquid:
{% assign minimum_quantity = 1 %}
{% assign multiple_quantity = 1 %}
{% for tag in item.product.tags %}
{% if tag contains 'minimum-quantity-' %}
{% assign minimum_quantity = tag | replace: 'minimum-quantity-', '' | plus: 0 %}
{% elsif tag contains 'multiple-quantity-' %}
{% assign multiple_quantity = tag | replace: 'multiple-quantity-', '' | plus: 0 %}
{% endif %}
{% endfor %}
Hello @poorna123 ,
It seems that the issue you are facing is related to the initial value of the quantity input field on the cart page not matching the value selected on the product page. This can be fixed by passing the selected quantity value from the product page to the cart page.
Here is how you can modify the code on the product page to achieve this:
Add a hidden input field to store the selected quantity value:
Modify the quantity input field to update the selected quantity value when the value is changed:
Add a JavaScript function to update the selected quantity value:
In the cart page code, replace the value attribute of the quantity input field with the selected quantity value:
typescript
<input class=“quantity__input”
type=“number”
name=“updates[{{ item.index}}]”
value=“{{ item.quantity }}”
min=“{{ minimum_quantity }}”
step=“{{ multiple_quantity }}”
aria-label=“{{ ‘products.product.quantity.input_label’ | t: product: item.product.title | escape }}”
id=“Quantity-{{ item.index | plus: 1 }}”
data-index=“{{ item.index | plus: 1 }}”
onload=“updateQuantityInput(this)”
This should ensure that the selected quantity value is passed from the product page to the cart page and displayed correctly in the quantity input field.
Hope it helps. Feel free to connect with us if you have any further questions.
Regards,
CedCommerce
Thanks for your reply, even this code is not helping me. Issue still persists, Do you have any other alternative which you can advise