Variables in the rules
In formula type fields, you can use any value from the product sheet field by indicating its name surrounded by braces {}. example {wholesale_price}, {wheigt}, {fixed_price} etc….
NB, if you want to use a "characteristic" from the product sheet, you must first check that this characteristic is correctly selected in the characteristics to be exported (see the main configuration screen of SmartPrice)
Example of mixed formula, formula and field:
We want to create a maximum price rule that would correspond to twice the price of the website excluding tax. We must therefore create a maximum price limit rule, choose the “value” method and formulate the price field multiplied by 2: {price} * 2
We also have internal variables in SmartPrice:
{rule.cost} = Result of the product purchase cost type rule applied to the offer
{rule.cost_shipping} = Result of the shipping cost type rule applied to the offer
{rule.additional_cost} = Result of the additional cost rule applied to the offer
{rule.tax_rate = Value of the TAX type rule applied to the offer in%. (will not give the result of the rule but the percentage applied. for example for a VAT rule of 20% the variable will result in 20.)
{rule.margin} = Value of the minimum margin type rule applied to the offer in%.
{rule.commission} = Value in the commission type rule applied to the offer in%.
{rule.final_price} = Target price calculated by SmartPrice, after possible deduction of the “Shipping costs” rule
Example of formula with internal SmartPrice variables:
We want to create a maximum price rule that would correspond to 2 times the price of the website including VAT. We must therefore create a maximum price limit rule, fall under the “value” method and formulate the price field in inclusive of VAT multiplied by 2. The value of the Prestashop “Price” field is generally exclusive of tax, therefore it must be converted into TTC. If we have a fixed VAT rate for all products and all distribution channels, we can then multiply the Price field by 1.20 if the VAT rate is 20% but we can also recover the VAT rate automatically according to tax rules configured and using the {rule.tax_rate} variable the formula will therefore be:
({price} * (1 + ({rule.tax_rate} / 100)) * 2)
Special formulas:
“If… then… else”
A particular formula exists to use a field from your product sheet, but if this field is empty, use another field or a value.
Examples:
For a purchase cost rule, we want to use the wholesale_price field but if this field is not filled in, use a default value of 10. We will therefore use a formula:
if {wholesale_price} then {wholesale_price} else 10.
For a purchase cost rule, we want to use the wholesale_price field but if this field is not filled in, use the website price divided by 2. We will therefore use a formula:
if {wholesale_price} then {wholesale_price} else ({price} / 2).