Skip to content

Commit

Permalink
Merge pull request #137 from Invertus/release-v3.2.20
Browse files Browse the repository at this point in the history
Release v3.2.20
  • Loading branch information
MarijusCoding authored Dec 17, 2024
2 parents 1b5e6ff + 834d62b commit 1f64d79
Show file tree
Hide file tree
Showing 18 changed files with 264 additions and 39 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,9 @@
- Carrier availability in country
- Phone input selections sorted by active countries in shop
- Work hours pop up fix
- Numeric post code improvements
- Numeric post code improvements

## [3.2.20]
- One page checkout compatibility improvements
- Multiple payment transaction and total price fix
- Carriers error handling improvements
1 change: 1 addition & 0 deletions config/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- '@invertus.dpdbaltics.orm.entity_manager'
- '@invertus.dpdbaltics.repository.phone_prefix_repository'
- '@invertus.dpdbaltics.repository.order_repository'
- '@invertus.dpdbaltics.validator.opc_module_compatibility_validator'

invertus.dpdbaltics.service.carrier.update_carrier_service:
class: 'Invertus\dpdBaltics\Service\Carrier\UpdateCarrierService'
Expand Down
3 changes: 3 additions & 0 deletions config/validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ services:
arguments:
- '@dpdbaltics'
- '@invertus.dpdbaltics.repository.phone_repository'

invertus.dpdbaltics.validator.opc_module_compatibility_validator:
class: 'Invertus\dpdBaltics\Validate\Compatibility\OpcModuleCompatibilityValidator'
41 changes: 32 additions & 9 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.19';
$this->version = '3.2.20';
$this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_];
$this->need_instance = 0;
parent::__construct();
Expand Down Expand Up @@ -168,7 +167,7 @@ public function getModuleContainer($id = false)
public function hookActionFrontControllerSetMedia()
{
//TODO fillup this array when more modules are compatible with OPC
$onePageCheckoutControllers = ['supercheckout'];
$onePageCheckoutControllers = ['supercheckout', 'onepagecheckoutps', 'thecheckout'];
$applicableControlelrs = ['order', 'order-opc', 'ShipmentReturn', 'supercheckout'];
$currentController = !empty($this->context->controller->php_self) ? $this->context->controller->php_self : Tools::getValue('controller');

Expand All @@ -183,7 +182,10 @@ public function hookActionFrontControllerSetMedia()
);
}

if (in_array($currentController, $onePageCheckoutControllers, true)) {
/** @var \Invertus\dpdBaltics\Validate\Compatibility\OpcModuleCompatibilityValidator $opcModuleCompatibilityValidator */
$opcModuleCompatibilityValidator = $this->getModuleContainer('invertus.dpdbaltics.validator.opc_module_compatibility_validator');

if (in_array($currentController, $onePageCheckoutControllers, true) || $opcModuleCompatibilityValidator->isOpcModuleInUse()) {
$this->context->controller->addJqueryPlugin('chosen');

$this->context->controller->registerJavascript(
Expand All @@ -198,11 +200,26 @@ public function hookActionFrontControllerSetMedia()
$this->context->controller->registerJavascript(
'dpdbaltics-supercheckout',
'modules/' . $this->name . '/views/js/front/modules/supercheckout.js',
[
'position' => 'bottom',
'priority' => 130
]
);

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

Media::addJsDef([
'dpdbaltics' => [
'isOnePageCheckout' => $opcModuleCompatibilityValidator->isOpcModuleInUse()
]
]);
}

/** @var \Invertus\dpdBaltics\Provider\CurrentCountryProvider $currentCountryProvider */
Expand Down Expand Up @@ -261,7 +278,7 @@ public function hookActionFrontControllerSetMedia()
'dpdLockerMarkerPath' => $this->getPathUri() . 'views/img/locker.png',
'dpdHookAjaxUrl' => $this->context->link->getModuleLink($this->name, 'Ajax'),
'pudoSelectSuccess' => $this->l('Pick-up point selected'),
'dpd_carrier_ids' => $carrierIds
'dpd_carrier_ids' => $carrierIds,
]);

$this->context->controller->registerStylesheet(
Expand Down Expand Up @@ -348,6 +365,12 @@ public function hookActionValidateStepComplete(&$params)
return;
}
}

//NOTE: thecheckout triggers this hook without phone parameters the phone is saved with ajax request
if (Tools::getValue('module') === 'thecheckout') {
return;
}

if (!Tools::getValue('dpd-phone')) {
$this->context->controller->errors[] =
$this->l('In order to use DPD Carrier you need to enter phone number');
Expand Down Expand Up @@ -1100,7 +1123,7 @@ public function printLabel($idShipment)

if ($parcelPrintResponse->getStatus() === Config::API_SUCCESS_STATUS) {
$this->updateOrderCarrier($idShipment);
return;
return $parcelPrintResponse;
}

return $parcelPrintResponse;
Expand All @@ -1117,7 +1140,7 @@ public function printMultipleLabels($shipmentIds)
foreach ($shipmentIds as $shipmentId) {
$this->updateOrderCarrier($shipmentId);
}
return;
return $parcelPrintResponse;
}

return $parcelPrintResponse;
Expand Down Expand Up @@ -1358,7 +1381,7 @@ private function handleLabelPrintService()
return;
}

if (!empty($parcelPrintResponse->getErrLog())) {
if (isset($parcelPrintResponse) && !empty($parcelPrintResponse->getErrLog())) {
Context::getContext()->controller->errors[] = $parcelPrintResponse->getErrLog();
}

Expand All @@ -1383,7 +1406,7 @@ private function handleLabelPrintService()
return;
}

if (!empty($parcelPrintResponse->getErrLog())) {
if (isset($parcelPrintResponse) && !empty($parcelPrintResponse->getErrLog())) {
Context::getContext()->controller->errors[] = $parcelPrintResponse->getErrLog();
}

Expand Down
3 changes: 3 additions & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ class Config

const COUNTRY_ISO_CODES_WITH_MIXED_CHARACTERS = ['IE', 'GB', 'NL'];

// NOTE: Add OPC module tech name if payment option is compatible
public const DPD_OPC_MODULE_LIST = ['onepagecheckoutps', 'supercheckout', 'thecheckout'];

const PRODUCT_NAME_B2B = [
'LT' => 'Pristatymas privatiems asmenims',
'EE' => 'DPD kuller',
Expand Down
10 changes: 9 additions & 1 deletion src/Service/CarrierPhoneService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Invertus\dpdBaltics\Repository\PhonePrefixRepository;
use Invertus\dpdBaltics\Config\Config;
use DPDOrderPhone;
use Invertus\dpdBaltics\Validate\Compatibility\OpcModuleCompatibilityValidator;

class CarrierPhoneService
{
Expand All @@ -45,19 +46,25 @@ class CarrierPhoneService
* @var OrderRepository
*/
private $orderRepository;
/**
* @var OpcModuleCompatibilityValidator
*/
private $opcModuleCompatibilityValidator;

public function __construct(
DPDBaltics $module,
Context $context,
EntityManager $entityManager,
PhonePrefixRepository $phonePrefixRepository,
OrderRepository $orderRepository
OrderRepository $orderRepository,
OpcModuleCompatibilityValidator $opcModuleCompatibilityValidator
) {
$this->module = $module;
$this->context = $context;
$this->entityManager = $entityManager;
$this->phonePrefixRepository = $phonePrefixRepository;
$this->orderRepository = $orderRepository;
$this->opcModuleCompatibilityValidator = $opcModuleCompatibilityValidator;
}

public function getCarrierPhoneTemplate($cartId, $carrierReference)
Expand Down Expand Up @@ -94,6 +101,7 @@ public function getCarrierPhoneTemplate($cartId, $carrierReference)
'dpdPhoneArea' => $phoneData['mobile_phone_code_list'],
'contextPrefix' => Config::PHONE_CODE_PREFIX . $phonePrefix,
'isAbove177' => Config::isPrestashopVersionAbove177(),
'isOpcCheckout' => $this->opcModuleCompatibilityValidator->isOpcModuleInUse(),
]
);

Expand Down
6 changes: 2 additions & 4 deletions src/Service/ShipmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,14 @@ public function createShipmentFromOrder(Order $order)
private function createNonDistributedShipment(Order $order, $idProduct, $isTestMode)
{
$products = $order->getProducts();
$parcelPrice = 0;
$parcelPrice = $order->getTotalPaid();
$parcelWeight = 0;
$orderShippingCost = $order->total_shipping_tax_incl ?: 0;

foreach ($products as $product) {
$parcelPrice += $this->calculateProductsPrice($product);
$parcelWeight += $product['weight'] * $product['product_quantity'];
}

$parcelPrice = $this->calculateParcelPriceWithOrderDiscount($order, $parcelPrice);
$parcelPrice += $orderShippingCost;
$shipment = $this->createShipment($order, $idProduct, $isTestMode, 1, $parcelWeight, $parcelPrice);

if (!$shipment->id) {
Expand Down
44 changes: 44 additions & 0 deletions src/Validate/Compatibility/OpcModuleCompatibilityValidator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/


namespace Invertus\dpdBaltics\Validate\Compatibility;

use DPDBaltics;
use Invertus\dpdBaltics\Config\Config;
use Invertus\dpdBaltics\Exception\DpdCarrierException;
use Invertus\dpdBaltics\Repository\PhoneRepository;
use Invertus\dpdBaltics\Util\NumberUtility;
use Invertus\dpdBaltics\Util\StringUtility;
use Module;

class OpcModuleCompatibilityValidator
{
public function isOpcModuleInUse(): bool
{
foreach (Config::DPD_OPC_MODULE_LIST as $opcModule){
if (Module::isInstalled($opcModule) && Module::isEnabled($opcModule)) {
return true;
}
}

return false;
}
}
30 changes: 30 additions & 0 deletions src/Validate/Compatibility/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/


header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
69 changes: 69 additions & 0 deletions views/css/front/onepagecheckout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
#phone-block-wrapper {
display: flex;
flex-direction: column;
}

.points-container .list-inline .row {
margin-left: 15px;
margin-right: 15px;
}

.panel-body .points-container .dpd-services-block {
width: 100%;
}

.panel-body .points-container {
width: 340px;
margin-left: 18px;
}

.dpd-services-block .list-inline-item {
min-width: 370px;
}

.carrier-extra-content {
display: flex;
flex-direction: column;
padding: 10px 5px;
}

.dpd-phone-block {
padding-bottom: 0;
}

.chosen-container {
width: 100% !important;
max-width: 290px;
}

.carrier-extra-content .chosen-select {
min-height: 49px;
height: 100%;
}

.dpd-checkout-delivery-time--container {
width: 100%;
}

.search-block-container {
padding-left: 15px;
padding-right: 15px;
}
Loading

0 comments on commit 1f64d79

Please sign in to comment.