Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v3.2.20 #137

Merged
merged 30 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d8f0ffc
initial opc compatibility
GytisZum Mar 7, 2024
8e16f8c
fixed carrier parameter on ajax call
GytisZum Mar 28, 2024
d824164
whitespace removed
GytisZum Mar 28, 2024
0c61096
DGS-322 getErrLog on null fix
GytisZum Apr 18, 2024
9664a7d
total paid fix
GytisZum May 3, 2024
02a69ab
opc compatibility improvements
GytisZum Jun 3, 2024
0ef1f07
the checkout module compatibility improvements
GytisZum Jun 3, 2024
3d49649
opc improvements and added some styles
GytisZum Jul 3, 2024
2ccea3e
Adding auto indexes
GytisZum Jul 3, 2024
458675d
Automatic license addition applying
GytisZum Jul 3, 2024
583b64f
styling and layout for checkout
Jul 3, 2024
4a9116d
Automatic license addition applying
justelis22 Jul 3, 2024
a9b70ed
onepagecheckout ps module compatibility fixes
GytisZum Jul 4, 2024
453f0c6
comment edited
GytisZum Jul 4, 2024
f8b3463
fixed onepagecheckout ps dropdown
GytisZum Jul 5, 2024
2355086
Automatic license addition applying
GytisZum Jul 5, 2024
1aab047
changed hardcoded value
GytisZum Jul 5, 2024
a5c4bcc
Merge branch 'opcps-module-fixes' of github.com:Invertus/dpdbaltics17…
GytisZum Jul 5, 2024
4903690
css changes to change input order
Jul 5, 2024
14def08
Merge pull request #136 from Invertus/opc-input-layout
justelis22 Jul 5, 2024
12311d4
Merge pull request #135 from Invertus/opcps-module-fixes
justelis22 Jul 5, 2024
1588837
Merge pull request #134 from Invertus/opc-styling-layout
GytisZum Jul 5, 2024
28a0728
version bump and changelog added
GytisZum Jul 5, 2024
b28eb40
Merge pull request #125 from Invertus/DGS-313/onepagecheckout-compati…
GytisZum Jul 11, 2024
dac1632
Merge pull request #130 from Invertus/DGS-332/error-fix
GytisZum Jul 11, 2024
74847d5
Merge pull request #128 from Invertus/DGS-298/carrier-parameter-fix
GytisZum Jul 11, 2024
fddb1ba
Merge pull request #133 from Invertus/DGS-328/totla-paid-fix
GytisZum Jul 11, 2024
329e02d
Release v3.2.20 beta (#89) (#90)
GytisZum Aug 2, 2024
451b359
changelog updated
GytisZum Aug 2, 2024
834d62b
Merge branch 'main' into release-v3.2.20
GytisZum Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading