Skip to main content

Shipping test event listeners

Event listeners developers can use to handle shipping values in custom themes.

Written by Joan at ABConvert
Updated yesterday

ABConvert's shipping test is powerful for determining free shipping thresholds and shipping rates.

To make our shipping test more seamless when handling values in the shipping banner and shipping progress bar for some custom-built themes, we provide event listeners that developers can use to update their custom logic.

Initialized

The initialized event is the event that is triggered when our shipping script finish loading.

 document.addEventListener('abconvert:shipping:initialized', (event) => {  const shippingTestData = event.detail.shippingTestData;  console.log('abconvert:shipping:initialized: shippingTestData', shippingTestData);});

type ShippingTestData = {  rate: number; //shipping rate for the variant  seed: string;  thresholdValue: number; //shipping threshold value  type: string; // the shipping test type "FREE_SHIPPING_THRESHOLD","FLAT_RATE_SHIPPING","ADVANCED_SHIPPING"  variant: string; // the variant group of this visitor  advancedRates?: AdvanceRate[];};//all the rate and thresholdValue here is presented as subunits. // If the currency doesn't use subunits, then the value must be multiplied by 100. // For example: "rate": 500 for 5.00 CAD, "thresholdValue": 100000 for 1000 JPY.type AdvanceRate  = {  conditionType: string; // "weight", "price"  hasCondition: boolean; 
  maximum: number;//condition max value presented as subunits.    minimum: number;//condition max value presented as subunits.   price: number; //shipping rate presented as subunits.   weightUnit: string; // "kg", "lb", "oz"};

The event will only be triggered in the following scenarios:

  1. Shipping Zone Match: The country must be included in the shipping zone. If you're testing from a country outside your selected shipping zone, ensure you're using a VPN to simulate being in one of the countries within the shipping zone.

  2. Preview Mode: You can manually trigger the event by using preview mode. To do this, append the following query parameters to your URL: ?preview=<group_index>&country=<country_code>.

Finally, make sure to enable the abconvert-shipping-script in the app embed settings.

For any feedback, feel free to reach out to [email protected].

Did this answer your question?