Trying to add product if cart hits certain amount

Dimwo
New Member
7 0 0

Pretty much what the title says. My first time trying to set this up, not receiving the response, wondering what I'm doing wrong here. The code is inside the checkout.liquid file. Code is below 

 

 

<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 == 6564672929928 %}
        {% assign found_title = true %}
      {% endif %}
    {% endfor %}

    {% if checkout.subtotal_price > 50000 and found_title == false %}
    <script>
      $( document ).ready(function () {
        variantId = 6564672929928
        jQuery.post('/cart/add.js', {
          items: [{
            quantity: 1,
            id: 6564672929928            
          }],
          function(res){
            console.log(res)
          }
        })
      })
    </script>

 

0 Likes