diff --git a/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php index 1b2e43592b0d158bb7b71dfcb120908ad0142d96..5d071801a406da9f220bf1fd0093996f8eeb5b3d 100644 --- a/Block/System/Config/Form/Field/Version.php +++ b/Block/System/Config/Form/Field/Version.php @@ -1,5 +1,5 @@ <?php -namespace bobgo\CustomShipping\Block\System\Config\Form\Field; +namespace BobGroup\BobGo\Block\System\Config\Form\Field; use Magento\Framework\Data\Form\Element\AbstractElement; @@ -15,17 +15,17 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field const EXTENSION_URL = 'https://www.bob.co.za'; /** - * @var \bobgo\CustomShipping\Helper\Data $helper + * @var \BobGroup\BobGo\Helper\Data $helper */ protected $_helper; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \bobgo\CustomShipping\Helper\Data $helper + * @param \BobGroup\BobGo\Helper\Data $helper */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \bobgo\CustomShipping\Helper\Data $helper + \BobGroup\BobGo\Helper\Data $helper ) { $this->_helper = $helper; parent::__construct($context); @@ -39,7 +39,7 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field protected function _getElementHtml(AbstractElement $element) { $extensionVersion = $this->_helper->getExtensionVersion(); - $extensionTitle = 'Bob Go'; + $extensionTitle = 'BobGo'; $versionLabel = sprintf( '<a href="%s" title="%s" target="_blank">%s</a>', self::EXTENSION_URL, diff --git a/Helper/Data.php b/Helper/Data.php index 0b3e07a2972a63d06db5d3888cde878072a7216e..d0627eefd27a235e7b0b5b498f8e22ab4fd1a215 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,5 +1,5 @@ <?php -namespace bobgo\CustomShipping\Helper; +namespace BobGroup\BobGo\Helper; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; @@ -15,8 +15,8 @@ use Magento\Store\Model\ScopeInterface; class Data extends AbstractHelper { - const XML_PATH_ENABLED = 'bobgo_CustomShipping/general/enabled'; - const XML_PATH_DEBUG = 'bobgo_CustomShipping/general/debug'; + const XML_PATH_ENABLED = 'BobGroup_BobGo/general/enabled'; + const XML_PATH_DEBUG = 'BobGroup_BobGo/general/debug'; /** * @var \Psr\Log\LoggerInterface @@ -65,7 +65,7 @@ class Data extends AbstractHelper public function getExtensionVersion() { - $moduleCode = 'bobgo_CustomShipping'; + $moduleCode = 'BobGroup_BobGo'; $moduleInfo = $this->_moduleList->getOne($moduleCode); return $moduleInfo['setup_version']; } diff --git a/Model/Carrier/CustomShipping.php b/Model/Carrier/BobGo.php similarity index 82% rename from Model/Carrier/CustomShipping.php rename to Model/Carrier/BobGo.php index f2ae2682c08008894481c20610950770fd11022c..431e11b6fcf31a0ed6828d9d2d30321b1d2a5785 100644 --- a/Model/Carrier/CustomShipping.php +++ b/Model/Carrier/BobGo.php @@ -1,7 +1,7 @@ <?php declare(strict_types=1); -namespace bobgo\CustomShipping\Model\Carrier; +namespace BobGroup\BobGo\Model\Carrier; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; use Magento\CatalogInventory\Api\StockRegistryInterface; @@ -16,11 +16,11 @@ use Magento\Framework\DataObject; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\HTTP\Client\CurlFactory; use Magento\Framework\Module\Dir\Reader; -use Magento\Framework\View\Element\Template\Context; use Magento\Framework\Xml\Security; use Magento\Quote\Model\Quote\Address\RateRequest; use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; +use Magento\Sales\Model\Order\Shipment; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Rate\Result; @@ -41,11 +41,10 @@ use Psr\Log\LoggerInterface; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface +class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface { /** * Code of the carrier - *` * @var string */ public const CODE = 'bobgo'; @@ -74,6 +73,12 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected $_result = null; + /** + * Container types that could be customized for bobgo carrier + * + * @var string[] + */ + protected $_customizableContainerTypes = ['YOUR_PACKAGING']; /** * @var \Magento\Store\Model\StoreManagerInterface @@ -102,8 +107,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected JsonFactory $jsonFactory; private $cartRepository; - private Company $company; - private uSub $newSub; + public Company $company; /** @@ -177,7 +181,6 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ ); $this->jsonFactory = $jsonFactory; $this->curl = $curlFactory->create(); - $this->newSub = new uSub(); $this->company = new Company(); } @@ -190,8 +193,8 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ public function getBaseUrl(): string { - $storeBaseUrl = $this->_storeManager->getStore()->getBaseUrl(); - return parse_url($storeBaseUrl)["host"]; + $storeBase = $this->_storeManager->getStore()->getBaseUrl(); + return parse_url($storeBase, PHP_URL_HOST); } @@ -206,6 +209,79 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ return $this->uRates($payload); } + /** + * Processing additional validation to check if carrier applicable. + * + * @param \Magento\Framework\DataObject $request + * @return $this|bool|\Magento\Framework\DataObject + */ + public function processAdditionalValidation(\Magento\Framework\DataObject $request) + { + if (!count($this->getAllItems($request))) { + return false; + } + + $maxAllowedWeight = 500; //$this->getConfigData('max_package_weight'); + $errorMsg = ''; + $configErrorMsg = $this->getConfigData('specificerrmsg'); + $defaultErrorMsg = __('The shipping module is not available.'); + $showMethod = $this->getConfigData('showmethod'); + + /** @var $item \Magento\Quote\Model\Quote\Item */ + foreach ($this->getAllItems($request) as $item) { + $product = $item->getProduct(); + if ($product && $product->getId()) { + $weight = $product->getWeight(); + $stockItemData = $this->stockRegistry->getStockItem( + $product->getId(), + $item->getStore()->getWebsiteId() + ); + $doValidation = true; + + if ($stockItemData->getIsQtyDecimal() && $stockItemData->getIsDecimalDivided()) { + if ($stockItemData->getEnableQtyIncrements() && $stockItemData->getQtyIncrements() + ) { + $weight = $weight * $stockItemData->getQtyIncrements(); + } else { + $doValidation = false; + } + } elseif ($stockItemData->getIsQtyDecimal() && !$stockItemData->getIsDecimalDivided()) { + $weight = $weight * $item->getQty(); + } + + + if ($doValidation && $weight > $maxAllowedWeight) { + $errorMsg = $configErrorMsg ? $configErrorMsg : $defaultErrorMsg; + break; + } + } + } + + if (!$errorMsg && !$request->getDestPostcode() && $this->isZipCodeRequired($request->getDestCountryId())) { + + $errorMsg = __('This shipping method is not available. Please specify the zip code.'); + } + + if ($request->getDestCountryId() == 'ZA') { + $errorMsg = ''; + } else { + $errorMsg = $configErrorMsg ? $configErrorMsg : $defaultErrorMsg; + } + + if ($errorMsg && $showMethod) { + $error = $this->_rateErrorFactory->create(); + $error->setCarrier($this->_code); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setErrorMessage($errorMsg); + + return $error; + } elseif ($errorMsg) { + return false; + } + + return $this; + } + /** * Collect and get rates for this shipping method based on information in $request * This is a default function that is called by Magento to get the shipping rates for the cart @@ -223,6 +299,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ * This method is used is the last resort to get the company name since the company name is not available in _rateFactory */ $destComp = $this->getDestComp(); + $destSuburb = $this->getDestSuburb(); /** @var \Magento\Shipping\Model\Rate\Result $result */ @@ -237,23 +314,16 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ /** Destination Information */ [$destStreet1, $destStreet2, $destStreet3] = $this->destStreet($destStreet); + + /** Origin Information */ - [$originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb] = $this->storeInformation(); - /** Get all the items in the cart */ - $items = $request->getAllItems(); + [$originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb,$weightUnit] = $this->storeInformation(); + /** Get all items in cart */ + $items = $request->getAllItems(); $itemsArray = []; + $itemsArray = $this->getStoreItems($items, $weightUnit, $itemsArray); - foreach ($items as $item) { - $itemsArray[] = [ - 'sku' => $item->getSku(), - 'quantity' => $item->getQty(), - 'price' => $item->getPrice(), - 'grams' => $item->getWeight() * 1000, - ]; - } - - $destSubs = $this->getDestStreet(); $payload = [ 'identifier' => $baseIdentifier, 'rate' => [ @@ -272,8 +342,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ 'company' => $destComp, 'address1' => $destStreet1, 'address2' => $destStreet2, - 'suburb' => $destSubs,//$destStreet3, - + 'suburb' => $destSuburb, 'city' => $destCity, 'province' => $destRegion, 'country_code' => $destCountry, @@ -289,10 +358,6 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Get The store information from the Magento store configuration and return it as an array - * In magento 2 there is origin information in the store information section of the configuration, so we get it from there - * since Store Information has the origin information including suburb field that we Injected upon Bob Go Extension installation - * which is not available in the origin section * @return array */ public function storeInformation(): array @@ -335,9 +400,14 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ 'general/store_information/suburb', ScopeInterface::SCOPE_STORE ); + $weightUnit = $this->_scopeConfig->getValue( + 'general/locale/weight_unit', + ScopeInterface::SCOPE_STORE + ); $baseIdentifier = $this->getBaseUrl(); - return array($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb); + + return array($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb, $weightUnit); } @@ -392,7 +462,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ /** * Get configuration data of carrier - * Interact with the + * * @param string $type * @param string $code * @return array|false @@ -402,19 +472,11 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ { $codes = [ 'method' => [ - 'bobgo_SHIPPING' => __('bobgo Shipping'), + 'bobGo' => __('BobGo'), ], 'unit_of_measure' => [ - 'KG' => __('Kilograms'), - ], - 'specificcountry' => [ - 'ZA' => __('South Africa'), - ], - 'allspecificcountries' => [ - 'ZA' => __('South Africa'), - ], - 'showmethod' => [ - '0' => __('No'), + 'KGS' => __('Kilograms'), + 'LBS' => __('Pounds'), ], ]; @@ -433,8 +495,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ /** - * Get tracking info by tracking number or tracking request - * Without getTrackingInfo() method, Magento will not show tracking info on frontend + * Get tracking * * @param string|string[] $trackings * @return Result|null @@ -455,7 +516,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Set tracking request data for request by getting context from Magento + * Set tracking request * * @return void */ @@ -470,7 +531,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Send request for the actual tracking info and process response + * Send request for tracking * * @param string[] $tracking * @return void @@ -496,6 +557,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ } foreach ($trackingValue as $trackingReference) { $tracking = $this->_trackStatusFactory->create(); + $tracking->setCarrier(self::CODE); $tracking->setCarrierTitle($carrierTitle); @@ -715,7 +777,7 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Perform API Request to Bob Go API and return response + * Perfom API Request to bobgo API and return response * @param array $payload * @param Result $result * @return void @@ -913,13 +975,69 @@ class CustomShipping extends AbstractCarrierOnline implements \Magento\Shipping\ { return $this->company->getDestComp(); } - - /* - * Get the suburb from the uSub class + /** * @return mixed|string */ - protected function getDestStreet(): mixed + public function getDestSuburb(): mixed + { + return $this->company->getSuburb(); + } + + /** + * @param mixed $weightUnit + * @param mixed $item + * @return float|int + */ + public function getItemWeight(mixed $weightUnit, mixed $item): int|float + { + //1 lb = 453.59237 g exact. 1 kg = 1000 g. 1 lb = 0.45359237 kg + if ($weightUnit == 'KGS') { + $mass = $item->getWeight() ? $item->getWeight() * 1000 : 0; + } else { + $mass = $item->getWeight() ? $item->getWeight() * 0.45359237 * 1000 : 0;//Pound to Kilogram Conversion Formula + } + return $mass; + } + + /** + * @param array $items + * @param mixed $weightUnit + * @param array $itemsArray + * @return array + */ + public function getStoreItems(array $items, mixed $weightUnit, array $itemsArray): array { - return $this->newSub->getSuburb(); + foreach ($items as $item) { + + $mass = $this->getItemWeight($weightUnit, $item); + + $itemsArray[] = [ + 'sku' => $item->getSku(), + 'quantity' => $item->getQty(), + 'price' => $item->getPrice(), + 'weight' => round($mass), + ]; + + } + return $itemsArray; + } + + /** + * Get the list of required data fields + * @return bool + */ + public function hasRequiredData(DataObject $request): bool + { + $requiredFields = [ + 'dest_country_id', + 'dest_region_id', + ]; + + foreach ($requiredFields as $field) { + if (!$request->getData($field)) { + return false; + } + } + return true; } } diff --git a/Model/Carrier/Company.php b/Model/Carrier/Company.php index c0d6a932df2aa37fdcaef03a53b0cceea8adb38d..b5547595722df67b2535db561a06aad3c28b1918 100644 --- a/Model/Carrier/Company.php +++ b/Model/Carrier/Company.php @@ -1,6 +1,6 @@ <?php -namespace bobgo\CustomShipping\Model\Carrier; +namespace BobGroup\BobGo\Model\Carrier; /** * Get the Company information from the request body and return it @@ -22,4 +22,18 @@ class Company } return $destComp; } + + public function getSuburb(): mixed + { + + $data = json_decode(file_get_contents('php://input'), true); + + if (isset($data['address']['custom_attributes'][0]['value'])) { + $destSub = $data['address']['custom_attributes'][0]['value']; + //print_r($destSub); + } else { + $destSub = ''; + } + return $destSub; + } } diff --git a/Model/Carrier/Suburb.php b/Model/Carrier/Suburb.php deleted file mode 100644 index e8b18dd63d2c00a80a91e451ff68f431ae29c039..0000000000000000000000000000000000000000 --- a/Model/Carrier/Suburb.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace bobgo\CustomShipping\Model\Carrier; - - -use Magento\Checkout\Api\Data\ShippingInformationInterface; -use Magento\Framework\View\Element\Template; -use Magento\Framework\View\Element\Template\Context; - -class Suburb extends Template { - - /** - * @var ShippingInformationInterface - */ - private $_addressInformation; - - /** - * @param Context $context - * @param ShippingInformationInterface $addressInformation - * @param array $data - */ - public function __construct( - Context $context, - ShippingInformationInterface $addressInformation, - array $data = [] - ) { - $this->_addressInformation = $addressInformation; - parent::__construct($context, $data); - } - - /** - * Get custom Shipping Charge - * - * @return String - */ - public function getShippingCharge() - { - $extAttributes = $this->_addressInformation->getExtensionAttributes(); - return $extAttributes->getCustomField(); //get custom attribute data. - } -} diff --git a/Model/Carrier/uData.php b/Model/Carrier/uData.php index 12d975fea967ead004f06d1999f94a4c38f801a0..4ccffa28748266b3e0d3e379a3c835055bc58f8b 100644 --- a/Model/Carrier/uData.php +++ b/Model/Carrier/uData.php @@ -1,14 +1,14 @@ <?php -namespace bobgo\CustomShipping\Model\Carrier; +namespace BobGroup\BobGo\Model\Carrier; /** * Class uData - * bobGo API Resources for Custom Shipping - * @package bobgo\CustomShipping\Model\Carrier + * @package BobGroup\BobGo\Model\Carrier */ class uData { + /** Tracking Endpoint */ //dev public const TRACKING = 'https://api.dev.bobgo.co.za/tracking?channel=localhost&tracking_reference='; diff --git a/Model/Carrier/uSub.php b/Model/Carrier/uSub.php deleted file mode 100644 index 87cb646178974111ec4fecb845d1189e56819185..0000000000000000000000000000000000000000 --- a/Model/Carrier/uSub.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -namespace bobgo\CustomShipping\Model\Carrier; -use Magento\Checkout\Api\Data\ShippingInformationInterface; -use Magento\Framework\App\ObjectManager; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Quote\Api\CartRepositoryInterface; - - -class uSub -{ - public function getSuburb(): mixed - { - //address.custom_attributes[0].value = "suburb value" - $data = json_decode(file_get_contents('php://input'), true); - return $data['address']['custom_attributes'][0]['value'] ?? ''; - } - -} diff --git a/Model/Carrier/uSubs.php b/Model/Carrier/uSubs.php index 315f65d7a7def1f6362c3756bb16f1a4d78bc7ce..283f8b5b7ddc9614c9aeef7848cec348ac303707 100644 --- a/Model/Carrier/uSubs.php +++ b/Model/Carrier/uSubs.php @@ -1,6 +1,6 @@ <?php -namespace bobgo\Customshipping\Model\Carrier; +namespace BobGroup\BobGo\Model\Carrier; /** Get Company information if available from the Estimate Shipping Methods Request Body */ class uSubs diff --git a/Model/Source/Allspecificcountries.php b/Model/Source/Allspecificcountries.php deleted file mode 100644 index eecbda8f154a553c54a33ba921a49b606ca957bc..0000000000000000000000000000000000000000 --- a/Model/Source/Allspecificcountries.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -namespace bobgo\CustomShipping\Model\Source; - -class Allspecificcountries extends Generic -{ - /** - * Carrier code - * @var string - */ - protected string $_code = 'allspecificcountries'; - - /** - * @return array - */ - public function toOptionArray(): array - { - return [ - ['value' => 1, 'label' => __('Specific Countries')] - ]; - } - -} diff --git a/Model/Source/Country.php b/Model/Source/Country.php deleted file mode 100644 index 017d7353c5f9476ee5bd379e28dce03e673d3434..0000000000000000000000000000000000000000 --- a/Model/Source/Country.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace bobgo\CustomShipping\Model\Source; - -class Country extends Generic -{ - /** - * Carrier code - * @var string - */ - protected string $_code = 'specificcountry'; - -} diff --git a/Model/Source/Dropoff.php b/Model/Source/Dropoff.php index e2705573bef8e747fc4a8759cbeb78165e5f743a..e355c3ad31e4bb0c5d66c438ef6880afc30a786a 100644 --- a/Model/Source/Dropoff.php +++ b/Model/Source/Dropoff.php @@ -1,6 +1,6 @@ <?php -namespace bobgo\CustomShipping\Model\Source; +namespace BobGroup\BobGo\Model\Source; class Dropoff extends Generic { diff --git a/Model/Source/Freemethod.php b/Model/Source/Freemethod.php index 2e0bc6fd50f52e242f98ed7eef3965f47c032fae..674f68706a72978fd580ecb1f6ebd157e78b9bfc 100644 --- a/Model/Source/Freemethod.php +++ b/Model/Source/Freemethod.php @@ -1,6 +1,6 @@ <?php -namespace bobgo\CustomShipping\Model\Source; +namespace BobGroup\BobGo\Model\Source; /** * Bob Go Free Method source implementation diff --git a/Model/Source/Generic.php b/Model/Source/Generic.php index 4751ab06e16faf475fef74fe0f7a12c9a8afd525..f5eb3943cd1c7c0f71cc2af44e6361fb0adb1006 100644 --- a/Model/Source/Generic.php +++ b/Model/Source/Generic.php @@ -1,33 +1,33 @@ <?php -namespace bobgo\CustomShipping\Model\Source; +namespace BobGroup\BobGo\Model\Source; use Magento\Framework\Data\OptionSourceInterface; -use bobgo\CustomShipping\Model\Carrier\CustomShipping; +use BobGroup\BobGo\Model\Carrier\BobGo; /** - * Bob Go generic source implementation + * bobgo generic source implementation */ class Generic implements OptionSourceInterface { /** - * @var CustomShipping + * @var BobGo */ - protected CustomShipping $_shippingCustomShipping; + protected BobGo $_shippingBobGo; /** * Carrier code * @var string */ - protected string $_code = 'bobgo'; + protected string $_code = ''; /** - * @param CustomShipping $shippingCustomShipping + * @param BobGo $shippingBobGo */ - public function __construct(CustomShipping $shippingCustomShipping) + public function __construct(BobGo $shippingBobGo) { - $this->_shippingCustomShipping = $shippingCustomShipping; + $this->_shippingBobGo = $shippingBobGo; } /** @@ -36,7 +36,7 @@ class Generic implements OptionSourceInterface */ public function toOptionArray() { - $configData = $this->_shippingCustomShipping->getCode($this->_code); + $configData = $this->_shippingBobGo->getCode($this->_code); $arr = []; if ($configData) { $arr = array_map( diff --git a/Model/Source/Method.php b/Model/Source/Method.php index 6ff23503c0c8b273df38b0abfbc5dcee3b1e4f79..fe13c122b58ad9be911db099da5774bcec6fe30d 100644 --- a/Model/Source/Method.php +++ b/Model/Source/Method.php @@ -1,6 +1,6 @@ <?php -namespace bobgo\CustomShipping\Model\Source; +namespace BobGroup\BobGo\Model\Source; class Method extends Generic { diff --git a/Model/Source/Packaging.php b/Model/Source/Packaging.php index 5c93ad376f2c01564da7593149e89cc783dcc06f..a7fce6356606f0bc366c4d8b0b45acd40da71df6 100644 --- a/Model/Source/Packaging.php +++ b/Model/Source/Packaging.php @@ -1,6 +1,6 @@ <?php -namespace bobgo\CustomShipping\Model\Source; +namespace BobGroup\BobGo\Model\Source; class Packaging extends Generic { diff --git a/Model/Source/Showmethod.php b/Model/Source/Showmethod.php deleted file mode 100644 index d2c517c78e74c844672f83ab83a1237aa5d40b3d..0000000000000000000000000000000000000000 --- a/Model/Source/Showmethod.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace bobgo\CustomShipping\Model\Source; - -class Showmethod extends Generic -{ - /** - * @return array - */ - public function toOptionArray() - { - return [ - ['value' => '0', 'label' => __('No')], - ]; - } - -} diff --git a/Model/Source/Unitofmeasure.php b/Model/Source/Unitofmeasure.php index 8ef12cdb8b4a84d1ae7a59b5c8a366a1e6d54e69..be8d13b0455812d4f308f45a235ab4888eb19aa5 100644 --- a/Model/Source/Unitofmeasure.php +++ b/Model/Source/Unitofmeasure.php @@ -1,6 +1,6 @@ <?php -namespace bobgo\CustomShipping\Model\Source; +namespace BobGroup\BobGo\Model\Source; class Unitofmeasure extends Generic { @@ -9,4 +9,5 @@ class Unitofmeasure extends Generic * @var string */ protected string $_code = 'unit_of_measure'; + } diff --git a/Observer/SaveOrderBeforeSalesModelQuote.php b/Observer/SaveOrderBeforeSalesModelQuote.php deleted file mode 100644 index 25cc18a5477f0a750453cda6716d5ff348e898a8..0000000000000000000000000000000000000000 --- a/Observer/SaveOrderBeforeSalesModelQuote.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -namespace bobgo\CustomShipping\Observer; - -use Magento\Framework\DataObject\Copy; -use Magento\Framework\Event\Observer; -use Magento\Framework\Event\ObserverInterface; -use Magento\Quote\Model\Quote; -use Magento\Sales\Model\Order; - -/** - * Class SaveOrderBeforeSalesModelQuote - * @package bobgo\CustomShipping\Observer - * This class is supposed to copy the suburb attribute from the quote to the order object. - */ -class SaveOrderBeforeSalesModelQuote implements ObserverInterface -{ - public Copy $objectCopyService; - - public function __construct( - Copy $objectCopyService - ) { - $this->objectCopyService = $objectCopyService; - } - - public function execute(Observer $observer) - { - $this->objectCopyService->copyFieldsetToTarget( - 'sales_convert_quote', - 'to_order', - $observer->getEvent()->getQuote(), - $observer->getEvent()->getOrder() - ); - - - return $this; - - } -} diff --git a/Plugin/Block/DataProviders/Tracking/ChangeTitle.php b/Plugin/Block/DataProviders/Tracking/ChangeTitle.php index 285ca5af64851b89e1d4de810acc46bd2a8bc7b8..03d6b4c431d49ef9588960332a9e4213a815173e 100644 --- a/Plugin/Block/DataProviders/Tracking/ChangeTitle.php +++ b/Plugin/Block/DataProviders/Tracking/ChangeTitle.php @@ -1,20 +1,20 @@ <?php -namespace bobgo\CustomShipping\Plugin\Block\DataProviders\Tracking; +namespace BobGroup\BobGo\Plugin\Block\DataProviders\Tracking; -use bobgo\CustomShipping\Model\Carrier; +use BobGroup\BobGo\Model\Carrier; use Magento\Shipping\Model\Tracking\Result\Status; use Magento\Shipping\Block\DataProviders\Tracking\DeliveryDateTitle as Subject; /** - * Plugin to change delivery date title with Bob Go customized value + * Plugin to change delivery date title with bobgo customized value */ class ChangeTitle { /** - * Title modification in case if Bob Go used as carrier + * Title modification in case if bobgo used as carrier * * @param Subject $subject * @param \Magento\Framework\Phrase|string $result diff --git a/Plugin/Block/Tracking/PopUpDeliveryDate.php b/Plugin/Block/Tracking/PopUpDeliveryDate.php index e2fa211dd336927e36e7f5bfb17f1f69e8a42c97..18c07ebf94298a5a8703f3f80f3efe5cb44e0f01 100644 --- a/Plugin/Block/Tracking/PopUpDeliveryDate.php +++ b/Plugin/Block/Tracking/PopUpDeliveryDate.php @@ -1,10 +1,10 @@ <?php -namespace bobgo\CustomShipping\Plugin\Block\Tracking; +namespace BobGroup\BobGo\Plugin\Block\Tracking; use Magento\Shipping\Block\Tracking\Popup; use Magento\Shipping\Model\Tracking\Result\Status; -use Magento\Shiiping\Model\Carrier; +use Magento\Shipping\Model\Carrier; /* * Plugin to update delivery date value in case if Bob Go is a carrier used diff --git a/Plugin/Checkout/Block/LayoutProcessorPlugin.php b/Plugin/Checkout/Block/LayoutProcessorPlugin.php index 24a13280ae0d4884462bf4b36817b4e0948b4f46..1c32fb6afc4d8e9b0956ec0534ad9adc237f88ab 100644 --- a/Plugin/Checkout/Block/LayoutProcessorPlugin.php +++ b/Plugin/Checkout/Block/LayoutProcessorPlugin.php @@ -1,11 +1,11 @@ <?php -namespace bobgo\CustomShipping\Plugin\Checkout\Block; +namespace BobGroup\BobGo\Plugin\Checkout\Block; use Magento\Checkout\Block\Checkout\LayoutProcessor; /** * Class LayoutProcessorPlugin - * @package bobgo\CustomShipping\Plugin\Checkout\Block + * @package BobGroup\BobGo\Plugin\Checkout\Block * This class is supposed to add a new field to the checkout page for the suburb. It is supposed to be used in conjunction with the SaveOrderBeforeSalesModelQuote observer. * At the moment, it overrides the 2 Address fields and adds a new 3 Address field to accommodate the suburb on the checkout page( including placeholders). * This is not the best way to do it, but it is the only way I could get it to work. @@ -26,7 +26,7 @@ class LayoutProcessorPlugin $suburb = [ 'component' => 'Magento_Ui/js/form/element/abstract', 'config' => [ - 'customScope' => 'shippingAddress.custom_attributes', + 'customScope' => 'shippingAddress.custom_attributes', 'customEntry' => null, 'template' => 'ui/form/field', 'elementTmpl' => 'ui/form/element/input', diff --git a/Plugin/ShippingInformationManagement.php b/Plugin/ShippingInformationManagement.php deleted file mode 100644 index 233ed2c00b1f56ca4dff7bc3743133a17f8bedcf..0000000000000000000000000000000000000000 --- a/Plugin/ShippingInformationManagement.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -namespace bobgo\CustomShipping\Plugin; - -use Magento\Quote\Api\CartRepositoryInterface; - -use Magento\Checkout\Api\Data\ShippingInformationInterface; - -/** - * Class ShippingInformationManagement - * @package bobgo\CustomShipping\Plugin - * This class is supposed to copy the suburb attribute from the quote to the order object. - */ -class ShippingInformationManagement -{ - public CartRepositoryInterface $cartRepository; - - public function __construct( - CartRepositoryInterface $cartRepository - ) - { - $this->cartRepository = $cartRepository; - } - - public function beforeSaveAddressInformation($subject, $cartId, ShippingInformationInterface $addressInformation): array - { - $quote = $this->cartRepository->getActive($cartId); - $deliveryNote = $addressInformation->getShippingAddress()->getExtensionAttributes()->getSuburb(); - $quote->setSuburb($deliveryNote); - $this->cartRepository->save($quote); - return [$cartId, $addressInformation]; - } - -} diff --git a/composer.json b/composer.json index 3525313e32b88ffaf3bf9ea1ff69b34157962f65..76742bd4a7f0a11b0de9a1d2606feb1895ef279c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "registration.php" ], "psr-4": { - "bobgo\\CustomShipping\\": "" + "bobgo\\BobGo\\": "" } } } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 4e3d0637a834572d1f65004c1e74a68c18945c93..0d3fa3adc894f9aa28968138ba8856ee6379a46f 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -2,19 +2,15 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> <system> - <tab id="BobGo" translate="label" sortOrder="1"> + <tab id="bobgo" translate="label" sortOrder="2"> <label>Bob Go</label> </tab> - <section id="bobgo_CustomShipping" showInDefault="1"> - <tab>BobGo</tab> + <section id="BobGroup_BobGo" showInDefault="1"> + <tab>bobgo</tab> <label>Settings</label> <resource>Magento_Config::config</resource> <group id="general" showInDefault="1"> <label>Settings</label> - <field id="version" translate="label" type="label" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0"> - <label>Version</label> - <frontend_model>bobgo\CustomShipping\Block\System\Config\Form\Field\Version</frontend_model> - </field> <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Extension enabled</label> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> @@ -22,7 +18,6 @@ </group> </section> -<!-- General Section(Store Information) --> <section id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <group id="store_information" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="suburb" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> @@ -31,17 +26,18 @@ </field> </group> </section> - <!--- End General Section --> -<!--- Delivery Methods Section --> <section id="carriers" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> <group id="bobgo" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Bob Go</label> - + <field id="version" translate="label" type="label" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Version</label> + <frontend_model>BobGroup\BobGo\Block\System\Config\Form\Field\Version</frontend_model> + </field> <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> <label>Show rates for checkout</label> - <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <comment>When this setting is enabled, your customers will be presented with shipping rates at checkout, as configured on the Bob Go platform under Rates at checkout.</comment> + <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> </field> <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Displayed Error Message</label> @@ -65,9 +61,13 @@ <frontend_class>shipping-skip-hide</frontend_class> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> </field> - <field id="unit_of_measure" translate="label" type="select" sortOrder="73" showInDefault="1" showInWebsite="1" canRestore="1"> + <field id="unit_of_measure" translate="label" type="select" sortOrder="73" showInDefault="1" showInWebsite="1"> <label>Weight Unit</label> - <source_model>bobgo\CustomShipping\Model\Source\Unitofmeasure</source_model> + <source_model>BobGroup\BobGo\Model\Source\Unitofmeasure</source_model> + </field> + <field id="max_package_weight" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1"> + <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> + <validate>validate-number validate-zero-or-greater</validate> </field> <field id="additional_info" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1"> <label>Show additional rate information</label> @@ -80,4 +80,3 @@ </system> </config> - diff --git a/etc/config.xml b/etc/config.xml index 6f6b16960b490baddabe19e16a900dfd2fc3fd39..eb34051b8ece8d438e1e19c5dae9a533cd4e25a2 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,21 +1,24 @@ <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> <default> - <bobgo_CustomShipping> + <BobGroup_BobGo> <general> <debug>0</debug> </general> - </bobgo_CustomShipping> + </BobGroup_BobGo> <carriers> <bobgo> <active>0</active> - <sallowspecific>0</sallowspecific> +<!-- <sallowspecific>1</sallowspecific> + <specificcountry>ZA</specificcountry>--> <price>0.00</price> - <model>bobgo\CustomShipping\Model\Carrier\CustomShipping</model> + <model>BobGroup\BobGo\Model\Carrier\BobGo</model> <name>Fixed</name> + <max_package_weight>300</max_package_weight> <title>Bob Go</title> - <specificerrmsg>We could not find any shipping rates for your delivery address. Please make sure your address is correct. If you are experiencing problems, please contact us.</specificerrmsg> </bobgo> + <specificerrmsg>We could not find any shipping rates for your delivery address. Please make sure your address is correct. If you are experiencing problems, please contact us.</specificerrmsg> + </bobgo> </carriers> </default> diff --git a/etc/db_schema.xml b/etc/db_schema.xml deleted file mode 100644 index c4aba785c2ec895a032593a63ffd672795c1a4a5..0000000000000000000000000000000000000000 --- a/etc/db_schema.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0"?> -<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> - <table name="quote" resource="default" engine="innodb"> - <column xsi:type="text" name="suburb" nullable="true" comment="Delivery suburb"/> - <column xsi:type="text" name="service_code" nullable="true" comment="Shipping Service Code"/> - <column xsi:type="text" name="delivery_note" nullable="true" comment="Delivery Note"/> - </table> - <table name="sales_order" resource="default" engine="innodb"> - <column xsi:type="text" name="suburb" nullable="true" comment="Delivery Suburb"/> - <column xsi:type="text" name="service_code" nullable="true" comment="Shipping Service Code"/> - <column xsi:type="text" name="delivery_note" nullable="true" comment="Delivery Note"/> - </table> - <table name="customer_address_entity" resource="default" engine="innodb"> - <column xsi:type="text" name="suburb" nullable="true" comment="Customer Suburb"/> - <column xsi:type="text" name="service_code" nullable="true" comment="Shipping Service Code"/> - <column xsi:type="text" name="delivery_note" nullable="true" comment="Delivery Note"/> - </table> - -</schema> diff --git a/etc/di.xml b/etc/di.xml deleted file mode 100644 index 4f4ee2d8bbfd191d93355cbc58931211a3be53b2..0000000000000000000000000000000000000000 --- a/etc/di.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0"?> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <type name="Magento\Checkout\Model\ShippingInformationManagement"> - <plugin name="get_suburb" - type="bobgo\CustomShipping\Plugin\ShippingInformationManagement" sortOrder="1"/> - </type> -</config> diff --git a/etc/events.xml b/etc/events.xml deleted file mode 100644 index caf07f224582cd023691b1d43ed3d5d5052c75b5..0000000000000000000000000000000000000000 --- a/etc/events.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0"?> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> - <event name="sales_model_service_quote_submit_before"> - <observer name="bobgo_CustomShipping_sales_model_service_quote_submit_before" - instance="bobgo\CustomShipping\Observer\SaveOrderBeforeSalesModelQuote" /> - </event> -</config> diff --git a/etc/fieldset.xml b/etc/fieldset.xml deleted file mode 100644 index 6773bc70b8ef293caf882255dd7587bbb95b966c..0000000000000000000000000000000000000000 --- a/etc/fieldset.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd"> - <scope id="global"> - <fieldset id="sales_convert_quote"> - <field name="suburb"> - <aspect name="to_order" /> - </field> - </fieldset> - </scope> -</config> diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index 61b1ccdd5598615f49d8e63f90f0bbff6a2ccf20..2ee6f54f96f9264b803de3a8dd8f99b923988f76 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,9 +1,9 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Block\Checkout\LayoutProcessor"> - <plugin name="add_custom_field_checkout_shipping_form" type="bobgo\CustomShipping\Plugin\Checkout\Block\LayoutProcessorPlugin" sortOrder="10"/> + <plugin name="add_custom_field_checkout_shipping_form" type="BobGroup\BobGo\Plugin\Checkout\Block\LayoutProcessorPlugin" sortOrder="10"/> <arguments> <argument name="layoutProcessors" xsi:type="array"> - <item name="orderattribute" xsi:type="object">bobgo\CustomShipping\Plugin\Checkout\Block\LayoutProcessorPlugin</item> + <item name="orderattribute" xsi:type="object">BobGroup\BobGo\Plugin\Checkout\Block\LayoutProcessorPlugin</item> </argument> </arguments> </type> diff --git a/etc/module.xml b/etc/module.xml index 9cb1757c8c447dd892545d31c618ed7482cf03aa..d736136edb4535fca984abcd0b7d2b08fed15e6d 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -7,7 +7,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="bobgo_CustomShipping" setup_version="1.0.0"> + <module name="BobGroup_BobGo" setup_version="1.0.0"> <sequence> <module name="Magento_Webapi"/> <module name="Magento_Catalog"/> diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 09ef6059efe59917e951137999e4054f9a615699..02bd9c253e0f562a2e79ec9422e3ab59e1ea1bf1 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -1 +1,24 @@ -"Enabled","Enabled" \ No newline at end of file +"The shipping module is not available.","The shipping module is not available." +"This shipping method is not available. Please specify the zip code.","This shipping method is not available. Please specify the zip code." +BobGo,BobGo +Kilograms,Kilograms +Pounds,Pounds +"For some reason we can't retrieve tracking info right now.","For some reason we can't retrieve tracking info right now." +status,status +"Empty response","Empty response" +None,None +"Expected Delivery:","Expected Delivery:" +"Field ","Field " +" is required."," is required." +"Bob Go","Bob Go" +"Extension enabled","Extension enabled" +Suburb,Suburb +Version,Version +"Show rates for checkout","Show rates for checkout" +"Displayed Error Message","Displayed Error Message" +"Ship to Applicable Countries","Ship to Applicable Countries" +"Ship to Specific Countries","Ship to Specific Countries" +"Show Method if Not Applicable","Show Method if Not Applicable" +"Weight Unit","Weight Unit" +"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)" +"Show additional rate information","Show additional rate information" diff --git a/registration.php b/registration.php index 4c358c2e4db661b29186feaf09f205555534fa69..d8ff5a840e4d2d57e7de9f29ae6764db98a3687f 100644 --- a/registration.php +++ b/registration.php @@ -1,7 +1,6 @@ <?php -// Convention requires Vendor_Extension \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'bobgo_CustomShipping', + 'BobGroup_BobGo', __DIR__ ); diff --git a/view/frontend/layout/checkout_cart_index.xml b/view/frontend/layout/checkout_cart_index.xml index 884a7712c0b183d822204c85f434ee9c250ec4ab..c9b9a3b52a22200f0ed29d37f8e903b658dc6ce6 100644 --- a/view/frontend/layout/checkout_cart_index.xml +++ b/view/frontend/layout/checkout_cart_index.xml @@ -10,7 +10,7 @@ <item name="shipping-rates-validation" xsi:type="array"> <item name="children" xsi:type="array"> <item name="bobgo-rates-validation" xsi:type="array"> - <item name="component" xsi:type="string">bobgo_CustomShipping/js/view/shipping-rates-validation</item> + <item name="component" xsi:type="string">BobGroup_BobGo/js/view/shipping-rates-validation</item> </item> </item> </item> diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 95457b70f16c695dc1869519860fbdb73f1f94a1..225627fcabc840bd2c3a3880e2ddb15eca213600 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -16,7 +16,7 @@ <item name="shipping-rates-validation" xsi:type="array"> <item name="children" xsi:type="array"> <item name="bobgo-rates-validation" xsi:type="array"> - <item name="component" xsi:type="string">bobgo_CustomShipping/js/view/shipping-rates-validation</item> + <item name="component" xsi:type="string">BobGroup_BobGo/js/view/shipping-rates-validation</item> </item> </item> </item> diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js index 471dc742f1a6068b0d02ccbfeba883f771eab8ff..7b5c1d8619b5d2e0331bf42470c44c2005f8b9a1 100644 --- a/view/frontend/requirejs-config.js +++ b/view/frontend/requirejs-config.js @@ -4,7 +4,7 @@ var config = { config: { mixins: { 'Magento_Checkout/js/action/set-shipping-information': { - 'bobgo_CustomShipping/js/action/set-shipping-information-mixin': true + 'BobGroup_BobGo/js/action/set-shipping-information-mixin': true } } } diff --git a/view/frontend/web/js/action/set-shipping-information-mixin.js b/view/frontend/web/js/action/set-shipping-information-mixin.js index b899f21c19c365149aeac59026048b30e3d322fa..85349aad71fafdd3078668e6591fc0cdc8b7957f 100644 --- a/view/frontend/web/js/action/set-shipping-information-mixin.js +++ b/view/frontend/web/js/action/set-shipping-information-mixin.js @@ -14,19 +14,7 @@ define([ if (shippingAddress['extension_attributes'] === undefined) { shippingAddress['extension_attributes'] = {}; } - //This is supposed to be the mixin that adds the suburb to the shipping address, but it doesn't work -/* var attribute = shippingAddress.customAttributes.find( - function (element) { - return element.attribute_code === 'suburb'; - } - ); - - shippingAddress['extension_attributes']['suburb'] = attribute.value; - - shippingAddress['extension_attributes']['suburb'] = shippingAddress.value; - - pass execution to original action ('Magento_Checkout/js/action/set-shipping-information')*/ - //after all the of the above the suburb is still not added to the request payload that goes to CustomShipping.php + // pass execution to original action ('Magento_Checkout/js/action/set-shipping-information') return originalAction(); }); };