Browse articles

Scalapay in the cart

Show Scalapay's pay-in-installments message above the EliteCart checkout button, kept in sync with the live cart total.

Last updated

Showing that customers can split the payment with Scalapay can help them commit to a purchase. This article shows how to add the Scalapay widget above the EliteCart checkout button with Custom HTML, so it always shows the current cart total.

Scalapay installment message shown in the EliteCart drawer near the checkout button

What you need

  • A Scalapay merchant account with Scalapay enabled for your store
  • EliteCart Professional or Enterprise (Custom HTML is part of these plans)

Add the widget

  1. Open Custom HTML

    In EliteCart, go to Cart designerOtherCustom HTML.

  2. Choose the position

    In Above checkout button, tick Enable.

  3. Paste the code

    Paste the code below into the HTML editor.

  4. Save and test

    Click Save. On your store, add products to the cart, check the installment amount, then change a quantity and check that the amount follows.

Above checkout button card with Enable ticked and the Scalapay widget code in the HTML editor.
<script type="module" src="https://cdn.scalapay.com/widget/scalapay-widget-loader.js?version=V5"></script>
<scalapay-widget amount="0" amount-separator="."></scalapay-widget>

<script>
  (function () {
    function updateScalapay(cart) {
      var root = window.eliteCartDocumentOrShadowRoot || document;
      var widget = root.querySelector("scalapay-widget");
      if (!widget || !cart) return;
      // total_price is in cents
      widget.setAttribute("amount", (cart.total_price / 100).toFixed(2));
    }

    // Every time this position appears: write the current total
    updateScalapay(window.EliteCart.getCurrentCart());

    // Only once per page: follow cart changes
    if (!window.__ecScalapayBound) {
      window.__ecScalapayBound = true;
      window.EliteCart.onCartChange(updateScalapay);
    }
  })();
</script>

Why not the amount selector

Scalapay also offers amount-selectors, which reads the total from the page. With Use Shadow DOM for CSS isolation on (the default for new installs), Scalapay's script can't see inside the cart, so the amount may stay empty or out of date. The code above hands Scalapay the cart total directly instead, which works with Shadow DOM on or off.

Scalapay reads the amount attribute only when no amount selector is set, and amount-separator="." tells it the decimals use a dot. If the amount doesn't update after a cart change, or you need other options such as your merchant settings, ask Scalapay support; they know the widget's options best.

Still stuck?

Chat with us and we'll help you get your cart live. Or email contact@elitecart.app.