Using Shopify Product Metafields in calculations

You have the ability to pass up to 5 Shopify product metafields to be used in calculations.

Before you will be able to get access to product metafields, you will need to create them in Shopify and configure them in Option Price Calculator Product App block.

How to Create Shopify Product Metafields #

https://help.shopify.com/en/manual/metafields

How to Configure Metafields in Option Price Calculator
#

JSON Templates #

Adding to Product Page Using Template Customizer

  1. Go to Online Store => Themes

  1. Click Customize on the theme you wan to add Option Price Calculator

  1. Open the product template you want to add Option Price Calculator

  1. Click the Option Price Calculator app block.

  1. Set up to 5 metafields. Click the dynamic source stack icon to select metafields configured on your product record.

    Although you can set any metafield, setting any field that does not contain a number or decimal will break your calculations if you use it

Manual Installed App #

1. Open the theme Code Editor.
Online Store -> Themes -> (Theme you want to install OPC) -> Actions -> Edit Code

2. Expand the “Snippets” folder in left navigation.

3. Click “opc-includes”.

4. Look for the following code (highlighted in red):

<product-options-section> 
<span class='product-id' id='{{product.id}}' 
price='{{product.selected_or_first_available_variant.price}}' compareprice='{{product.selected_or_first_available_variant.compare_at_price}}' isavailable='{{product.selected_or_first_available_variant.available}}' metadata01='{{ block.settings.metadata01 }}' 
metadata02='{{ block.settings.metadata02 }}' 
metadata03='{{ block.settings.metadata03 }}'  
metadata04='{{ block.settings.metadata04 }}' 
metadata05='{{ block.settings.metadata05 }}' 
style='display: none'>
</span>

  1. Replace {{ block.settings.metadata01 }} with the reference to a product metafield element you want to use in a calculation.

    Example: {{ product.metafields.custom.box_price }}

    You can get the reference to the metafield element from:
    Shopify Settings => Metafields => Products
  1. Save the opc-includes file.

Add metafields into your calculations. #

From an Option Set Calculation or formula field, select a product metadata calculation variable.