Theme customizations using ShipScout data
The definitive guide to updating shipping related copy and UI throughout your shop
Introduction
Using Javascript (Recommended approach)
<script>
window._shipScout = window._shipScout || [];
_shipScout.push(function (response) {
/*
example response object
{
experimentId: 1,
variant: 'B',
isAssignmentManagedExternally: false,
threshold: true,
thresholdType: 'pricing',
thresholdValue: 5000,
thresholdValueUnit: 'cents',
thresholdMetRateAmountCents: 0,
shippingPriceCents: 1000,
dynamicShipping: false,
lineItemProperty: '0467e6f7-8d66-4610-a939-da76dd9f7a68_1_B',
isNewAssignment: false
}
*/
//apply any exchange rates to currency if necessary
var thresholdCents = (window.Shopify && Shopify.currency && Shopify.currency.rate) ? response.thresholdValue * Shopify.currency.rate : response.thresholdValue;
var flatrateCents = (window.Shopify && Shopify.currency && Shopify.currency.rate) ? response.shippingPriceCents * Shopify.currency.rate : response.shippingPriceCents;
//format currency
var currencyFormat = ShipScoutGetCurrency();
//get threshold amount with currency symbol
var thresholdAmount = ShipScoutFormatMoney(thresholdCents, currencyFormat);
//get flat rate amount with currency symbol
var flatrateAmount = ShipScoutFormatMoney(flatrateCents, currencyFormat);
//==== insert your code below to dynamically update elements ====//
//example updating an element on the page dynamically with the threshold amount
var el = document.getElementById("foo-bar");
if(response.thresholdValue === 0) {
el.innerHTML = "FREE!";
} else {
el.innerHTML = thresholdAmount;
}
});
</script>Using liquid
Last updated