Last active
April 10, 2022 04:25
-
-
Save dylanjhunt/696e24b4a9b49f9290ee81aed419a2c9 to your computer and use it in GitHub Desktop.
Automatically add item to cart checkout.liquid Shopify - https://dylanjh.com/blogs/22-add-a-free-item-to-checkout-automatically-if-price-over-100-shopify
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
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |
| {% assign found_title = false %} | |
| {% for item in checkout.line_items %} | |
| {% if item.variant.id == 7387208286253 %} | |
| {% assign found_title = true %} | |
| {% endif %} | |
| {% endfor %} | |
| {% if checkout.subtotal_price > 10000 and found_title == false %} | |
| <script> | |
| $( document ).ready(function() { | |
| var variantId = 7387208286253; | |
| jQuery.post('/cart/add.js', { | |
| quantity: 1, | |
| id: variantId | |
| }); | |
| setTimeout( | |
| function() { | |
| window.location.reload(true); | |
| }, 1000); | |
| }); | |
| </script> | |
| {% endif %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment