Skip to content

Instantly share code, notes, and snippets.

@lucdkny
Forked from cvieth/Shopify-Checkout-Hack.js
Created March 1, 2018 17:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucdkny/a2a2c75d00e8e8ea66041e3e064c41f9 to your computer and use it in GitHub Desktop.
Save lucdkny/a2a2c75d00e8e8ea66041e3e064c41f9 to your computer and use it in GitHub Desktop.
Shopify Checkout Hack - This scipt helps to modify the Shopify Checkout Pages
/**
* Shopify Checkout Hack
*
* This scipt helps to modify the Shopify Checkout Pages. To run this script, add your
* code for each checkout step, compress your code with a tool of your choice and paste
* it to:
*
* Admin > General > Google Analytics > Additional Google Analytics Javascript
*
* @author Christoph Vieth <christoph@vieth.me>
* @copyright Copyright (c) 2015 - Christoph Vieth <christoph@vieth.me>
* @license MIT License http://opensource.org/licenses/MIT
* @url http://www.falkens-laboratory.de/2015/01/shopify-checkout-hack.html
*/
(function() {
var checkReady = function(callback) {
if (window.jQuery) {
callback(jQuery);
} else {
window.setTimeout(function() {
checkReady(callback);
}, 100);
}
};
var runCode = function($) {
var checkoutPage = $('#checkout');
if (checkoutPage.length > 0) {
if (checkoutPage.hasClass(
'current-step-contact_information')) {
/**
* Contact Information Step
*/
/* Add Code here */
} else if (checkoutPage.hasClass(
'current-step-shipping_and_payment_method')) {
/**
* Shipping and Payment Step
*/
/* Add Code here */
} else if (checkoutPage.hasClass('current-step-review')) {
/**
* Review Page Step
*/
/* Add Code here */
}
}
};
if (typeof jQuery == "undefined") {
var script = document.createElement("SCRIPT");
script.src =
'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName("head")[0].appendChild(script);
checkReady(function($) {
runCode($);
});
} else {
runCode(jQuery);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment