Skip to content

Commit

Permalink
Added option for 'unspecified' delivery type (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrii <[email protected]>
  • Loading branch information
chaikovskyia and chaikovskyia authored Feb 16, 2024
1 parent e7b3ad5 commit a520063
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Api/Data/ShippingMethodInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ interface ShippingMethodInterface
*/
const DELIVERY_METHOD_PICKUP = 'pick_up';

/*
* Unspecified
*/
const DELIVERY_METHOD_UNSPECIFIED = 'unspecified';

/*
* None
*/
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

v1.7.14
- Added option to allow selection of 'unspecified' delivery method

v1.7.13
- Session update logic when coupon code changes re-worked.

Expand Down
19 changes: 19 additions & 0 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class Config extends AbstractHelper
*/
const XPATH_PICKUP_METHODS = 'payment/dintero/shipping_methods_map';

/*
* Shipping methods map
*/
const XPATH_UNSPECIFIED_METHODS = 'payment/dintero/unspecified_methods_map';

/*
* Default callback delay in seconds
*/
Expand Down Expand Up @@ -604,4 +609,18 @@ public function getPickupMethods($scopeCode = null)
$this->scopeConfig->getValue(self::XPATH_PICKUP_METHODS, ScopeInterface::SCOPE_STORE, $scopeCode)
);
}

/**
* Retrieve pickup methods list
*
* @param string $scopeCode
* @return array
*/
public function getUnspecifiedMethods($scopeCode = null)
{
return explode(
',',
$this->scopeConfig->getValue(self::XPATH_UNSPECIFIED_METHODS, ScopeInterface::SCOPE_STORE, $scopeCode)
);
}
}
2 changes: 1 addition & 1 deletion Model/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private function initRequest($endpoint, $token = null)
'Dintero-System-Name' => __('Magento'),
'Dintero-System-Version' => $this->getSystemMeta()->getVersion(),
'Dintero-System-Plugin-Name' => 'Dintero.Checkout.Magento.V2',
'Dintero-System-Plugin-Version' => '1.7.13',
'Dintero-System-Plugin-Version' => '1.7.14',
];

if ($token && $token instanceof Token) {
Expand Down
11 changes: 9 additions & 2 deletions Model/ShippingCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,15 @@ public function __construct(
*/
protected function resolveDeliveryType($shippingMethod, $scopeCode = null)
{
return in_array($shippingMethod, $this->configHelper->getPickupMethods($scopeCode))
? ShippingMethodInterface::DELIVERY_METHOD_PICKUP : ShippingMethodInterface::DELIVERY_METHOD_DELIVERY;
if(in_array($shippingMethod, $this->configHelper->getPickupMethods($scopeCode))) {
return ShippingMethodInterface::DELIVERY_METHOD_PICKUP;
}

if (in_array($shippingMethod, $this->configHelper->getUnspecifiedMethods($scopeCode))) {
return ShippingMethodInterface::DELIVERY_METHOD_UNSPECIFIED;
}

return ShippingMethodInterface::DELIVERY_METHOD_DELIVERY;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions Model/Source/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public function toOptionArray()
continue;
}



$options[] = [
'label' => $carrier->getConfigData('title'),
'value' => $carrier->getCarrierCode(),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"Dintero\\Checkout\\": ""
}
},
"version": "1.7.13"
"version": "1.7.14"
}
8 changes: 7 additions & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@
<field id="shipping_methods_map" type="multiselect" translate="label" sortOrder="150" showInDefault="1" showInWebsite="1">
<label>Shipping Methods Mapping</label>
<source_model>Dintero\Checkout\Model\Source\Carrier</source_model>
<can_be_empty>1</can_be_empty>
</field>
<field id="debug" translate="label" type="select" sortOrder="150" showInDefault="1" showInWebsite="1">
<field id="unspecified_methods_map" type="multiselect" translate="label" sortOrder="160" showInDefault="1" showInWebsite="1">
<label>Unspecified Methods</label>
<source_model>Dintero\Checkout\Model\Source\Carrier</source_model>
<can_be_empty>1</can_be_empty>
</field>
<field id="debug" translate="label" type="select" sortOrder="160" showInDefault="1" showInWebsite="1">
<label>Debug Mode</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<attribute type="shared">1</attribute>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Dintero_Checkout" setup_version="1.7.13">
<module name="Dintero_Checkout" setup_version="1.7.14">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Checkout"/>
Expand Down

0 comments on commit a520063

Please sign in to comment.