Skip to content

Commit

Permalink
Release v3.2.20 beta (#89) (#90)
Browse files Browse the repository at this point in the history
* initial opc compatibility

* opc compatibility improvements

* opc improvements and added some styles

* Adding auto indexes

* Automatic license addition applying

* styling and layout for checkout

* Automatic license addition applying

* onepagecheckout ps module compatibility fixes

* comment edited

* fixed onepagecheckout ps dropdown

* Automatic license addition applying

* changed hardcoded value

* css changes to change input order

* version bump and changelog added

---------

Co-authored-by: GytisZum <[email protected]>
Co-authored-by: Justas Vaitkus <[email protected]>
Co-authored-by: justelis22 <[email protected]>
Co-authored-by: justelis22 <[email protected]>
  • Loading branch information
5 people authored Aug 2, 2024
1 parent 0a2c744 commit 329e02d
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 23 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,7 @@
- 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
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'
33 changes: 28 additions & 5 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
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
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;
}
11 changes: 6 additions & 5 deletions views/css/front/order-input.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This file is generated by `grunt build`, do not edit it by hand.
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
width: 100% !important;
width: 100%;
max-width: 100%;
}

Expand Down Expand Up @@ -84,7 +84,7 @@ This file is generated by `grunt build`, do not edit it by hand.
margin: 1px 0;
padding: 4px 20px 4px 5px;
width: 100%;
height: auto;
height: 49px;
outline: 0;
border: 1px solid #aaa;
background: url("../../img/dpd-chosen-front.png") no-repeat 100% -20px;
Expand Down Expand Up @@ -178,11 +178,12 @@ This file is generated by `grunt build`, do not edit it by hand.
margin-right: 20px;
text-overflow: ellipsis;
white-space: nowrap;
padding: 13px 0;
padding: 16px 0;
}

.chosen-container-single a.chosen-single {
height: auto;
min-height: 49px;
height: 100%;
}

.chosen-container-single .chosen-single div {
Expand All @@ -203,7 +204,7 @@ div.form-control-chosen:focus-within {
.css-dpd-phone-prefix .chosen-single:before {
content: '+';
position: absolute;
transform: translate(-12px, 12px);
transform: translate(-12px, 16px);
}

.dpd-input-wrapper .form-control,
Expand Down
6 changes: 5 additions & 1 deletion views/css/front/pudo-shipment.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
.phone-block-hr,
.delivery-time-hr
{
padding-bottom: 2rem;
padding-bottom: 0;
}


Expand Down Expand Up @@ -244,3 +244,7 @@ a.chosen-single:hover {
width: 100%;
}

.dpd-delivery-time-block {
margin-top: 1rem;
}

Loading

0 comments on commit 329e02d

Please sign in to comment.