Skip to content

Commit

Permalink
Merge pull request #126 from Invertus/release_3.2.19
Browse files Browse the repository at this point in the history
Release 3.2.19
  • Loading branch information
GytisZum authored Apr 18, 2024
2 parents b531e34 + 82eeaa8 commit 8d90295
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,9 @@
- Ability to hide label print feature in orders list page
- Vulnerability fix with development dependencies
- Price rule bug fix to add additional filtration by country

## [3.2.19]
- Carrier availability in country
- Phone input selections sorted by active countries in shop
- Work hours pop up fix
- Numeric post code improvements
16 changes: 10 additions & 6 deletions dpdbaltics.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct()
$this->author = 'Invertus';
$this->tab = 'shipping_logistics';
$this->description = 'DPD Baltics shipping integration';
$this->version = '3.2.18';
$this->version = '3.2.19';
$this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_];
$this->need_instance = 0;
parent::__construct();
Expand Down Expand Up @@ -203,7 +203,6 @@ public function hookActionFrontControllerSetMedia()
'priority' => 130
]
);

}

/** @var \Invertus\dpdBaltics\Provider\CurrentCountryProvider $currentCountryProvider */
Expand Down Expand Up @@ -278,7 +277,8 @@ public function hookActionFrontControllerSetMedia()
$googleApiService = $this->getModuleContainer('invertus.dpdbaltics.service.google_api_service');
$this->context->controller->registerJavascript(
'dpdbaltics-google-api',
$googleApiService->getFormattedGoogleMapsUrl(), [
$googleApiService->getFormattedGoogleMapsUrl(),
[
'server' => 'remote'
]
);
Expand Down Expand Up @@ -475,6 +475,11 @@ public function getOrderShippingCostExternal($cart)
return false;
}

if (!$productRepo->checkIfCarrierIsAvailableInCountry((int) $carrier->id_reference, (int) $deliveryAddress->id_country)
) {
return false;
}

try {
$isCarrierAvailableInShop = $productRepo->checkIfCarrierIsAvailableInShop($carrier->id_reference, $this->context->shop->id);
if (empty($isCarrierAvailableInShop)) {
Expand Down Expand Up @@ -502,7 +507,7 @@ public function getOrderShippingCostExternal($cart)
$parcelDistribution = \Configuration::get(Config::PARCEL_DISTRIBUTION);
$maxAllowedWeight = Config::getDefaultServiceWeights($countryCode, $serviceCarrier['product_reference']);

if (!$cartWeightValidator->validate($cart, $parcelDistribution ,$maxAllowedWeight)) {
if (!$cartWeightValidator->validate($cart, $parcelDistribution, $maxAllowedWeight)) {
return false;
}

Expand Down Expand Up @@ -1145,7 +1150,6 @@ private function updateOrderCarrier($shipmentId)

public function hookDisplayOrderDetail($params)
{

$isReturnServiceEnabled = Configuration::get(Config::PARCEL_RETURN);
if (!$isReturnServiceEnabled) {
return;
Expand Down Expand Up @@ -1274,7 +1278,7 @@ public function hookActionOrderGridDefinitionModifier(array $params)
$definition = $params['definition'];

if (!(bool) Configuration::get(Config::HIDE_ORDERS_LABEL_PRINT_BUTTON)) {
$definition->getColumns()
$definition->getColumns()
->addAfter(
'date_add',
(new ActionColumn('dpd_print_label'))
Expand Down
2 changes: 2 additions & 0 deletions src/Repository/PhonePrefixRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public function getCallPrefixesFrontOffice()
$query = new DbQuery();
$query->select('c.`call_prefix`');
$query->from('country', 'c');
$query->where('active=1');

$resource = Db::getInstance()->query($query);
$result = [];
while ($row = Db::getInstance()->nextRow($resource)) {
Expand Down
38 changes: 38 additions & 0 deletions src/Repository/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,42 @@ public function findProductByProductReference($carrierReference)

return $this->db->getRow($query) ?: null;
}

/**
* @param int $carrierReference
* @param int $countryId
*
* @return array|bool|mysqli_result|PDOStatement|resource|null
* @throws PrestaShopDatabaseException
*/
public function checkIfCarrierIsAvailableInCountry($carrierReference, $countryId)
{
$productId = $this->getProductIdByCarrierReference($carrierReference);
$product = new DPDProduct($productId);

if ($product->all_zones) {
return ['id_dpd_product' => $productId];
}

$query = new DbQuery();
$query->select('dp.id_dpd_product');
$query->from('dpd_product', 'dp');

$query->leftJoin(
'dpd_product_zone',
'dpz',
'dp.`id_dpd_product` = dpz.`id_dpd_product`'
);

$query->leftJoin(
'dpd_zone_range',
'dzr',
'dzr.`id_dpd_zone` = dpz.`id_dpd_zone`'
);

$query->where('dp.id_reference= '.(int) $product->id_reference);
$query->where('dzr.id_country = '.(int) $countryId);

return $this->db->executeS($query);
}
}
5 changes: 3 additions & 2 deletions src/Repository/ZoneRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Address;
use Country;
use DbQuery;
use Invertus\dpdBaltics\Validate\Zone\ZoneRangeValidate;
use PrestaShopDatabaseException;

class ZoneRepository extends AbstractEntityRepository
Expand Down Expand Up @@ -101,14 +102,14 @@ public function addProductZonesFromArray(array $zones)
public function findZoneInRangeByAddress(Address $address)
{
$idCountry = $address->id_country ?: (int)\Configuration::get('PS_COUNTRY_DEFAULT');
$zipCode = $address->postcode;
$zipCode = ZoneRangeValidate::getNumericZipCode($address->postcode, $idCountry);

$query = new DbQuery();
$query->select('dz.id_dpd_zone');
$query->from('dpd_zone', 'dz');
$query->leftJoin('dpd_zone_range', 'dzr', 'dzr.id_dpd_zone = dz.id_dpd_zone');
$query->where('dzr.id_country = ' . (int)$idCountry);
$query->where('dzr.include_all_zip_codes = 1 OR (dzr.zip_code_from <= \'' . pSQL($zipCode) . '\' AND dzr.zip_code_to >= \'' . pSQL($zipCode) . '\')');
$query->where('dzr.include_all_zip_codes = 1 OR (dzr.zip_code_from_numeric <= \'' . pSQL($zipCode) . '\' AND dzr.zip_code_to_numeric >= \'' . pSQL($zipCode) . '\')');

$result = $this->db->executeS($query);

Expand Down
2 changes: 1 addition & 1 deletion views/js/front/pudo-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function saveSelectedStreet(city, street) {
var coordinates = response.coordinates;
var $idReference = $parent.data('id');
$('.points-container').empty().append(response.template);

reselectDataPopover();
initMap(coordinates, true, response.selectedPudoId, false, $idReference);
isPudoPointSelected = true;
}
Expand Down

0 comments on commit 8d90295

Please sign in to comment.