All things Shopify and commerce
I have added a snippet in this way in main_product.liquid page.
<input class="quantity__input"
type="number"
name="quantity"
id="Quantity-{{ section.id }}"
min="0.5"
max="{{ product.selected_or_first_available_variant.inventory_quantity}}"
value="0.5"
step="0.5"
form="{{ product_form_id }}"
>
The quantity selected in decimal isn't getting updated in cart page. And the price also doesn't get updated. Kindle help! THANK YOU
Solved! Go to the solution
This is an accepted solution.
Hey @Ashi1410 , I added it in the form of Dropdown menu.
Here is the code:
<select class="product-quantity--input"
id="{{id}}--quantity" name="quantity" form="{{ id }}" >
{% for i in (1..product.selected_or_first_available_variant.inventory_quantity) %}
<option value="{{ i }}">{{ i|divided_by:2.0 }}</option>
{% endfor %}
</select>
Hey mate!
Unfortunately the quantity has to be an integer, so 0.5 won't work. You have to increase the quantity by a whole number.
What is the use case of adding a product in increments of half an item? There may be a workaround but unsure what you are trying to achieve. Could you set the product price to be 50% and then use whole numbers for the quantity? You would want to express this to the user though so they don't get confused. If you have a link pass it through 😀
Hey! Thank you for the response. My store is based on fabrics. I need to sell them in meters. So i want options such as 0.5m, 1m etc. Is there any other way(except variants) through which i can achieve this?
Okay, that makes a bit more sense. Thank you for sharing.
My advice would be to rename the products to contain 0.5m lengths, for example, 0.5m Egyptian Cotton. That way when the user has selected a quantity of 2, it would be 1m of the fabric.
Depending on your coding knowledge, you could add an event listener to the quantity change and show the total fabric to the user. That would clear up any confusion the user might have.
I hope that help!!
Now my store is working on that method itself. I did specify 0.5 cotton and its price (same as you said). I want a better quantity selector for better working and understanding.
my store: https://antriksh.thefolkfair.com/
Hello DevoloperCZ sir,
I hope you're well. I'm also facing the same issue you can share the code so I can fix my problem?
Thank you
This is an accepted solution.
Hey @Ashi1410 , I added it in the form of Dropdown menu.
Here is the code:
<select class="product-quantity--input"
id="{{id}}--quantity" name="quantity" form="{{ id }}" >
{% for i in (1..product.selected_or_first_available_variant.inventory_quantity) %}
<option value="{{ i }}">{{ i|divided_by:2.0 }}</option>
{% endfor %}
</select>
Hello @DevoloperCZ sir,
Thank you for your reply
Can you please guide me on where I must update this code so that my quantity selector works like 0.5,1,1.5,2,2.5 etc?
(I'm using Impulse theme)
thank you
Hey @Ashi1410 , the code must be updated in product and cart page.
product-quantity.liquid and cart.liquid. I need to know if you have these files in your code.
No sir
I have these files
Then place it in main-product.liquid
Where? at the end?
after updating this code quantity is still not update
Replace it with quantity input here
sir if you don't mind may I know your email id so that I can share you the code of my website
Hello DevoloperCZ sir,
I'm sharing the code kindly add 0.5 , 1 , 1.5 , 2, 2.5 etc code into it.
Thank you
{%- liquid
assign isModal = false
if template == 'product.modal'
assign isModal = true
endif
-%}
{%- render 'product-template',
product: product,
section_id: section.id,
blocks: section.blocks,
image_position: section.settings.image_position,
image_container_width: section.settings.image_size,
product_zoom_enable: section.settings.product_zoom_enable,
sku_enable: section.settings.sku_enable,
isModal: isModal,
thumbnail_position: section.settings.thumbnail_position,
thumbnail_arrows: section.settings.thumbnail_arrows,
mobile_layout: section.settings.mobile_layout,
video_looping: section.settings.enable_video_looping,
video_style: section.settings.product_video_style
-%}
{% schema %}
{
"name": "t:sections.main-product.name",
"settings": [
{
"type": "checkbox",
"id": "sku_enable",
"label": "t:sections.main-product.settings.sku_enable.label"
},
{
"type": "header",
"content": "t:sections.main-product.settings.header_media"
},
{
"type": "paragraph",
"content": "t:sections.main-product.settings.content"
},
{
"type": "select",
"id": "image_position",
"label": "t:sections.main-product.settings.image_position.label",
"default": "left",
"options": [
{
"value": "left",
"label": "t:sections.main-product.settings.image_position.options.left.label"
},
{
"value": "right",
"label": "t:sections.main-product.settings.image_position.options.right.label"
}
]
},
{
"type": "select",
"id": "image_size",
"label": "t:sections.main-product.settings.image_size.label",
"default": "medium",
"options": [
{
"value": "small",
"label": "t:sections.main-product.settings.image_size.options.small.label"
},
{
"value": "medium",
"label": "t:sections.main-product.settings.image_size.options.medium.label"
},
{
"value": "large",
"label": "t:sections.main-product.settings.image_size.options.large.label"
}
]
},
{
"type": "checkbox",
"id": "product_zoom_enable",
"label": "t:sections.main-product.settings.product_zoom_enable.label",
"default": true
},
{
"type": "select",
"id": "thumbnail_position",
"label": "t:sections.main-product.settings.thumbnail_position.label",
"default": "beside",
"options": [
{
"value": "beside",
"label": "t:sections.main-product.settings.thumbnail_position.options.beside.label"
},
{
"value": "below",
"label": "t:sections.main-product.settings.thumbnail_position.options.below.label"
}
]
},
{
"type": "checkbox",
"id": "thumbnail_arrows",
"label": "t:sections.main-product.settings.thumbnail_arrows.label"
},
{
"type": "select",
"id": "mobile_layout",
"label": "t:sections.main-product.settings.mobile_layout.label",
"default": "partial",
"options": [
{
"value": "partial",
"label": "t:sections.main-product.settings.mobile_layout.options.partial.label"
},
{
"value": "full",
"label": "t:sections.main-product.settings.mobile_layout.options.full.label"
}
]
},
{
"type": "checkbox",
"id": "enable_video_looping",
"label": "t:sections.main-product.settings.enable_video_looping.label",
"default": true
},
{
"type": "select",
"id": "product_video_style",
"label": "t:sections.main-product.settings.product_video_style.label",
"default": "muted",
"options": [
{
"value": "muted",
"label": "t:sections.main-product.settings.product_video_style.options.muted.label"
},
{
"value": "unmuted",
"label": "t:sections.main-product.settings.product_video_style.options.unmuted.label"
}
],
"info": "t:sections.main-product.settings.product_video_style.info"
}
],
"blocks": [{
"type": "@app"
},
{
"type": "price",
"name": "t:product_block.price.name",
"limit": 1
},
{
"type": "quantity_selector",
"name": "t:product_block.quantity_selector.name",
"limit": 1
},
{
"type": "size_chart",
"name": "t:product_block.size_chart.name",
"limit": 1,
"settings": [
{
"type": "page",
"id": "size_chart",
"label": "t:product_block.size_chart.settings.page.label"
}
]
},
{
"type": "image_picker",
"name": "Icon Image",
"limit": 5,
"settings": [
{
"type": "image_picker",
"id": "product_img",
"label": "Enter the image"
},
{
"type": "text",
"id": "prod_icons",
"label": "Enter the text"
}
]
},
{
"type": "variant_picker",
"name": "Variant picker",
"limit": 1,
"settings": [
{
"type": "checkbox",
"id": "variant_labels",
"label": "t:product_block.variant_picker.settings.variant_labels.label",
"default": true
},
{
"type": "select",
"id": "picker_type",
"label": "t:product_block.variant_picker.settings.picker_type.label",
"options": [
{
"value": "button",
"label": "t:product_block.variant_picker.settings.picker_type.options.button.label"
},
{
"value": "dropdown",
"label": "t:product_block.variant_picker.settings.picker_type.options.dropdown.label"
}
],
"default": "button"
},
{
"type": "checkbox",
"id": "color_swatches",
"label": "Enable color swatches",
"info": "Requires type to be set to 'Buttons'. [Learn how to set up swatches](https://archetypethemes.co/blogs/impulse/how-do-i-set-up-color-swatches)"
}
]
},
{
"type": "description",
"name": "t:product_block.description.name",
"limit": 1,
"settings": [
{
"type": "checkbox",
"id": "is_tab",
"label": "t:product_block.description.settings.is_tab.label"
}
]
},
{
"type": "buy_buttons",
"name": "t:product_block.buy_buttons.name",
"limit": 1,
"settings": [
{
"type": "checkbox",
"id": "show_dynamic_checkout",
"label": "t:product_block.buy_buttons.settings.show_dynamic_checkout.label",
"info": "t:product_block.buy_buttons.settings.show_dynamic_checkout.info",
"default": true
},
{
"type": "checkbox",
"id": "surface_pickup_enable",
"label": "t:product_block.buy_buttons.settings.surface_pickup_enable.label",
"info": "t:product_block.buy_buttons.settings.surface_pickup_enable.info",
"default": true
}
]
},
{
"type": "inventory_status",
"name": "t:product_block.inventory_status.name",
"limit": 1,
"settings": [
{
"type": "range",
"id": "inventory_threshold",
"label": "t:product_block.inventory_status.settings.inventory_threshold.label",
"default": 10,
"min": 0,
"max": 20,
"step": 2
},
{
"type": "checkbox",
"id": "inventory_transfers_enable",
"label": "t:product_block.inventory_status.settings.inventory_transfers_enable.label",
"info": "t:product_block.inventory_status.settings.inventory_transfers_enable.info",
"default": true
}
]
},
{
"type": "sales_point",
"name": "t:product_block.sales_point.name",
"settings": [
{
"type": "select",
"id": "icon",
"label": "t:product_block.sales_point.settings.icon.label",
"default": "globe",
"options": [
{
"value": "checkmark",
"label": "t:product_block.sales_point.settings.icon.options.checkmark.label"
},
{
"value": "gift",
"label": "t:product_block.sales_point.settings.icon.options.gift.label"
},
{
"value": "globe",
"label": "t:product_block.sales_point.settings.icon.options.globe.label"
},
{
"value": "heart",
"label": "t:product_block.sales_point.settings.icon.options.heart.label"
},
{
"value": "leaf",
"label": "t:product_block.sales_point.settings.icon.options.leaf.label"
},
{
"value": "lock",
"label": "t:product_block.sales_point.settings.icon.options.lock.label"
},
{
"value": "package",
"label": "t:product_block.sales_point.settings.icon.options.package.label"
},
{
"value": "phone",
"label": "t:product_block.sales_point.settings.icon.options.phone.label"
},
{
"value": "ribbon",
"label": "t:product_block.sales_point.settings.icon.options.ribbon.label"
},
{
"value": "shield",
"label": "t:product_block.sales_point.settings.icon.options.shield.label"
},
{
"value": "tag",
"label": "t:product_block.sales_point.settings.icon.options.tag.label"
},
{
"value": "truck",
"label": "t:product_block.sales_point.settings.icon.options.truck.label"
}
]
},
{
"type": "text",
"id": "text",
"label": "t:product_block.sales_point.settings.text.label",
"default": "Free worldwide shipping"
}
]
},
{
"type": "text",
"name": "t:product_block.text.name",
"settings": [
{
"type": "text",
"id": "text",
"default": "Text block",
"label": "t:product_block.text.settings.text.label"
}
]
},
{
"type": "trust_badge",
"name": "t:product_block.trust_badge.name",
"settings": [
{
"type": "image_picker",
"id": "trust_image",
"label": "t:product_block.trust_badge.settings.trust_image.label"
}
]
},
{
"type": "tab",
"name": "t:product_block.tab.name",
"settings": [
{
"type": "text",
"id": "title",
"label": "t:product_block.tab.settings.title.label",
"default": "Shipping information"
},
{
"type": "richtext",
"id": "content",
"label": "t:product_block.tab.settings.content.label",
"default": "<p>Use collapsible tabs for more detailed information that will help customers make a purchasing decision.</p><p>Ex: Shipping and return policies, size guides, and other common questions.</p>"
},
{
"type": "page",
"id": "page",
"label": "t:product_block.tab.settings.page.label"
}
]
},
{
"type": "share",
"name": "t:product_block.share_on_social.name",
"limit": 1,
"settings": [
{
"type": "paragraph",
"content": "t:product_block.share_on_social.settings.content"
}
]
},
{
"type": "separator",
"name": "t:product_block.separator.name"
},
{
"type": "contact",
"name": "t:product_block.contact_form.name",
"limit": 1,
"settings": [
{
"type": "paragraph",
"content": "t:product_block.contact_form.settings.content"
},
{
"type": "text",
"id": "title",
"label": "t:product_block.contact_form.settings.title.label",
"default": "Ask a question"
},
{
"type": "checkbox",
"id": "phone",
"label": "t:product_block.contact_form.settings.phone.label"
}
]
},
{
"type": "custom",
"name": "t:product_block.html.name",
"settings": [
{
"type": "liquid",
"id": "code",
"label": "t:product_block.html.settings.code.label",
"default": "<h4>Custom code block</h4><p>Use this advanced section to add custom HTML, app scripts, or liquid.</p>",
"info": "t:product_block.html.settings.code.info"
}
]
}
]
}
{% endschema %}
Could you send the featured-product.liquid file here?
My mailID: deeksha@codezyng.com
can you please share with me this code?
Hey @DevoloperCZ - did you get it working? I am looking for a simple method also for a fabric shop and half meter quantity.
nice! That looks great! Would you mind telling me how you did it? Is it done like here in this thread or completely different? And is your stock going down by 0.5 or is just a display of 0.5 in frontend and in backend it is 1 x 0.5 meter?
Hey @akixam,
You can easily achieve this by using the app we built Measura: Sell by Weight & More. I have attached a few screenshots below to show what it looks like with the app. When customers enter a length and then adds to cart, the app automatically calculate the price.
You can also set settings like min/max length, and increment steps (e.g., 0.5m: so customers can only order in lengths such as 0.5m, 1m, 1.5m, 2m,...). The texts below the field can be optionally shown/hidden.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025