Specific integration instructions to enable order extraction.
Sleek’s Web Extension SDK can extract order details from pages your users are visiting. This feature allows you to capture successful transactions and order details. This documentation will guide you through the integration process.
This document assumes that you have already integrated the Sleek web extension SDK into your
extension. If you haven’t, please refer to the Web Extension SDK integration
guide.
To extract order information from an cart, checkout or order confirmation page, you can use the
extractOrder method:
Copy
import { getWebExtSdk } from "@sleek/web-ext-sdk";const order = await getWebExtSdk().onTab(tabId).extractOrder(); // Returns Promise<ExtractOrderResult>
Sleek will only return order information on pages that are classified as
cart, checkout or checkoutComplete. To determine the page classification,
you can use the classifyPage method. See the page classification
guide for more information.
Register an event listener to receive order information:
Copy
import { getWebExtSdk } from "@sleek/web-ext-sdk";getWebExtSdk().registerEventListener((event, tabDetails) => { if (event.type === "ORDER_EXTRACTED") { const order = event.data.order; const classification = event.data.pageClassification; // Handle the order information }});
What’s next:Now that you have enabled order extraction in your extension, you can check
out the TypeDoc for specific event types and methods on the web extension SDK.