Checkout 3.0
Shipping option changed callback

Shipping option changed callback

Optional callback that allows partner to get shipping option price and currency for currently selected shipping option in Ingrid form inside Checkout3.

Callback is triggered in multiple cases:

  1. Ingrid form is loaded inside Checkout3 form
  2. New shipping option is selected in Ingrid form by the user

Registering callback

To use this optional callback, partner has to pass an additional flag shippingOptionChangedCallback to avardaCheckoutInit. Please refer to Showing the checkout form for additional info about Checkout 3 Form initialisation.

Callback payload

Callback payload is an object with price, currency and taxAmount properties as the first parameter and checkoutInstance as the second parameter (not necessary to use it).

  • price is the price of the selected shipping option (including tax), represented as a number
  • currency is the currency code for the shipping option price (for example "SEK", "EUR"), represented as a string
  • taxAmount is the tax applied to the shipping price, represented as a number

The example below shows how to use these values in a callback function.

<script>
  var shippingOptionChangedCallback = function ({ price, currency, taxAmount }, checkoutInstance) {
    console.log('price:', price);
    console.log('currency:', currency);
    console.log('taxAmount:', taxAmount);
 
    // Use data for your business logic
  };
</script>