Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html class="{{ checkout_html_classes }}">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, height=device-height, minimum-scale=1.0, user-scalable=0">
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
- <!-- Get Discount Based on Amount Spent -->
- {% if checkout.total_price >= 10000 and checkout.total_price < 15000 %}
- {% assign discount_title = "H15" %}
- {% elsif checkout.total_price >= 15000 and checkout.total_price < 30000 %}
- {% assign discount_title = "H25" %}
- {% elsif checkout.total_price >= 30000 %}
- {% assign discount_title = "H60" %}
- {% endif %}
- <!-- Apply Discount Code and Submit the form -->
- {% if checkout.total_price > 10000 %}
- <script type="text/javascript">
- jQuery(document).ready(function($) {
- var $discountCode = $('input#checkout_discount_code'),
- calculatedCode = '{{ discount_title }}',
- appliedCode = $('span.applied-discount__code').text(),
- checkoutTotal = '{{ checkout.total_price }}';
- if(document.cookie.search(/no_auto_discount=true/) === -1){
- // If Discount Field is filled
- if ( appliedCode != '' ) {
- // If the Calculated Code is the right Code
- if ( appliedCode === calculatedCode ) {
- console.log('All good! Calculated Code matches Applied Code');
- } else {
- console.log('Erase old code, add in new code!')
- // Clear (2nd form to clear)
- $("#discount").find('form:nth-child(2)').submit();
- }
- } else {
- console.log('More than a $100 spent, check for code and form submit');
- // Calculate Discount Code
- $discountCode.val("{{ discount_title }}");
- // Submit (1st form to add)
- $("#discount").find('form:nth-child(1)').submit();
- }
- }
- $('.discount-delete').on('click', function(){
- document.cookie = "no_auto_discount=true";
- });
- });
- </script>
- {% endif %}
- <title>{{ shop.name }} - {{ page_title }}</title>
- {{ content_for_header }}
- {{ checkout_stylesheets }}
- {{ checkout_scripts }}
- </head>
- <body>
- {{ content_for_banner }}
- {{ content_for_layout }}
- {{ content_for_footer }}
- {{ tracking_code }}
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement