Recalculate shipping fees based on choose delivery date

Recalculate shipping fees based on choose delivery date

Vieweg
Shopify Partner
10 0 0

Our store offers different delivery options as well as different prices based on the items, postcode and delivery date. We have our own CarrierService that uses this data to return the available options and prices.

We currently add the delivery address to the checkout(shippingAddress) and the delivery date chosen by the customer to the attributes of the order items(checkoutLineItems.attributes), using storefrontAPI before getting to the checkout, this way the price is calculated correctly using this information.

Our goal is to remove this previous step and using the new checkout extensibility features, add a dataPicker to the checkout.

The flow would be something like this:

  1. Customer arrives at checkout
  2. Customer fills in the address
  3. Select the delivery date
    1. We update the cartLineItems by adding the chosen date to the attributes
    2. Recalculate delivery options and fees
  4. displays the delivery method selector with options and prices for the selected day.

It is also necessary to recalculate delivery fees each time the delivery date changes, in the same way as it would if the delivery address changes.

 

We have already added the datapicker to the checkout using Checkout UI Extension, we have also managed to add the date to cartLineItems.

The question is, how can we get the delivery price to be recalculated after a date is selected/changed?

Thank you 


Vieweg_0-1714741352495.png

 

Replies 0 (0)