1. Introduction to Connect Scripting Plugin 0:00
Overview of the video purpose: controlling shipping rates and methods during checkout.
Dynamic shipping options can be set up through code.
Access to the Connect Scripting module is required.
2. Accessing the Connect Scripting Module 0:10
Reminder to contact your Customer Success Manager if you need access to the module.
3. Shipping Plugin Endpoint Support 0:37
The Scripting plugin now supports the Shipping Plugin Endpoint for custom shipping integrations.
Use Megascript code for flexibility in defining shipping rules.
4. Data Access During Checkout 1:07
The scripting integration provides access to essential data:
Cart details
Checkout attributes
User information
Shipping and billing addresses.
5. Returning Shipping Option Information 1:20
Script execution returns detailed shipping options:
Method name/label
Unique codes for mapping
Price information
Descriptors and CSS classes for customization
Delivery offset days.
6. Example Setup 1:44
Walkthrough of a simple example on a storefront.
Navigate to Connect Settings and ensure the Connect Scripting plugin is enabled.
7. Configuring the Megascript 2:04
Go to the Connect Plugin screen and configure the Connect Scripting option.
Select the 'get shipping options' action.
8. Creating or Editing a Megascript 2:56
Access the Megascript management screen to create or edit a Megascript.
Input a simple example Megascript using static information.
9. Defining Shipping Options 3:37
Example shipping options:
UK Standard Shipping (for UK addresses)
International Shipping (for non-UK addresses)
Click and Collect (always available, free rate).
10. Saving the Megascript 4:50
Ensure the Megascript is saved before proceeding.
11. Creating a Megascript Instance 5:05
Create or edit a Megascript instance to ensure the script runs at the appropriate event.
12. Mapping Delivery Methods 5:45
Create reference mappings between script elements and delivery methods.
Use the delivery method screen to add new delivery methods.
13. Linking Delivery Methods to the Script 6:06
Specify names and link them to the Connect Scripting plugin using external IDs from the script.
14. Testing the Setup 7:04
Impersonate a customer and test the checkout process with different shipping addresses.
15. Observing Shipping Options in Action 7:23
Check available shipping options based on the input address (UK vs International).
Observe price updates and delivery days offset.
16. Flexibility of Scripting Capability 8:25
Discuss the flexibility of implementing static rules or integrating with third-party APIs for real-time rates.
17. Conclusion 9:03
Emphasize the control gained over shipping options at checkout using the Connect Scripting plugin.
/* ------------------------------------------------------------------
Get Shipping Options – Country-Based Example MegaScript
------------------------------------------------------------------
• Uses only:
1. Run.CurrentContext.Event.Parameter.ShippingAddress
2. Run.Customers.GetCustomerCheckoutAttributes (optional)
• Returns:
– UK Standard Shipping
– International Shipping
-------------------------------------------------------------------*/
// 1. Enable run-log entries & debug level
Run.AddRunLogEntry = true;
Logger.SetLogLevel(LogLevel.Debug);
Logger.LogInfo("Starting Country-Based Shipping Options script");
// 2. Grab the shipping address
var shippingAddress = Run.CurrentContext.Event.Parameter.ShippingAddress || {};
Logger.LogDebug("Shipping country: " + shippingAddress.Country);
// 3. (Optional) fetch checkout attributes if you want to use them
var customer = Run.CurrentContext.Event.Parameter.Customer;
var checkoutAttrs = Run.Customers.GetCustomerCheckoutAttributes(customer);
Logger.LogDebug("Fetched checkout attributes XML: " + checkoutAttrs);
// 4. Build the ShippingOptions array
var shippingOptions = [];
// 4a. UK Standard Shipping
if (shippingAddress.Country === "GB") {
shippingOptions.push({
Rate: 4.5,
Name: "UK Standard Shipping",
Code: "Mis.Scripting__uk_standard",
CssClass: "shipping-uk",
AdditionalInformation: "2-4 working days within the UK",
DeliveryDaysOffset: 3,
RatedShipmentWarnings: []
});
}
// 4b. International Shipping
else {
shippingOptions.push({
Rate: 15,
Name: "International Shipping",
Code: "Mis.Scripting__intl",
CssClass: "shipping-intl",
AdditionalInformation: "5-10 working days worldwide",
DeliveryDaysOffset: 7,
RatedShipmentWarnings: []
});
}
// 5. Always add a “Click and Collect” fallback
shippingOptions.push({
Rate: 0,
Name: "Click and Collect",
Code: "Mis.Scripting__pickup",
CssClass: "shipping-pickup",
AdditionalInformation: "Free — pick up in store",
DeliveryDaysOffset: 0,
RatedShipmentWarnings: []
});
// 6. Return results
var result = Run.CurrentContext.Event.Result;
result.Success = true;
result.ExternalId = null;
result.ShippingOptions = shippingOptions;
// 7. Final log
Logger.LogInfo(
"Finished script; returned " + shippingOptions.length + " options"
);
custom shipping integration script, dynamic shipping rate scripting, configure shipping methods via code, set shipping rules with Megascript, programmatic checkout shipping options, Connect Scripting shipping tutorial, shipping plugin endpoint guide, Infigo custom shipping rates, real-time shipping rate integration, conditional free shipping script