Samples of Custom Code for Shopify Cart

Samples of Custom Code for Shopify Cart

​ {% assign Partially = false %}
       {% for line_item in cart.items %}

       {% if line_item.product.tags contains 'PRODUCT_TAG' %}
       {% assign Partially = true %}
       {% endif %}
       {% endfor %}
​
       {% if Partially %}
​
[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]
​
{% endif %}

 {% assign Partially = false %}
       {% for line_item in cart.items %}

       {% if line_item.product.tags contains 'TAG1' %}
       {% assign Partially = 'OFFER1' %}

  {% elsif line_item.product.tags contains 'TAG2' %}
       {% assign Partially = 'OFFER2' %}

  {% elsif line_item.product.tags contains 'TAG3' %}
       {% assign Partially = 'OFFER3' %}

       {% endif %}
       {% endfor %}

       {% if Partially %}
       
[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]

{% endif %}

*You must replace the offer line within the Partial.ly script with:

 offer: '{{Partially}}',

{% assign Partially = false %}
       {% for line_item in cart.items %}

       {% if line_item.product.tags contains 'TAG1' %}
       {% assign Partially = 'OFFER1' %}

  {% elsif line_item.product.tags contains 'TAG2' %}
       {% assign Partially = 'OFFER2' %}

  {% else %}
        {% assign Partially = 'OFFER-FOR-EVERYTHING-ELSE' %}   

       {% endif %}
       {% endfor %}

       {% if Partially %}

[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]

{% endif %}

        

*You must replace the offer line within the Partial.ly script with:

 offer: '{{Partially}}',

{% assign Partially = false %}
        {% for line_item in cart.items %}
        
{% if line_item.product.tags contains 'PRODUCT-TAG' %}
        {% assign Partially = true %}
        {% endif %}
        {% endfor %}

         {% unless Partially %}

[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]

{% endunless %}

{% if cart.total_price > 10000 %}

[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]

{% endif %}

{% if cart.total_price >= 50000 and cart.total_price 

{% assign Partially = false %}
       {% for line_item in cart.items %}

       {% if cart.total_price >= 100 and cart.total_price = 40000 and cart.total_price = 100000 %}
       {% assign Partially = 'Offer3ID' %}

       {% endif %}
       {% endfor %}

       {% if Partially %}

       [PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]
          
{% endif %}

*You must replace the offer line within the Partial.ly script with:

 offer: '{{Partially}}',

{% assign Partially = false %}
        {% for line_item in cart.items %}
        
        {% if line_item.product.id == PRODUCT-ID-1 %}
        {% assign Partially = 'OFFER-ID-1' %}
  
 		{% elsif line_item.product.id == PRODUCT-ID-2 %}
        {% assign Partially = 'OFFER-ID-2' %}
  
        {% endif %}
        {% endfor %}

         {% if Partially %}

[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]

{% endif %}

*You must replace the offer line within the Partial.ly script with:

 offer: '{{Partially}}',

{% assign Partially = false %}
        {% for line_item in cart.items %}
        
        {% if line_item.variant.id == VARIANT-ID-1 %}
        {% assign Partially = 'OFFER-ID-1' %}
  
 		{% elsif line_item.variant.id == VARIANT-ID-2 %}
        {% assign Partially = 'OFFER-ID-2' %}
  
        {% endif %}
        {% endfor %}

         {% if Partially %}

[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]

{% endif %}


*You must replace the offer line within the Partial.ly script with:

 offer: '{{Partially}}',

 {% assign Partially = false %}
       {% for line_item in cart.items %}

       {% if line_item.product.tags contains 'TAG' %}
       {% assign Partially = true %}
       {% endif %}
       {% endfor %}

       {% if Partially %}
​
<div id="partiallyCartButtonContainer"></div>
<script>
document.partiallyButtonConfig = {

    {% if cart.total_price < 150001  %}
     offer: 'OFFER_ID',
    {% else %}
  offer: 'OFFER_ID',
    {% endif %}

     returnUrl: '{{shop.url}}/cart',
     returnConfirmedUrl: '{{shop.url}}/cart/clear',

     cssButton: true,
     cssButtonText: 'Purchase with',

     cssButtonShowLogo: true,
     cssButtonLogoType: 'full',
     cssButtonLogoPlacement: 'after',

     renderSelector: '#partiallyCartButtonContainer',

    baseUrl: 'https://demo.partial.ly',

    shopifyCart: {{cart | json}}
   };
   (function() {
     var script = document.createElement('script');
     script.type = 'text/javascript';
     script.src = 'https://partial.ly/js/partially-checkout-button.js';
     script.async = true;
     document.head.appendChild(script);
   })();
</script>

{% endif %} 

<div id="partiallyCartButtonContainer"></div>
<div id="partiallyCartButtonContainer2"></div>

<script src="https://partial.ly/js/partially-checkout-button.js"></script>
<script>
var basePartiallyConfig = {
     returnUrl: '{{shop.url}}/cart',
     returnConfirmedUrl: '{{shop.url}}/cart/clear',
     cssButton: true,
     cssButtonText: 'BUTTON-TEXT',
     cssButtonShowLogo: true,
     cssButtonLogoType: 'full',
     cssButtonLogoPlacement: 'before',
     cssButtonCustomBg: '#6623e9',
     renderSelector: '#partiallyCartButtonContainer',
    shopifyCart: {{cart | json}}
   };
   
// set the first offer and init button
basePartiallyConfig.offer = 'OFFER-ID-1';
var button1 = new PartiallyButton(basePartiallyConfig);
button1.init();

// set the second offer
basePartiallyConfig.offer = 'OFFER-ID-2';
basePartiallyConfig.renderSelector = '#partiallyCartButtonContainer2';
var button2 = new PartiallyButton(basePartiallyConfig);
button2.init();
</script>

<div id="partiallyCartButtonContainer"></div>
<script src="https://partial.ly/js/partially-checkout-button.js"></script>          
<script>
var basePartiallyConfig = {
     returnUrl: '{{shop.url}}/cart',
     returnConfirmedUrl: '{{shop.url}}/cart/clear',

     cssButton: true,
     cssButtonText: 'BUTTON-NAME-1',
     cssButtonShowLogo: true,
     cssButtonLogoType: 'full',
     cssButtonLogoPlacement: 'after',

     renderSelector: '#partiallyCartButtonContainer',
    shopifyCart: {{cart | json}}
   };
basePartiallyConfig.offer = 'OFFER-ID-1';
var button1 = new PartiallyButton(basePartiallyConfig);
button1.init();
</script>


<div id="partiallyCartButtonContainer2"></div>
<script src="https://partial.ly/js/partially-checkout-button.js"></script>           
<script>
var basePartiallyConfig = {
     returnUrl: '{{shop.url}}/cart',
     returnConfirmedUrl: '{{shop.url}}/cart/clear',

     cssButton: true,
     cssButtonText: 'BUTTON-NAME-2',
     cssButtonShowLogo: true,
     cssButtonLogoType: 'full',
     cssButtonLogoPlacement: 'after',

     renderSelector: '#partiallyCartButtonContainer2',
    shopifyCart: {{cart | json}}
   };
basePartiallyConfig.offer = 'OFFER-ID-2';
basePartiallyConfig.renderSelector = '#partiallyCartButtonContainer2';
var button2 = new PartiallyButton(basePartiallyConfig);
button2.init();
</script>

Contact our support team at support@partial.ly.

If you need code for your product pages, please see the following article: Samples of Custom Code for Shopify Product Pages