Guest User

Untitled

a guest
Oct 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <script>
  2. AttributeMachine.prototype.Generate_Discount = function( discount )
  3. {
  4. var discount_div;
  5.  
  6. var msrp = Number(document.getElementById('price-value-additional').innerHTML.replace(/[\$,]/, '')),
  7. savings_percent = Math.round(discount.discount / msrp * 100),
  8. savings_percent_formatted = savings_percent + '%';
  9.  
  10. // console.log('Generate_Discount', discount, msrp, savings_percent, savings_percent_formatted );
  11.  
  12. discount_div = document.createElement( 'div' );
  13. discount_div.innerHTML = 'You Save: ' + savings_percent_formatted + '<br>' + discount.descrip + ': ' + discount.formatted_discount;
  14.  
  15. return discount_div;
  16. }
  17.  
  18. AttributeMachine.prototype.Generate_Swatch = function( product_code, attribute, option )
  19. {
  20. var swatch = document.createElement( 'li' );
  21. var span = document.createElement( 'span' ); // to vertically center the swatch images
  22. var img = document.createElement( 'img' );
  23. img.src = option.image;
  24.  
  25. swatch.appendChild( span );
  26. swatch.appendChild( img );
  27.  
  28. return swatch;
  29. }
  30. </script>
Add Comment
Please, Sign In to add comment