Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.63 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html class="{{ checkout_html_classes }}">
  3.   <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0, height=device-height, minimum-scale=1.0, user-scalable=0">
  7.    
  8.     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  9.    
  10.     <!-- Get Discount Based on Amount Spent -->
  11.     {% if checkout.total_price >= 10000 and checkout.total_price < 15000 %}
  12.      {% assign discount_title = "H15" %}
  13.    {% elsif checkout.total_price >= 15000 and checkout.total_price < 30000 %}
  14.      {% assign discount_title = "H25" %}
  15.    {% elsif checkout.total_price >= 30000 %}
  16.       {% assign discount_title = "H60" %}
  17.     {% endif %}
  18.    
  19.  
  20.     <!-- Apply Discount Code and Submit the form -->
  21.     {% if checkout.total_price > 10000 %}
  22.     <script type="text/javascript">
  23.       jQuery(document).ready(function($) {
  24.  
  25.         var $discountCode = $('input#checkout_discount_code'),
  26.             calculatedCode = '{{ discount_title }}',
  27.             appliedCode = $('span.applied-discount__code').text(),
  28.             checkoutTotal = '{{ checkout.total_price }}';
  29.  
  30.         if(document.cookie.search(/no_auto_discount=true/) === -1){
  31.           // If Discount Field is filled
  32.           if ( appliedCode != '' ) {
  33.             // If the Calculated Code is the right Code
  34.             if ( appliedCode === calculatedCode ) {
  35.               console.log('All good! Calculated Code matches Applied Code');
  36.             } else {
  37.               console.log('Erase old code, add in new code!')
  38.               // Clear (2nd form to clear)
  39.               $("#discount").find('form:nth-child(2)').submit();
  40.             }
  41.           } else {
  42.               console.log('More than a $100 spent, check for code and form submit');
  43.               // Calculate Discount Code
  44.               $discountCode.val("{{ discount_title }}");
  45.               // Submit (1st form to add)
  46.               $("#discount").find('form:nth-child(1)').submit();
  47.           }
  48.         }
  49.         $('.discount-delete').on('click', function(){
  50.           document.cookie = "no_auto_discount=true";
  51.         });
  52.  
  53.       });
  54.     </script>
  55.     {% endif %}
  56.  
  57.     <title>{{ shop.name }} - {{ page_title }}</title>
  58.  
  59.     {{ content_for_header }}
  60.  
  61.     {{ checkout_stylesheets }}
  62.     {{ checkout_scripts }}
  63.  
  64.   </head>
  65.   <body>
  66.  
  67.     {{ content_for_banner }}
  68.     {{ content_for_layout }}
  69.     {{ content_for_footer }}
  70.  
  71.     {{ tracking_code }}
  72.  
  73.   </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement