Advertisement
orenchuck

soda change freeShipping Message

Mar 20th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <script>
  2. (function () {
  3. var FREE_SHIPPING_MESSAGE = 'Free Shipping unlocked';
  4. var FREE_SHIPPING_ICON = 'https://static.adoric.com/3db4186a-8e70-4e02-a7b7-68506303bf77.svg';
  5. var shippingText = document.querySelector('.mb-2 .no-shipping');
  6. var shippingIcon = document.querySelector('.mb-2 .no-shipping img');
  7. var productsInCart = document.querySelectorAll('div.col-7 [data-variant-id]');
  8. var whiteList = ['40513507622954', '40513507655722'];
  9. var quantityForFreeShiping = 0;
  10. productsInCart.forEach(function (product) {
  11. var isProductInTheCart = whiteList.some(function (item) {
  12. return item == product.getAttribute('data-variant-id');
  13. });
  14. if (isProductInTheCart) {
  15. var quantity = parseInt(product.getAttribute('data-qty'));
  16.  
  17. if (quantity) {
  18. quantityForFreeShiping += quantity;
  19. }
  20. }
  21. });
  22. if (quantityForFreeShiping >= 3 && shippingText && shippingIcon) {
  23.  
  24. shippingText.textContent = FREE_SHIPPING_MESSAGE;
  25. shippingIcon.src = FREE_SHIPPING_ICON;
  26. shippingText.insertAdjacentElement('afterbegin', shippingIcon);
  27. }
  28. })();
  29. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement