Shopify themes, liquid, logos, and UX
My store only sells one of a kind unique products and need to make the quantity field read-only on the product and cart pages. it should always be set to 1 when the customer puts the item in their cart and they shouldn't be able to change it. Am using the Craft theme and there doesn't appear to be a setting which controls this. Any help is much appreciated. Thanks.
Solved! Go to the solution
This is an accepted solution.
thanks that worked. also had to make the same changes in the main-cart-items.liquid.
Your storefront is password protected.
Never mind if you can find the quantity input in the code, then please find it and add 'readonly' to the <input> tags.
I've tried doing that in the main-product.liquid file and it doesn't appear to work. See the line I added below in read. Is this not correct?
<input
class="quantity__input"
type="number"
name="quantity"
id="Quantity-{{ section.id }}"
data-cart-quantity="{{ cart_qty }}"
data-min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
{% if product.selected_or_first_available_variant.quantity_rule.max != null %}
data-max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
{% endif %}
step="{{ product.selected_or_first_available_variant.quantity_rule.increment }}"
value="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
form="{{ product_form_id }}"
readonly
Yes thats correct,
if it is not working then the code needs to be checked and changed.
If possible, you can provide the collaborator access for the code editor so I will check and fix the code.
Correction... the readonly works as I'm no longer able to edit the quantity field directly. But I'm still able to change the quantity value with the - or + buttons. How do i prevent that?
In that case just hide the +/- buttons using display:none CSS or comment the +/- buttons html from the code using liquid comments
{% comment %}{% endcomment %}
This is an accepted solution.
thanks that worked. also had to make the same changes in the main-cart-items.liquid.
Yes,
Don't forget to like and accept the solution.
@dhowarth Could you please share your store URL with front password?
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025