-
-
Save lucdkny/a2a2c75d00e8e8ea66041e3e064c41f9 to your computer and use it in GitHub Desktop.
Shopify Checkout Hack - This scipt helps to modify the Shopify Checkout Pages
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
/** | |
* 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 <[email protected]> | |
* @copyright Copyright (c) 2015 - Christoph Vieth <[email protected]> | |
* @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