-
Notifications
You must be signed in to change notification settings - Fork 212
@W-20931847 - OMS multiple shipment support with pickups #3613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,15 @@ const AccountOrderDetail = () => { | |
| ) | ||
| const isLoading = isOrderLoading || !order | ||
|
|
||
| // Check if order has OMS data | ||
| const isOmsOrder = useMemo(() => !!order?.omsData, [order?.omsData]) | ||
|
|
||
| // Check if order is multi-shipment order | ||
| const isMultiShipmentOrder = useMemo( | ||
| () => (order?.omsData?.shipments?.length ?? 0) > 1 || (order?.shipments?.length ?? 0) > 1, | ||
| [isOmsOrder, order?.omsData?.shipments?.length, order?.shipments?.length] | ||
| ) | ||
|
|
||
| const {pickupShipments, deliveryShipments} = useMemo(() => { | ||
| return storeLocatorEnabled | ||
| ? groupShipmentsByDeliveryOption(order) | ||
|
|
@@ -164,6 +173,67 @@ const AccountOrderDetail = () => { | |
| [storeData?.data] | ||
| ) | ||
|
|
||
| const renderShippingMethod = ( | ||
| shippingMethodName, | ||
| shippingStatus, | ||
| trackingNumber, | ||
| trackingUrl, | ||
| shipmentsLength, | ||
| index | ||
| ) => ( | ||
| <Stack spacing={1}> | ||
| <Heading as="h2" fontSize="sm" pt={1}> | ||
| {shipmentsLength > 1 ? ( | ||
| <FormattedMessage | ||
| defaultMessage="Shipping Method {number}" | ||
| id="account_order_detail.heading.shipping_method_number" | ||
| values={{number: index + 1}} | ||
| /> | ||
| ) : ( | ||
| <FormattedMessage | ||
| defaultMessage="Shipping Method" | ||
| id="account_order_detail.heading.shipping_method" | ||
| /> | ||
| )} | ||
| </Heading> | ||
| <Box> | ||
| <Text fontSize="sm" textTransform="titlecase"> | ||
| {{ | ||
| not_shipped: formatMessage({ | ||
| defaultMessage: 'Not shipped', | ||
| id: 'account_order_detail.shipping_status.not_shipped' | ||
| }), | ||
| part_shipped: formatMessage({ | ||
| defaultMessage: 'Partially shipped', | ||
| id: 'account_order_detail.shipping_status.part_shipped' | ||
| }), | ||
| shipped: formatMessage({ | ||
| defaultMessage: 'Shipped', | ||
| id: 'account_order_detail.shipping_status.shipped' | ||
| }) | ||
| }[shippingStatus] || shippingStatus} | ||
| </Text> | ||
| <Text fontSize="sm">{shippingMethodName}</Text> | ||
| {trackingNumber && ( | ||
| <Text fontSize="sm"> | ||
| <FormattedMessage | ||
| defaultMessage="Tracking Number" | ||
| id="account_order_detail.label.tracking_number" | ||
| /> | ||
| :{' '} | ||
| {trackingUrl ? ( | ||
| <ChakraLink href={trackingUrl} isExternal color="blue.600"> | ||
| {trackingNumber} | ||
| </ChakraLink> | ||
| ) : ( | ||
| trackingNumber | ||
| )} | ||
| </Text> | ||
| )} | ||
| </Box> | ||
| </Stack> | ||
| ) | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementation is same as before, just extracted into a function. |
||
| const paymentCard = order?.paymentInstruments?.[0]?.paymentCard | ||
| const CardIcon = getCreditCardIcon(paymentCard?.cardType) | ||
| const itemCount = order?.productItems?.reduce((count, item) => item.quantity + count, 0) || 0 | ||
|
|
@@ -325,86 +395,31 @@ const AccountOrderDetail = () => { | |
| </Stack> | ||
| ) | ||
| })} | ||
| {/* Any type of Non-OMS or any type of single shipment order: show DeliveryMethods and Shipments info*/} | ||
| {(!isOmsOrder || !isMultiShipmentOrder) && | ||
| deliveryShipments.map((shipment, index) => { | ||
| const omsShipment = isOmsOrder | ||
| ? order.omsData.shipments?.[index] | ||
| : null | ||
|
|
||
| {/* Delivery Shipments */} | ||
| {deliveryShipments.map((shipment, index) => { | ||
| // Hide shipping address for OMS multi-shipment orders | ||
| // Can't reliably correlate OMS shipments to ECOM addresses by index | ||
| const isOmsOrder = !!order?.omsData | ||
| const omsShipment = isOmsOrder | ||
| ? order.omsData.shipments?.[index] | ||
| : null | ||
| const isOmsMultiShipment = | ||
| isOmsOrder && | ||
| (order.omsData.shipments?.length > 1 || | ||
| order.shipments?.length > 1) | ||
|
|
||
| const shippingMethodName = | ||
| omsShipment?.provider || shipment.shippingMethod.name | ||
| const shippingStatus = | ||
| omsShipment?.status || shipment.shippingStatus | ||
| const trackingNumber = | ||
| omsShipment?.trackingNumber || shipment.trackingNumber | ||
| const trackingUrl = omsShipment?.trackingUrl | ||
| const shippingMethodName = | ||
| omsShipment?.provider || shipment.shippingMethod.name | ||
| const shippingStatus = | ||
| omsShipment?.status || shipment.shippingStatus | ||
| const trackingNumber = | ||
| omsShipment?.trackingNumber || shipment.trackingNumber | ||
| const trackingUrl = omsShipment?.trackingUrl | ||
|
|
||
| return ( | ||
| <React.Fragment key={`delivery-${index}`}> | ||
| <Stack spacing={1}> | ||
| <Heading as="h2" fontSize="sm" pt={1}> | ||
| {deliveryShipments.length > 1 ? ( | ||
| <FormattedMessage | ||
| defaultMessage="Shipping Method {number}" | ||
| id="account_order_detail.heading.shipping_method_number" | ||
| values={{number: index + 1}} | ||
| /> | ||
| ) : ( | ||
| <FormattedMessage | ||
| defaultMessage="Shipping Method" | ||
| id="account_order_detail.heading.shipping_method" | ||
| /> | ||
| )} | ||
| </Heading> | ||
| <Box> | ||
| <Text fontSize="sm" textTransform="titlecase"> | ||
| {{ | ||
| not_shipped: formatMessage({ | ||
| defaultMessage: 'Not shipped', | ||
| id: 'account_order_detail.shipping_status.not_shipped' | ||
| }), | ||
| part_shipped: formatMessage({ | ||
| defaultMessage: 'Partially shipped', | ||
| id: 'account_order_detail.shipping_status.part_shipped' | ||
| }), | ||
| shipped: formatMessage({ | ||
| defaultMessage: 'Shipped', | ||
| id: 'account_order_detail.shipping_status.shipped' | ||
| }) | ||
| }[shippingStatus] || shippingStatus} | ||
| </Text> | ||
| <Text fontSize="sm">{shippingMethodName}</Text> | ||
| {trackingNumber && ( | ||
| <Text fontSize="sm"> | ||
| <FormattedMessage | ||
| defaultMessage="Tracking Number" | ||
| id="account_order_detail.label.tracking_number" | ||
| /> | ||
| :{' '} | ||
| {trackingUrl ? ( | ||
| <ChakraLink | ||
| href={trackingUrl} | ||
| isExternal | ||
| color="blue.600" | ||
| > | ||
| {trackingNumber} | ||
| </ChakraLink> | ||
| ) : ( | ||
| trackingNumber | ||
| )} | ||
| </Text> | ||
| )} | ||
| </Box> | ||
| </Stack> | ||
| {!isOmsMultiShipment && ( | ||
| return ( | ||
| <React.Fragment key={`delivery-${index}`}> | ||
| {renderShippingMethod( | ||
| shippingMethodName, | ||
| shippingStatus, | ||
| trackingNumber, | ||
| trackingUrl, | ||
| deliveryShipments.length, | ||
| index | ||
| )} | ||
| <Stack spacing={1}> | ||
| <Heading as="h2" fontSize="sm" pt={1}> | ||
| {deliveryShipments.length > 1 ? ( | ||
|
|
@@ -437,10 +452,25 @@ const AccountOrderDetail = () => { | |
| </Text> | ||
| </Box> | ||
| </Stack> | ||
| </React.Fragment> | ||
| ) | ||
| })} | ||
|
|
||
| {/* Any OMS multi-shipment: Only show OMS Shipments info;*/} | ||
| {isOmsOrder && | ||
| isMultiShipmentOrder && | ||
| order?.omsData?.shipments?.map((shipment, index) => ( | ||
| <React.Fragment key={`oms-shipment-${index}`}> | ||
| {renderShippingMethod( | ||
| shipment.provider, | ||
| shipment.status, | ||
| shipment.trackingNumber, | ||
| shipment.trackingUrl, | ||
| order?.omsData?.shipments?.length ?? 0, | ||
| index | ||
| )} | ||
| </React.Fragment> | ||
| ) | ||
| })} | ||
| ))} | ||
|
|
||
| {/* Payment Method */} | ||
| {paymentCard && ( | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.