Partial.ly
Back to home

Samples of Custom Code for Shopify Cart

Samples of Custom Code for Shopify Cart

With some custom coding, you can limit Partially on your Shopify store. Below are examples of various scripts to customize the Partial.ly button on your cart page.

Limit by Product Tags

1. Limit cart page button to product tag:

{% 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 %}

2. Limit cart page button to multiple offers and product tags:

{% 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}}',

3. Limit some products to specific offers, all other products use a different offer:

{% 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}}',

4. Make product tag ineligible for Partial.ly:

{% 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 %}

Limit by Price Range

1. Only allow purchases above a certain amount:

{% if cart.total_price > 10000 %}
[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]
{% endif %}

2. Limit all cart purchases to a specific price range:

{% if cart.total_price >= 50000 and cart.total_price <= 180000 %}
[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]
{% endif %}

3. Limit multiple offers to multiple price ranges on cart:

{% assign Partially = false %}
{% for line_item in cart.items %}
{% if cart.total_price >= 100 and cart.total_price <= 39999 %}
{% assign Partially = 'Offer1ID' %}
{% elsif cart.total_price >= 40000 and cart.total_price <= 99999 %}
{% assign Partially = 'Offer2ID' %}
{% elsif 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}}',

Limit by Product ID or Variant ID

1. Limit specific offer to specific product ID on cart:

{% 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}}',

2. Limit specific offer to specific variant ID on cart:

{% assign Partially = false %}
{% assign has_ineligible_variant = 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' %}
{% else %}
{% assign has_ineligible_variant = true %}
{% endif %}
{% endfor %}

{% if Partially and has_ineligible_variant == false %}
[PARTIAL.LY SHOPIFY SCRIPT FROM INTEGRATION TOOL GOES HERE]
{% endif %}

You must replace the offer line within the Partial.ly script with offer: '{{Partially}}',

Limit by Tag and Price

{% 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 %}

Multiple Checkout Buttons on Cart at Once

Option 1:

<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}}
   };

basePartiallyConfig.offer = 'OFFER-ID-1';
var button1 = new PartiallyButton(basePartiallyConfig);
button1.init();

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

Option 2:

<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>