Advanced price and sale price calculation
The advanced price modification present a powerful way to derive prices of the products in the feed, taking inputs from Shopify product price, compare at price, product and variant metafields in math expressions.
By default, the price and sale price in the feed are composed by the following rules:
- Feed Price: If compare at price is greater than price, use it, otherwise use the price.
- Feed Sale price: If compare at price is greater than price, use the price as sale price, otherwise not set.
These rules ensure the correct alignment of the prices in feed with how Shopify compare at price works.
Note the empty string ("") indicate that the sale price will be empty if the variant does not have a compare at price or the compare at price is not greater than price (to avoid some edge cases when the compare at price is presented, but not greater than the price, hence invalid).
The default rules work for most of the cases. However there are some common cases that require custom price calculations:
- Tax/shipping inclusion. In the following example, a VAT rate of 21% and fix shipping cost of $10 are added to the price
- Ignore compare at price (skip submitting a separate sale price field). This ensure that you always submit the lower prices, e.g. the target market place does not support displaying sale price
- Taking prices from product metafield
The use of
default function will make sure that the feed price will fallback to variant price if the metafield my_fields.price_uah is not available.
With both the rules and the expressions in place, you can be as creative as you want to with the price calculation.