{"id":67562,"date":"2016-03-30T03:52:18","date_gmt":"2016-03-30T07:52:18","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=67562"},"modified":"2016-04-14T03:05:03","modified_gmt":"2016-04-14T07:05:03","slug":"shopify-how-to-add-product-quantities-to-the-products-pages","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/shopify-how-to-add-product-quantities-to-the-products-pages.html","title":{"rendered":"Shopify. How to add product quantities to the products pages"},"content":{"rendered":"<p>This tutorial shows how to add product quantities to the products pages in Shopify.<\/p>\r\n\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=RbtC6Nqf31s?width=1280&amp;height=720\" rel=\"prettyPhoto\">Shopify. How to add product quantities to the products pages<\/a>\r\n<p>By default, quantity box is not included to the product page. Thus, the one can be placed manually via files. <\/p>\r\n<p>Open admin panel of the website and navigate to <strong>Online Store &gt; Themes&gt;  &#8216;&#8230;&#8217; button&gt; Edit HTML\/CSS<\/strong>. Search for the <strong>&#8216;product.liquid&#8217; file<\/strong>, located  under &#8216;Templates&#8217; section. You can use the search option available on top. Open this file to edit: <\/p>\r\n\r\n<a href=\"\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_1.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_1-300x148.jpg\" alt=\"Shopify_How_to_add_product_quantities_to_the_products_pages_1\" width=\"300\" height=\"148\" class=\"aligncenter size-medium wp-image-67565\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_1-300x148.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_1-150x74.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_1.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n<p><strong>Note: <\/strong>make a copy of the original file before editing, so that it can be used to restore product page in case required.<\/p>\r\n<ol>\r\n  <li>\r\n  <p>Check the product.liquid file and <strong>search for the area to show quantity at<\/strong>. This can be any section of the product page.<\/p><\/li>\r\n  <li>\r\n  <p>Let&#8217;s place the one above Type and Vendor, in the <strong>product details section<\/strong>. Find the line for it: <\/p>\r\n  <pre>&lt;div class=\"product_details\"&gt;<\/pre>\r\n  <\/li>\r\n  <li>\r\n    <p>The following lines should be placed below the div class mentioned. Once they are added, their alignment can be updated for easier code comprehension (that&#8217;s optional):<\/p>\r\n  <pre class=\"brush:html\">\r\n&lt;div id=\"variant-inventory\"&gt;\r\n{% if product.variants.first.inventory_management == \"shopify\" and product.variants.first.inventory_quantity > 0 %}\r\nWe currently have {{ product.variants.first.inventory_quantity }} in stock.\r\n{% endif %}\r\n&lt;\/div&gt;\r\n<\/pre>\r\n\r\n<a href=\"\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_2.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_2-300x134.jpg\" alt=\"Shopify_How_to_add_product_quantities_to_the_products_pages_2\" width=\"300\" height=\"134\" class=\"aligncenter size-medium wp-image-67567\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_2-300x134.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_2-150x67.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_2.jpg 855w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n<\/li>\r\n  <li><p>Next, find the <strong>selectCallback<\/strong>&nbsp;function in the same product.liquid\u00a0 file. Find  this piece of code:<\/p>\r\n  <pre class=\"brush:js\">var selectCallback = function(variant, selector) {<\/pre>\r\n  <p class=\"attention\">Note: if your theme doesn&#8217;t have it, <a href=\"https:\/\/docs.shopify.com\/themes\/customization\/products\/use-products-with-multiple-options\" target=\"_blank\">follow the corresponding steps to create one<\/a>.<\/p><\/li>\r\n  <li><p>New code should be placed right after the value of <strong>selectCallback<\/strong> variable. Copy-paste the following code to the file:<\/p>\r\n  <pre class=\"brush:js\">\r\n  if (variant) {\r\n  if (variant.inventory_management == \"shopify\" && variant.inventory_policy != \"continue\") {\r\n    if (variant.inventory_quantity > 0) {\r\n      jQuery('#variant-inventory').text('We have ' + variant.inventory_quantity + ' in stock.');\r\n    } else {\r\n      jQuery('#variant-inventory').text(\"This product is sold out\");\r\n    }\r\n  } else {\r\n    jQuery('#variant-inventory').text(\"This product is available\");\r\n  }\r\n} else {\r\n    jQuery('#variant-inventory').text(\"\");\r\n}<\/pre>\r\n\r\n<a href=\"\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_3.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_3-300x137.jpg\" alt=\"Shopify_How_to_add_product_quantities_to_the_products_pages_3\" width=\"300\" height=\"137\" class=\"aligncenter size-medium wp-image-67566\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_3-300x137.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_3-150x68.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Shopify_How_to_add_product_quantities_to_the_products_pages_3.jpg 976w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n  <\/li>\r\n<\/ol>\r\n\r\n<p>Save changes applied to the product.liquid file and get back to the products page to check results. Code has been applied respectively. Product quantity is displayed in the required section.<\/p>\r\n\r\n<p>Feel free to check the detailed video tutorial below:<\/p>\r\n\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=RbtC6Nqf31s?width=1280&amp;height=720\" rel=\"prettyPhoto\">Shopify. How to add product quantities to the products pages<\/a>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to add product quantities to the products pages in Shopify.<\/p>\n","protected":false},"author":66,"featured_media":67570,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1771],"tags":[572,542,1795,2419],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/67562"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/66"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=67562"}],"version-history":[{"count":0,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/67562\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/67570"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=67562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=67562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=67562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}