Custom Pricing via URL Parameter

Overview

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

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
    }
    
    
Have more questions? Submit a request

Comments

Powered by Zendesk