Dynamic Notice PRO


Adds a possibility to display some data like regular and non option variables values as well as perform virtually any operations with these data by using JS code.

Syntax

To display data use these tags: {{{ and }}}.

Example:

Width: {{{data.uni_cpo_width}}} cm

data JS object contains all the data available, so you have to put it before the actual name of a variable. Just like in the example above. If some variable simply does not exist (for instance, you made a typo) or just does not available at the moment (for instance, some NOV is not available before AJAX request for price calculation has been made), then nothing will be displayed. There will not be any errors too.

To use JS expressions put them in these tags: {# and #}.

{# if (typeof data.uni_cpo_width !=== 'undefined' && data.uni_cpo_width > 100) { print 'The width is too big!'; } #}

Data

  1. In Dynamic Notice you can display any regular or non option variable (please, note that NOVs are available only after the AJAX request for price calculation has been made)
  2. Also these variables:
    • price - a nicely formatted calculated product price
    • raw_price - price to be used in JS expressions
    • price_suffix - a nicely formatted price with taxes1
    • raw_price_tax_rev - price with taxes to be used in JS expressions1
    • currency - currency symbol
    • currency_code - currency code
    • raw_price_discounted - raw price discounted;
    • price_discounted - price discounted
    • quantity - value from WC quantity field
    • total - a nicely formatted total (price multiplied by WC quantity field)
    • raw_total - total value to be used in JS expressions
    • raw_total_tax_rev - total with taxes to be used in JS expressions1
    • total_suffix - a nicely formatted total with taxes1

Some more use cases

If you have your own qty Option and would like to calculate total based on this Option's value:

{{{ parseFloat(data.uni_cpo_qty*data.raw_price).toFixed(2) }}}

This piece of code uses two JS functions: parseFloat() and toFixed(). You have to be familiar with JS and their functions prior using them in Dynamic Notice.

Another example. Basically, it does the same, but allows to bind our total value to JS variable and then re use it everywhere. This is our variable creation:

{# var myTotal = parseFloat(data.uni_cpo_qty*data.raw_price); #}

Now let's use it this and there:

{{{ myTotal.toFixed(2) }}} or {{{ myTotal.toFixed(0) }}} (this code makes a whole number)

1. This values will be set according to settings chosen in WooCommerce on Tax tab; so, this values may include or exclude taxes, actually; also, the product must be set to Taxable;

results matching ""

    No results matching ""