Hello everybody!
We have a private online store for our managers. They requested a feature where they can see cost per unit, this means, divide the price into units according to a metafield with # of products inside a case, package, etc. Then display this results inside website and packing slip.
I know there is an app but we want our “# of items” custom field to be inside the product page itself, no external app or page.
Thank you!
What you will probably want to do is add some custom liquid to your product page template that gets the product price and divides it by the custom “# of items” metafield and then displays the value. Something like the code below can be placed in your product.liquid template. Make sure to replace the metafield_keyspace and metafield_name with you metafield data. You’ll also need to make sure your metafield is stored as an Integer or Decimal.
{% assign metafield_keyspace = "custom_fields" %}
{% assign metafield_name = "NUMBER_IN_PACKAGE" %}
{% if product.metafields[metafield_keyspace][metafield_name] %}
{% assign number_in_package = product.metafields[metafield_keyspace][metafield_name] %}
{% if number_in_package > 0 %}
{% assign product_price = product.price | divided_by: 100.0 %}
{% assign cost_per_unit = product_price | divided_by: number_in_package %}
Cost per unit: {{ cost_per_unit | money }}
{% else %}
Number in package is not valid.
{% endif %}
{% else %}
Number in package is not set.
{% endif %}
What are you using for your packing slip?
Thank you very much.
We have a warehouse with all the boxes and we deliver to our own stores. Every order we receive online from our store managers are printed as packing slip and then we deliver.