How to add Earn Coins section to your Shopify theme?
If you want to add the earn coins section to your Shopify website but you have an older theme that does not support app blocks, you need to add the section by editing the code of your theme.
Follow the below steps for adding the earn coins section to your website:
Go to your Shopify admin page
Under Online Store, click on Themes and click on Edit Code in the options
Find the Snippets folder and click on Add a new snippet and write the name nectorcustom_earn_coins
Copy the below block of code and paste in the file you just created and click on Save
After that, find the file that has the code related to your product page, and paste the below line of code wherever appropriate based on where you want to display the section
Since each theme will have different files and structure, it is not possible to mention the exact file in which you have to put the below line of code. You need to find the appropriate file for your current theme and paste it in there.
Click on Save button
How to add the earn coins section on Shopify ?
Follow the below steps for adding the earn coins section to your website:
Go to your Shopify admin page
Under Online Store, click on Themes and click on Edit Code in the options
Find the Snippets folder and click on Add a new snippet and write the name nectorcustom_earn_coins
Copy the below block of code and paste in the file you just created and click on Save
{% assign nector_api_key = shop.metafields.nector.api_key %}
{% assign nector_entity_id = shop.metafields.nector.entity_id %}
{% assign nector_env = shop.metafields.nector.env %}
{% assign nector_platform_url = 'https://platform.nector.io' %}
{% assign nector_script_url = 'https://cdn.nector.io/nector-static/no-cache/reward-widget/mainloader.min.js' %}
{% if nector_env != 'production' %}
{% assign nector_platform_url = 'https://stageplatform.nector.io' %}
{% assign nector_script_url = 'https://cdn.nector.io/nector-static/no-cache/stagereward-widget/mainloader.min.js' %}
{% endif %}
{% if product.selected_or_first_available_variant and product.selected_or_first_available_variant.price %}
{% assign nector_current_product_price = product.selected_or_first_available_variant.price
| default: 0
| divided_by: 100
%}
{% else %}
{% assign nector_current_product_price = product.price | default: 0 | divided_by: 100 %}
{% endif %}
{% if redirect_url %}
{% assign nector_redirect_url = redirect_url %}
{% endif %}
{% if shorter_text %}
{% assign nector_shorter_text = shorter_text %}
{% endif %}
<script
async
src="{{nector_script_url}}"
data-op="customerearn"
data-platform_url="{{nector_platform_url}}"
data-api_key="{{nector_api_key}}"
data-platform="shopify"
data-customer_id="{{ customer.id }}"
{% if nector_redirect_url %}
data-redirect_url="{{ nector_redirect_url }}"
{% endif %}
{% if nector_shorter_text %}
data-shorter_text="{{ nector_shorter_text }}"
{% endif %}
data-price="{{ nector_current_product_price }}"
></script>
<script id="nector-product-variants-data" type="application/json">
{{ product.variants | json }}
</script>
After that, find the file that has the code related to your product page, and paste the below line of code wherever appropriate based on where you want to display the section
Since each theme will have different files and structure, it is not possible to mention the exact file in which you have to put the below line of code. You need to find the appropriate file for your current theme and paste it in there.
{% render 'nectorcustom_earn_coins', shop: shop, customer: customer, product: product %}
Click on Save button
After adding the above line of code, the earn coins section will be visible on your product page
Related Articles
How to add the earn coins section on Shopify ?
Updated on: 21/05/2024
Thank you!