Shopify / ui-extensions

MIT License
249 stars 35 forks source link

useDeliveryGroups() hook result is not changing after updating the delivery address. #2035

Open Ritesh-Rana opened 1 month ago

Ritesh-Rana commented 1 month ago

I am using useDeliveryGroups() hook in checkout UI extension. It supposed to return the current delivery groups for the checkout when delivery address changes ( As i checked in hook implementation ).

Steps to reproduce the behavior:

  1. Use the hook in the extension and print the return result.
  2. Now at information page fill the shipping address and select any available shipping method on shipping page.
  3. We can see the result object as :
    [ { "targetedCartLines": [ { "id": "gid://shopify/CartLine/6169802ba0c31361360e65a18d473b7c" }, { "id": "gid://shopify/CartLine/540bbb6f8e223a63103db789078c6180" } ], "deliveryOptions": [ { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-1841c728747429c89ca8980cc97b6e21", "title": "Click and Collect", "description": "Ships next day", "type": "shipping", "carrier": {}, "cost": { "amount": 0, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 0, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "Click and Collect" }, { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-945b4de19461d3c9fc765b115996e776", "title": "Standard", "type": "shipping", "carrier": {}, "cost": { "amount": 0, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 0, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "Standard" } ], "selectedDeliveryOption": { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-945b4de19461d3c9fc765b115996e776" }, "groupType": "oneTimePurchase", "isDeliveryRequired": true, "id": "gid://shopify/DeliveryGroup/269ea2856c41d63937d1ba5212c29713" } ]
  4. Now go back to information page and update the address and move forward to shipping page.
  5. Now we can should see the new object as address is changed but it is not. I noticed the same result object : [ { "targetedCartLines": [ { "id": "gid://shopify/CartLine/6169802ba0c31361360e65a18d473b7c" }, { "id": "gid://shopify/CartLine/540bbb6f8e223a63103db789078c6180" } ], "deliveryOptions": [ { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-1841c728747429c89ca8980cc97b6e21", "title": "Click and Collect", "description": "Ships next day", "type": "shipping", "carrier": {}, "cost": { "amount": 0, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 0, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "Click and Collect" }, { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-945b4de19461d3c9fc765b115996e776", "title": "Standard", "type": "shipping", "carrier": {}, "cost": { "amount": 0, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 0, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "Standard" } ], "selectedDeliveryOption": undefined, "groupType": "oneTimePurchase", "isDeliveryRequired": true, "id": "gid://shopify/DeliveryGroup/269ea2856c41d63937d1ba5212c29713" } ]
  6. As we can see it is showing previous available shipping method and value for the key 'selectedDeliveryOption' is also become undefined

Expected behavior

Hook should update the result as per the new shipping method available on updating the address.

Before updating object is : [ { "targetedCartLines": [ { "id": "gid://shopify/CartLine/6169802ba0c31361360e65a18d473b7c" }, { "id": "gid://shopify/CartLine/540bbb6f8e223a63103db789078c6180" } ], "deliveryOptions": [ { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-1841c728747429c89ca8980cc97b6e21", "title": "Click and Collect", "description": "Ships next day", "type": "shipping", "carrier": {}, "cost": { "amount": 0, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 0, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "Click and Collect" }, { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-945b4de19461d3c9fc765b115996e776", "title": "Standard", "type": "shipping", "carrier": {}, "cost": { "amount": 0, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 0, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "Standard" } ], "selectedDeliveryOption": { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-945b4de19461d3c9fc765b115996e776" }, "groupType": "oneTimePurchase", "isDeliveryRequired": true, "id": "gid://shopify/DeliveryGroup/269ea2856c41d63937d1ba5212c29713" } ]

Expectation result object after updating address : [ { "targetedCartLines": [ { "id": "gid://shopify/CartLine/6169802ba0c31361360e65a18d473b7c" } ], "deliveryOptions": [ { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-48655edfe60d8e83a6e77ce9825db60a", "title": "International Shipping", "type": "shipping", "carrier": {}, "cost": { "amount": 30, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 30, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "International Shipping" }, { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-672a88b49e334faad5010a0075ad0bb8", "title": "Standard", "type": "shipping", "carrier": {}, "cost": { "amount": 1700, "currencyCode": "INR" }, "costAfterDiscounts": { "amount": 1700, "currencyCode": "INR" }, "deliveryEstimate": {}, "code": "Standard" } ], "selectedDeliveryOption": { "handle": "b87e1c5d1ba8e31bec7a79be1edb54cb-48655edfe60d8e83a6e77ce9825db60a" }, "groupType": "oneTimePurchase", "isDeliveryRequired": true, "id": "gid://shopify/DeliveryGroup/269ea2856c41d63937d1ba5212c29713" } ]

Screenshots

Expected result : Screenshot from 2024-05-29 19-37-58

Current Result : Screenshot from 2024-05-29 23-26-16

jamesvidler commented 1 month ago

@Ritesh-Rana can you confirm which extension target you are using in this extension?

Ritesh-Rana commented 1 month ago

@jamesvidler , target is purchase.checkout.shipping-option-list.render-after

Ritesh-Rana commented 3 weeks ago

@jamesvidler ?