Advanced Scripting Examples for ECWID

​If you wish to apply limitations to your Ecwid integration, 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["order"]["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.order.items) do
    local allowed = false
 
    for _, value in ipairs(allowed_products) do
        if value == line.productId 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.order.items) do
    -- test if there's a custom offer for this line item
    if custom_offers[line.productId] ~= nil then
        return {offer_id=custom_offers[line.productId]}
    end
end
return true

Replace PRODUCT-ID-# and OFFER-ID-# with the required info.

The product ID can be found within your ECWID admin.

The offer ID can be found in your Partial.ly account within the integration tool of your offer.

Don't see what you need?

Please reach out to our support team at support@partial.ly.