Skip to content

Commit

Permalink
Merge pull request #68 from logeecom/feature/check-drop-off-flag
Browse files Browse the repository at this point in the history
Release version 3.3.5
  • Loading branch information
vytautasdagilis authored Jan 31, 2022
2 parents 18b588c + 5d4c03f commit bbca8d4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [3.3.5](https://github.com/packlink-dev/ecommerce_module_core/compare/v3.3.4...v3.3.5) - 2021-01-31
### Added
- Added a new configuration flag that specifies whether a given integration supports drop-off carriers or not. The default will be `true` and only integrations that do not support drop-off carriers should set this flag to `false`.
### Changed
- Fixed a frontend issue when adding/editing a shipping service on the module configuration page.

## [3.3.4](https://github.com/packlink-dev/ecommerce_module_core/compare/v3.3.3...v3.3.4) - 2021-11-30
### Changed
- Updated the mechanism for fetching controller URLs on the frontend views.
Expand Down
10 changes: 10 additions & 0 deletions src/BusinessLogic/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public function setMaxTaskAge($maxAge)
$this->saveConfigValue('maxTaskAge', $maxAge);
}

/**
* Determines whether the drop-off shipping services are system supported.
*
* @return bool
*/
public function dropOffShippingServicesSupported()
{
return true;
}

/**
* Returns web-hook callback URL for current system.
*
Expand Down
27 changes: 27 additions & 0 deletions src/BusinessLogic/Http/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ public function getShippingServicesDeliveryDetails(ShippingServiceSearch $params

$shippingDetails = ShippingServiceDetails::fromBatch($body);

if (!$this->configService->dropOffShippingServicesSupported()) {
return $this->getShippingServicesDeliveryDetailsWithoutDropOffServices($shippingDetails, $params);
}

foreach ($shippingDetails as $shippingDetail) {
$shippingDetail->departureCountry = $params->fromCountry;
$shippingDetail->destinationCountry = $params->toCountry;
Expand Down Expand Up @@ -440,6 +444,29 @@ public function sendAnalytics($eventName)
}
}

/**
* @param $shippingDetails
* @param $params
* @return array
*/
protected function getShippingServicesDeliveryDetailsWithoutDropOffServices($shippingDetails, $params)
{
$newShippingDetails = array();

foreach ($shippingDetails as $shippingDetail) {
if ($shippingDetail->destinationDropOff) {
continue;
} else {
$shippingDetail->departureCountry = $params->fromCountry;
$shippingDetail->destinationCountry = $params->toCountry;
$shippingDetail->national = $params->toCountry === $params->fromCountry;
$newShippingDetails[] = $shippingDetail;
}
}

return $newShippingDetails;
}

/**
* Calls shipments endpoint and handles response. Any shipment endpoint can return 404 so this call handles that.
*
Expand Down
12 changes: 8 additions & 4 deletions src/BusinessLogic/Resources/js/EditServiceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,20 @@ if (!window.Packlink) {
}

for (let systemId in pricePolicyControllers) {
let fieldName = pricePolicyControllers[systemId].getExcludedFieldForValidation();
if (fieldName !== null) {
excludedElementNames.push(fieldName);
if (pricePolicyControllers.hasOwnProperty(systemId)) {
let fieldName = pricePolicyControllers[systemId].getExcludedFieldForValidation();
if (fieldName !== null) {
excludedElementNames.push(fieldName);
}
}
}

if (validationService.validateForm(form, excludedElementNames) && validateMiconfiguredPolicies()) {
let pricingPolicies = [];
for (let systemId in pricePolicyControllers) {
pricingPolicies = pricingPolicies.concat(pricePolicyControllers[systemId].getSystemPricingPolicies());
if (pricePolicyControllers.hasOwnProperty(systemId)) {
pricingPolicies = pricingPolicies.concat(pricePolicyControllers[systemId].getSystemPricingPolicies());
}
}

serviceModel.activated = true;
Expand Down

0 comments on commit bbca8d4

Please sign in to comment.