All things Shopify and commerce
For theme 2.0, you can use product/variant metafield as dynamic content.
We build an upsell function based on this feature. But it bounces back and forth between working and not working.
Here is the setting from the `product-template` section
...
{% schema %}
{
"name": "Product",
"class": "shopify-section--product-template has-sidebar-option",
"settings": [
{
"type": "header",
"content": "Upsell"
},
{
"type": "checkbox",
"label": "Show debug information for upsell",
"info": "Information does not show on the frontend",
"id": "show_upsell_debug",
"default": false
},
{
"type": "collection",
"id": "upsell_collection",
"label": "Upsell collection"
},
...
{% endschema %}
Here is some setting from `product.json`
{
"sections": {
"main": {
"type": "product-template",
...
"settings": {
"show_upsell_debug": false,
"upsell_collection": "{{ product.metafields.upsell.collection.value }}",
"upsell_add_button_text": "",
"upsell_product_heading": "Add a bulb for your {{ product.title }}",
"upsell_product_content": "<p>The {{ product.title }} does not come with a bulb, so we’ve put together our favourite options that are compatible with this product. If you’d like more options, click the button below to view our entire bulb collection. <\/p>{{ product.metafields.content.bulbs_info | metafield_tag }}",
"upsell_button_text": "",
"product_thumbs": true,
"gallery_arrows": true,
"enable_product_lightbox": true,
"activate_zoom": false,
...}},
"order": [
"main"]
}
In the `product-template` section, we try to detect the setting for upsell collection and render the JS.
{%- liquid
if section.settings.upsell_collection
render 'product-upsell-modal', section: section
endif
if section.settings.upsell_collection
echo 'yes'
else
echo 'no'
endif
echo product.metafields.upsell.collection
-%}
Sometime echo `no` but we can see the collection gid next to it.
Does any one know why and how to fix it?
Solved! Go to the solution
This is an accepted solution.
Issue found. The are multiple JSON templates, and the products are associated with different JSON template, some of the JSON template does not set the upsell collection. That caused the issue.
This is an accepted solution.
Issue found. The are multiple JSON templates, and the products are associated with different JSON template, some of the JSON template does not set the upsell collection. That caused the issue.
User | RANK |
---|---|
53 | |
48 | |
41 | |
28 | |
21 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023