What are smart labels?
Smart labels is a way for you to display automated messages. For instance, if you want to display a messages based on a calculation of the cart subtotal and how much more they would have to spend before reaching your $100,- free shipping limit. For this calculation you would need to display “$100 – cart_subtotal”.
Available smart labels
WooCommerce Advanced Messages supports a variety of smart labels by default.
Cart subtotal
Use the following code to display the cart subtotal in a message
{subtotal} {subtotal_ex_tax} {subtotal_minus_discounts} {subtotal_ex_tax_minus_discounts}
Cart quantity
Number of products in the cart
{cart_quantity}
Time
Display the current time, formatted according your WordPress settings
{time}
Date
Display the current date, it will be formatted according your WordPress settings
{date}
Advanced Date
The {date} label also allows for more flexible settings such as ‘format’ and ‘date’.
{date format="d-m-Y"} {date date="+5 weekdays"} {date date="next monday" format="Y/m/d"}
For all format possibilities, take a look at the documentation here: https://codex.wordpress.org/Formatting_Date_and_Time
Today
Display todays name, e.g. if its Monday, it will display ‘Monday’
{day}
Tomorrow
Display tomorrow’s name, e.g. if its Monday, it will display ‘Tuesday’
{tomorrow}
Day after tomorrow
Display the day name of the day after tomorrow, e.g. if its monday, it will display ‘Wednesday’
{day_after_tomorrow}
Applied coupons
This shows all the applied coupons in a comma separated list
{applied_coupons}
Even smarter stuff
Those smart labels are nice huh!? But you can do even cooler stuff!
Calculations
You can some nice calculations within the message too! As a basic example, this will display ’50’;
[100-50]
You can do also a bit more complicated stuff like calculating the remaining amount;
[100 - {subtotal}]
Format your messages
When calculating something, you might want it formatted. You can use the following to price format stuff in your messages;
{price_format amount='100'} OR {price_format amount='[100-{subtotal}]'}
Time calculations
If you want to display a automated text like ‘Order within 12 hours and 18 minutes’ you can use one of the following examples
Time left
To display the time left there are a couple of possibilities. This will display the time left before 20:00
{time_left time='20:00'} OR {time_left time='8:00PM'}
Time left till date
You can do the same for the time left till a date
{time_left date='25-12-2018'}
Time left till date + time
Its of course also possible to set a day and time
{time_left date='24-12-2018' time='20:00'}
Or even more advanced
You can also turn it up a notch, for instance try this to calculate the time left till tomorrow 20:00;
{time_left time='+1 day 20:00'}
Product labels
The following labels are available on product pages only:
Product weight
Displays the product weight (without weight unit)
{product_weight}
Product stock
Display the product stock quantity
{product_stock}
Product price(s)
Display the product prices
{price} // Actual product price {regular_price} // Regular price {sale_price} // Sale price {discount} // Discount amount {percentage} // Discount percentage
Something missing?
If there is something missing I would like to hear about it! Feature requests can be done via the support contact form, please mention the plugin name and explain what you would like to see with a general use case. That way I will be able to judge if this would be something that could be implemented in the core plugin.
Add Your Own Custom Smart Labels
You can also consider adding your own custom Smart Labels. Using the Adding a Custom Smart Label documentation page you can learn how this can be done.