Created
June 25, 2019 10:43
-
-
Save martinsoender/685430f12b772e84520154aa9e1d3966 to your computer and use it in GitHub Desktop.
Show Splitit instalments on Shopify checkout
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
| // Splitit sidebar | |
| if(location.href.indexOf('/checkouts/') >= 0) { | |
| // JQuery injection | |
| var ccJqueryScript = document.createElement('script'); | |
| ccJqueryScript.setAttribute('type', 'text/javascript'); | |
| ccJqueryScript.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'); | |
| document.getElementsByTagName('head')[0].appendChild(ccJqueryScript); | |
| // Checkout js injection | |
| var ccScript = document.createElement('script'); | |
| ccScript.setAttribute('type', 'text/javascript'); | |
| ccScript.setAttribute('src', '//cdn.shopify.com/s/files/1/0027/5536/2879/files/splitit-checkout.js?56957'); | |
| document.getElementsByTagName('head')[0].appendChild(ccScript); | |
| // Splitit styles injection | |
| const splititStyles = document.createElement('link'); | |
| splititStyles.setAttribute('rel', 'stylesheet'); | |
| splititStyles.setAttribute('src', '//cdn.shopify.com/s/files/1/0027/5536/2879/files/splitit-styles.css?56959'); | |
| document.getElementsByTagName('head')[0].appendChild(splititStyles); | |
| } | |
| // Splitit learn more | |
| var learn_more_data = '<div class="learn-more-wrapper"><div class="learn-more-inner"><a href="javascript:void(0);" class="close_learn_more"><img src="https://cdn.shopify.com/s/files/1/0985/6204/files/cancel.svg?4079804129806697275" class="img-responsive" /></a><img src="https://cdn.shopify.com/s/files/1/0027/5536/2879/files/splitit-learn_more-en_us.png?56958" class="img-responsive" /></div></div>'; | |
| $('.edit_checkout').append(learn_more_data); | |
| var learn_more = 'Learn More'; | |
| if ($('[data-select-gateway="30122437"]').length > 0) { | |
| $('label[for="checkout_payment_gateway_30122437"]').append('<a href="javascript:void(0)" class="learn-more">' + learn_more + '</a>'); | |
| $('label[for="checkout_payment_gateway_30122437"] .offsite-payment-gateway-logo').attr('src', 'https://cdn.shopify.com/s/files/1/1477/0490/files/logo.svg?18104013711271438358'); | |
| } | |
| $('.learn-more').on('click', function() { | |
| $('.learn-more-wrapper').toggleClass('active'); | |
| }); | |
| $('.close_learn_more').on('click', function() { | |
| $('.learn-more-wrapper').toggleClass('active'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment