Forked from rklubenspies/ClickFunnels_Auto_Select_Product_on_Order_Form.js
Created
May 19, 2017 16:38
-
-
Save KustomDeveloper/0c372d380c6a4a3402f261fed0384f7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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