From e36301ac145637e1a24465947e9ea8e4698841f7 Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Fri, 9 Sep 2022 10:30:20 +0200 Subject: [PATCH] feat(medusa-fulfillment-webshipper): Support personal customs no in orders (#2167) * feat(webshipper): support personal customs no in orders * docs: update readme with personal customs number info --- .../medusa-fulfillment-webshipper/README.md | 29 +++++++++++++++++++ .../src/services/webshipper-fulfillment.js | 2 ++ 2 files changed, 31 insertions(+) diff --git a/packages/medusa-fulfillment-webshipper/README.md b/packages/medusa-fulfillment-webshipper/README.md index 130bdfe202..a5859fbe14 100644 --- a/packages/medusa-fulfillment-webshipper/README.md +++ b/packages/medusa-fulfillment-webshipper/README.md @@ -15,3 +15,32 @@ A webhook listener is exposed at `/webshipper/shipments` to listen for shipment coo_countries: [an array of countries in which a Certificate of Origin will be attached] (default: "all") delete_on_cancel [determines whether Webshipper orders are deleted when a Medusa fulfillment is canceled] (default: false) ``` + +## Personal Customs Numbers + +In countries like South Korea a personal customs number is required to clear customs. The Webshipper fulfillment plugin is able pass this information to Webshipper given that the number is stored in `order.shipping_address.metadata.personal_customs_no`. + +### Modifications in checkout flow + +To pass the information along you should dynamically show an input field to the customer when they are shopping from a region that requires a personal customs number, and make sure that the metadata field is set when updating the cart shipping address. + +```js +const onUpdateAddress = async () => { + const address = { + first_name: "John", + last_name: "Johnson", + ..., + metadata: { + personal_customs_no: "my-customs-number" + } + } + + await medusaClient.carts + .update(cartId, { + shipping_address: address + }) + .then(() => { + console.log("Good stuff - Webshipper will pass along the customs number") + }) +} +``` diff --git a/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js b/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js index 7f77ef20c0..6c0324428c 100644 --- a/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js +++ b/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js @@ -390,6 +390,8 @@ class WebshipperFulfillmentService extends FulfillmentService { state: shipping_address.province, phone: shipping_address.phone, email: fromOrder.email, + personal_customs_no: + shipping_address.metadata?.personal_customs_no || null, }, currency: fromOrder.currency_code.toUpperCase(), },