This document describes passing a custom price via the URL. This is an advanced pricing setup for special situations only, and you may need to modify it for your needs. Testing is highly recommended.

Passing a custom price via a URL parameter uses "tag" functionality -- tags are free-form labels with an optional integer value. Because tag values are integers instead of decimals, a special Javascript is used to convert an integer such as "1995" into a decimal of "19.95".

Steps

Step 1: Change the pricing type to "Custom Calculation".

Step 2: In the script field, enter the following example Javascript. This script converts an integer value such as a "1995" to a decimal value of "19.95".

  • if (tags['total'] > 100) {
      Math.floor(tags['total'] / 100) + '.' + (tags['total'] % 100);
    } else {
      0.00;
    }
    

Step 3: Pass the price via the URL by adding the following:

  • ?tags=total=1995
When integers are passed as URL parameters, they have a hard limit of 2000000 (2 million). If you try to pass an integer value of 2000001, the Classic platform will only parse a value of 2000000.

If you set pricing using a URL parameter and a JavaSscript script to make the integer value a decimal value, the JavaScript function divides the integer value by 100 in order to convert it to a decimal price. Any integer value greater than 2 million will parse incorrectly as $2000000.

Notes

  • Prices are defined per product. Prices are unit prices -- if a quantity is allowed then the final total would be quantity X multiplied by the amount passed in.
  • If you will have multiple products using this technique, and each product needs their own custom price, then use a tag name such as "product_a_total" and make the 3 relevant changes to that tag reference in the script.
  • If you are using a form POST instead of a URL, then you may pass the tag information in a hidden field: <input type="hidden" name="tags" value="total=1995" />
  • To pass non-USD price options, you need to pass two tags. For example:
    ?tags=total_usd=x,total_gbp=y

    And then use logic in the script to find out the currency that's being used, and set the prices based upon this:
    if (currency == 'GBP'){
      // Look at the total_gbp tag
    } else if (currency == 'USD') {
      // Look at the total_usd tag
    }