How to add BCPO to a product on your homepage (featured-product.liquid)

Go to Online Store > Actions > Edit Code
Open your featured-product.liquid or home-product.liquid file in the Sections area.
If you have the theme called Fastlane, then open your product.liquid file in the Sections area instead.

Paste this code after the place where product is defined.
See attached screenshot for the correct placement.

{% if product != empty %}
var bcpo_product = {{product | json}};
{% if all_products[product.handle].metafields.bcpo.bcpo_data %}
var bcpo_data = {{all_products[product.handle].metafields.bcpo.bcpo_data}};
var inventory_quantity = [];{% for v in product.variants %}inventory_quantity.push({{v.inventory_quantity}});{% endfor %}
if(bcpo_product) { for (var i = 0; i < bcpo_product.variants.length; i += 1) { bcpo_product.variants[i].inventory_quantity = inventory_quantity[i]; }}
{% endif %}
{% endif %}

Our app only supports one featured product
Was this article helpful?

Pin It on Pinterest