Skip to content

Commit

Permalink
Bugfix: Split shipping carrier and method by a different separator
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed May 14, 2024
1 parent 2a918e4 commit 8104eee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Controller/ApplePay/ShippingMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public function execute()
return $response->setData([
'shipping_methods' => array_map(function ($method) {
return [
'identifier' => $method->getCarrierCode() . '_' . $method->getMethodCode(),
// Magento uses an _ (underscore) to separate the carrier and method, but those can have an
// underscore as well. So separate by a different divider to prevent errors.
'identifier' => $method->getCarrierCode() . '__SPLIT__' . $method->getMethodCode(),
'label' => $method->getMethodTitle() . ' - ' . $method->getCarrierTitle(),
'amount' => number_format($method->getPriceInclTax() ?: 0.0, 2, '.', ''),
'detail' => '',
Expand Down
2 changes: 1 addition & 1 deletion Service/Magento/ChangeShippingMethodForQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function execute(AddressInterface $address, string $identifier): void
$address->setCollectShippingRates(true);
$address->setShippingMethod($identifier);

[$carrierCode, $methodCode] = explode('_', $identifier);
[$carrierCode, $methodCode] = explode('__SPLIT__', $identifier);
$shippingInformation = $this->shippingInformationFactory->create([
'data' => [
ShippingInformationInterface::SHIPPING_ADDRESS => $address,
Expand Down

0 comments on commit 8104eee

Please sign in to comment.