Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rklubenspies/68b69dfd0a31b1756302b325049563e0 to your computer and use it in GitHub Desktop.
Save rklubenspies/68b69dfd0a31b1756302b325049563e0 to your computer and use it in GitHub Desktop.
// AUTO-SELECT CLICKFUNNELS PRODUCT ON ORDER PAGE
// --
//
// AUTHOR: Robert Klubenspies (klubenspies.com)
//
// REQUIREMENTS: jQuery
//
// USAGE:
// 1) Find your product's ID numbers by using Web Inspector to find
// the code for your order page's radio buttons. They'll look
// something like the sample below, and have a ID number in the
// value field. You'll need to know which numbers correspond with
// which products.
//
// <input type="radio" name="purchase[product_id]" value=
// "595243" data-storage="false">
//
// 2) Add all of this code to your order page's custom JS/jQuery
//
// 3) Link to your order page using the following URL format when you
// need to auto-select a product, based on the ID numbers you
// determined earlier:
//
// https://order.example.com/order-form?product=PRODUCT_ID_NUMBER
//
// NOTES:
// * This is a hack. Always test it on your page before relying on it.
// * You might need to wrap this code in a $(function(){ }); jQuery
// function to get it to run on page load.
// Tool to read URL parameters (Credit: http://stackoverflow.com/a/25359264)
$.urlParam=function(n){var e=new RegExp("[?&]"+n+"=([^&#]*)").exec(window.location.href);return null==e?null:e[1]||0};
// Select the correct product's radio button using the product's id number
$('input:radio[name="purchase[product_id]"][value="' + $.urlParam('product') +'"]').prop('checked', true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment