Skip to content

Commit

Permalink
the checkout module compatibility improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
GytisZum committed Jun 3, 2024
2 parents 02a69ab + 1b5e6ff commit 0ef1f07
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 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
38 changes: 17 additions & 21 deletions dpdbaltics.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/


use Invertus\dpdBaltics\Grid\Row\PrintAccessibilityChecker;
use Invertus\dpdBaltics\Builder\Template\Front\CarrierOptionsBuilder;
use Invertus\dpdBaltics\Config\Config;
Expand Down Expand Up @@ -92,7 +91,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 @@ -183,30 +182,27 @@ public function hookActionFrontControllerSetMedia()
);
}

//todo for onepagecheckoutps module these are needed to be included as it handles phone number
// onepageps module controller is like in normal prestashop OrderController and some test are needed with normal flow
// if (in_array($currentController, $onePageCheckoutControllers, true)) {
$this->context->controller->addJqueryPlugin('chosen');
if (in_array($currentController, $onePageCheckoutControllers, true) || Tools::getValue('module') === 'thecheckout') {
$this->context->controller->addJqueryPlugin('chosen');

$this->context->controller->registerJavascript(
'dpdbaltics-opc',
'modules/' . $this->name . '/views/js/front/order-opc.js',
[
'position' => 'bottom',
'priority' => 130
]
);

$this->context->controller->registerJavascript(
'dpdbaltics-supercheckout',
'modules/' . $this->name . '/views/js/front/modules/supercheckout.js',
[
$this->context->controller->registerJavascript(
'dpdbaltics-opc',
'modules/' . $this->name . '/views/js/front/order-opc.js',
[
'position' => 'bottom',
'priority' => 130
]
);
);

// }
$this->context->controller->registerJavascript(
'dpdbaltics-supercheckout',
'modules/' . $this->name . '/views/js/front/modules/supercheckout.js',
[
'position' => 'bottom',
'priority' => 130
]
);
}

/** @var \Invertus\dpdBaltics\Provider\CurrentCountryProvider $currentCountryProvider */
$currentCountryProvider = $this->getModuleContainer('invertus.dpdbaltics.provider.current_country_provider');
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
2 changes: 1 addition & 1 deletion src/Repository/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function findProductByProductReference($carrierReference)
* @return array|bool|mysqli_result|PDOStatement|resource|null
* @throws PrestaShopDatabaseException
*/
public function checkIfCarrierIsAvailableInCountry(int $carrierReference, int $countryId)
public function checkIfCarrierIsAvailableInCountry($carrierReference, $countryId)
{
$productId = $this->getProductIdByCarrierReference($carrierReference);
$product = new DPDProduct($productId);
Expand Down
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 0ef1f07

Please sign in to comment.