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

onepagecheckout ps module compatibility fixes #135

Merged
merged 8 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion dpdbaltics.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ public function hookActionFrontControllerSetMedia()
'priority' => 130
]
);

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

/** @var \Invertus\dpdBaltics\Provider\CurrentCountryProvider $currentCountryProvider */
Expand Down Expand Up @@ -272,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
8 changes: 7 additions & 1 deletion views/css/front/onepagecheckout.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
}

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

.carrier-extra-content .chosen-select {
Expand All @@ -60,4 +61,9 @@

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

.search-block-container {
padding-left: 15px;
padding-right: 15px;
}
22 changes: 20 additions & 2 deletions views/js/front/order-opc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
var isPudoPointSelected = false;
var phoneQuerySelectors = [
'#checkout #delivery-address [name="phone"]',
'.address-fields input[name="phone"]',
'#checkout [name="delivery_phone_mobile"]'
];

$(document).ready(function (){

$(document).on('change', '.dpd-phone-block', function() {
Expand Down Expand Up @@ -51,9 +57,19 @@ function handlePhoneNumber(selector)
if (!$('.dpd-phone-block')) {
return true;
}

var phone = selector.find('input[name="dpd-phone"]').val();
var phoneArea = selector.find('select[name="dpd-phone-area"] option:selected').val();

// if empty then take it from opc phone field
if (phone === '') {
phoneQuerySelectors.forEach(function (phoneSelector) {
if ($(phoneSelector).val()) {
phone = $(phoneSelector).val();
}
});
}

if (currentController === 'supercheckout') {
saveSelectedPhoneNumberSuperCheckout(phone, phoneArea)
} else {
Expand Down Expand Up @@ -95,8 +111,10 @@ function DPDdisplayMessageOpc(parent, template) {

// Module "onepagecheckoutps" compatibility
$(document).on('opc-load-review:completed', function() {
$('.delivery-option.selected .carrier-extra-content').show();
handlePhoneNumber($('.dpd-phone-block'));
});


// Then address is being modified
$(document).on('thecheckout_Address_Modified', function () {
handlePhoneNumber($('.dpd-phone-block'));
});
2 changes: 1 addition & 1 deletion views/js/front/pudo.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ $(document).ready(function () {
}

//Js to open extra content failed from theme, doing it manually.
if (params.deliveryOption.length > 0 && !$(params.deliveryOption).next('.carrier-extra-content').is(':visible')) {
if (params.deliveryOption.length > 0 && !$(params.deliveryOption).next('.carrier-extra-content').is(':visible') && !dpdbaltics.isOnePageCheckout) {
$('.carrier-extra-content').hide();
$(params.deliveryOption).next('.carrier-extra-content').slideDown();
}
Expand Down
6 changes: 3 additions & 3 deletions views/templates/hook/front/partials/pudo-search-block.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

<div class="search-block-container">
{if count($city_list) > 1}
<div class="col-xl-6 col-lg-6 col-sm-12 dpd-city-block dpd-select-wrapper dpd-input-wrapper">
<div class="{if !($isOpcCheckout)}col-xl-6 col-lg-6 col-sm-12 {/if}dpd-city-block dpd-select-wrapper dpd-input-wrapper">
<select name="dpd-city" class="form-control-chosen chosen-select">
{else}
<div class="col-xl-0 col-lg-0 col-sm-12 dpd-city-block dpd-select-wrapper">
<div class="{if !($isOpcCheckout)}col-xl-0 col-lg-0 col-sm-12 {/if}dpd-city-block dpd-select-wrapper">
<select name="dpd-city" style="display: none">
{/if}
{if !empty($city_list)}
Expand All @@ -40,7 +40,7 @@
</div>
</div>

<div class="col-xl-6 col-lg-6 col-sm-12 dpd-city-block dpd-input-wrapper js-pudo-search-street">
<div class="{if !($isOpcCheckout)}col-xl-6 col-lg-6 col-sm-12 {/if}dpd-city-block dpd-input-wrapper js-pudo-search-street">
{include file='module:dpdbaltics/views/templates/hook/front/partials/pudo-search-street.tpl'}
</div>
</div>
Loading