Skip to content

Commit cfadd77

Browse files
zlikasavaleMeta
andauthored
Parsing shipping option in reference ID for dynamic checkout (#536)
* shipping option for dynamic checkout * added a change based on dynamic checkout recent discussions * use '_' as the delimiter for shipping option * remove extra space --------- Co-authored-by: Ameya Savale <[email protected]>
1 parent 8677978 commit cfadd77

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/code/Meta/Sales/Model/Mapper/OrderMapper.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,21 @@ public function map(array $data, int $storeId): Order
184184
* @param array $data
185185
* @param int $storeId
186186
* @return void
187+
* @throws LocalizedException
187188
*/
188189
private function applyShippingToOrder(Order $order, array $data, int $storeId)
189190
{
190191
$metaShippingOptionName = $data['selected_shipping_option']['name'];
191192
$magentoShippingReferenceID = $data['selected_shipping_option']['reference_id'];
192193

193-
$shippingMethod = $this->getShippingMethod($metaShippingOptionName, $magentoShippingReferenceID, $storeId);
194-
$shippingDescription = $this->getShippingDescription($metaShippingOptionName, $shippingMethod, $storeId);
194+
if (strpos($magentoShippingReferenceID, '_') !== false) {
195+
$shippingMethod = $magentoShippingReferenceID;
196+
$shippingDescription = $metaShippingOptionName;
197+
} else {
198+
$shippingMethod = $this->getShippingMethod($metaShippingOptionName, $magentoShippingReferenceID, $storeId);
199+
$shippingDescription = $this->getShippingDescription($metaShippingOptionName, $shippingMethod, $storeId);
200+
}
201+
195202
// This should never happen, as it means Meta has passed a shipping method with no equivalent in Magento.
196203
// @todo strictly handle this edge case by canceling the entire Meta order if this happens.
197204
$fallbackShippingDescription = $metaShippingOptionName . " - {$shippingMethod}";

0 commit comments

Comments
 (0)