If you wish to apply limitations to the woocommerce plugin, you will need to sign up for our Advanced Scripting subscription. It is free for the first 30 days and then $10 a month. You can read more about this here: https://support.partial.ly/advanced-scripting/
You can activate Advanced Scripting within your Partial.ly account under Settings > Advanced Scripting. Here is a direct link: https://partial.ly/merchant/merchant_script
Once activated, you will see a box to place the code needed for your limitations:
Below are examples of various scripts:
#1. Minimum Order Requirement:
total = context["total"]
if total < 300 then
return {error="Partial.ly is not available for orders under $300"}
else
return true
end
Replace the amount with your preference.
#2. Different Offers for Different Products
-- allowed product ids, anything else won't be allowed
allowed_products = {PRODUCT-ID-#1,PRODUCT-ID-#2}
-- check for any disallowed products
for _, line in ipairs(context.line_items) do
local allowed = false
for _, value in ipairs(allowed_products) do
if value == line.product_id then
allowed = true
end
end
if allowed == false then
return {error="Can not use Partially with "..line.name.." in cart"}
end
end
-- map of product ids to offer ids, these are product ids with custom/non-default offers
custom_offers = {}
custom_offers[PRODUCT-ID-#1] = "OFFER-ID-#1"
custom_offers[PRODUCT-ID-#2] = "OFFER-ID-#2"
-- iterate over cart line items
for _, line in ipairs(context.line_items) do
-- test if there's a custom offer for this line item
if custom_offers[line.product_id] ~= nil then
return {offer_id=custom_offers[line.product_id]}
end
end
return true
Replace PRODUCT-ID-# and OFFER-ID-# with the required info.
The product ID can be found within your woocommerce admin.
The offer ID can be found in your Partial.ly account within the integration tool of your offer.
#3: Limit a specific product to a specific offer while having all other products default to the offer set within your Woo plugin
-- iterate over cart line items
for _, line in ipairs(context.line_items) do
-- test if product is in cart
if line.product_id == PRODUCT-ID-# then
return {offer_id="OFFER-ID-#"}
else
return true
end
end
Replace PRODUCT-ID-# and OFFER-ID-# with the required info.
The product ID can be found within your woocommerce admin.
The offer ID can be found in your Partial.ly account within the integration tool of your offer.
#4: Multiple Offers Limited by Price Range:
total = context["total"]
if total < 300 then
return {error = "Partial.ly is not available for orders under $300"}
end
if total > 300 and total < 1000 then
return {offer_id="OFFER-ID-#1"}
end
if total > 1001 and total < 3000 then
return {offer_id="OFFER-ID-#2"}
end
if total > 3001 then
return {offer_id="OFFER-ID-#3"}
end
Replace the amounts with your preference and the OFFER-ID-# with the required info.
The offer ID can be found in your Partial.ly account within the integration tool of your offer.
#5: Combination: Limit a specific product to a specific offer while having all other products default to the offer set within your Woo plugin, plus a required price minimum.
total = context["total"]
if total < 300 then
return {error = "Partial.ly is not available for orders under $300"}
end
-- iterate over cart line items
for _, line in ipairs(context.line_items) do
-- test if product is in cart
if line.product_id == PRODUCT-ID-# then
return {offer_id="OFFER-ID-#"}
else
return true
end
end
#6. Only have certain products available for offer set in plugin.
-- allowed product ids, anything else won't be allowed
allowed_products = {PRODUCT-ID-#1,PRODUCT-ID-#2}
-- check for any disallowed products
for _, line in ipairs(context.line_items) do
local allowed = false
for _, value in ipairs(allowed_products) do
if value == line.product_id then
allowed = true
end
end
if allowed == false then
return {error="Can not use Partially with "..line.name.." in cart"}
end
end
Don't see what you need?
Please reach out to our support team at support@partial.ly.