Skip to content
Cartly Developers

App Extensions

Extend the Cartly admin and storefront with custom UI blocks, scripts, and integration hooks.

Overview

App Extensions let you inject behaviour into Cartly without modifying core platform code. There are three extension types:

  • Integration Hooks — react to platform events (order created, product updated, etc.)
  • Storefront Scripts — JavaScript injected into every storefront page
  • Admin UI Blocks — embedded iframes rendered inside admin pages via App Bridge

Integration Hooks

Hooks are defined in your connector template JSON. When a matching platform event fires, Cartly sends an HTTP request to your endpoint with the event payload interpolated via the input_mapping.

jsonHook definition in connector template
// Define hooks in your connector template (JSON)
{
  "hooks": {
    "order.created": {
      "chain": [
        {
          "url": "https://your-app.example.com/hooks/order-created",
          "method": "POST",
          "input_mapping": {
            "order_id": "{{order.id}}",
            "total": "{{order.total_price}}",
            "customer_email": "{{order.customer.email}}"
          }
        }
      ]
    }
  }
}

Supported hook events:

  • order.created, order.paid, order.fulfilled, order.cancelled
  • product.created, product.updated, product.deleted
  • customer.created, customer.updated
  • cart.recovered

Storefront Scripts

Register a script URL via the Admin API and Cartly will inject it into every storefront page. The window.Cartly global exposes shop context, cart state, and event listeners.

javascriptStorefront script example
// Storefront script — injected on all storefront pages
// Access cart, shop, and customer data via window.Cartly
window.Cartly.onReady(function(ctx) {
  console.log("Shop:", ctx.shop.name);
  console.log("Cart items:", ctx.cart.item_count);

  // Listen to cart changes
  ctx.cart.on("change", function(cart) {
    console.log("Cart updated:", cart.item_count, "items");
  });
});

Admin UI Blocks

Admin UI blocks are iframes rendered inside admin pages using the App Bridge protocol. Register your block URL and target page (e.g., product-detail, order-detail) and the admin will embed your UI at the specified location.

See the App Bridge guide for the full iframe communication protocol.

Extension Lifecycle

  1. Merchant installs your app from the Marketplace
  2. OAuth authorization flow completes
  3. Cartly activates your registered hooks, scripts, and UI blocks
  4. Extensions remain active until the merchant uninstalls the app