Skip to content

Instantly share code, notes, and snippets.

@cvieth
Last active May 20, 2023 09:51
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cvieth/d2a4ddedac9743ac5649 to your computer and use it in GitHub Desktop.
Save cvieth/d2a4ddedac9743ac5649 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);
}
})();
Copy link

ghost commented Nov 11, 2015

Can this be used to run scripts inside it? Or has the Class IDs changed? does not seem to work?

@mattmagi
Copy link

Yeah this no longer works :(

@0xlino
Copy link

0xlino commented Apr 23, 2018

Yes ^, shopify stopped this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment