From 0b24c1ae4301806da3781021f5a238ae2c873a28 Mon Sep 17 00:00:00 2001 From: Gytautas Zumaras <96050852+GytisZum@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:24:17 +0300 Subject: [PATCH] Release v3.2.20 (#93) * initial opc compatibility * fixed carrier parameter on ajax call * whitespace removed * DGS-322 getErrLog on null fix * total paid fix * 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 * changelog updated --------- Co-authored-by: GytisZum Co-authored-by: Justas Vaitkus Co-authored-by: justelis22 Co-authored-by: justelis22 <103486043+justelis22@users.noreply.github.com> --- CHANGELOG.md | 4 +++- dpdbaltics.php | 8 ++++---- src/Service/ShipmentService.php | 6 ++---- views/js/front/pudo-search.js | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d821b8e..d1f964d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -167,4 +167,6 @@ - Numeric post code improvements ## [3.2.20] -- One page checkout compatibility improvements \ No newline at end of file +- One page checkout compatibility improvements +- Multiple payment transaction and total price fix +- Carriers error handling improvements \ No newline at end of file diff --git a/dpdbaltics.php b/dpdbaltics.php index 812579f..7654451 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -1123,7 +1123,7 @@ public function printLabel($idShipment) if ($parcelPrintResponse->getStatus() === Config::API_SUCCESS_STATUS) { $this->updateOrderCarrier($idShipment); - return; + return $parcelPrintResponse; } return $parcelPrintResponse; @@ -1140,7 +1140,7 @@ public function printMultipleLabels($shipmentIds) foreach ($shipmentIds as $shipmentId) { $this->updateOrderCarrier($shipmentId); } - return; + return $parcelPrintResponse; } return $parcelPrintResponse; @@ -1381,7 +1381,7 @@ private function handleLabelPrintService() return; } - if (!empty($parcelPrintResponse->getErrLog())) { + if (isset($parcelPrintResponse) && !empty($parcelPrintResponse->getErrLog())) { Context::getContext()->controller->errors[] = $parcelPrintResponse->getErrLog(); } @@ -1406,7 +1406,7 @@ private function handleLabelPrintService() return; } - if (!empty($parcelPrintResponse->getErrLog())) { + if (isset($parcelPrintResponse) && !empty($parcelPrintResponse->getErrLog())) { Context::getContext()->controller->errors[] = $parcelPrintResponse->getErrLog(); } diff --git a/src/Service/ShipmentService.php b/src/Service/ShipmentService.php index ffe9dcc..fdcac7b 100644 --- a/src/Service/ShipmentService.php +++ b/src/Service/ShipmentService.php @@ -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) { diff --git a/views/js/front/pudo-search.js b/views/js/front/pudo-search.js index ee43983..ef907e6 100644 --- a/views/js/front/pudo-search.js +++ b/views/js/front/pudo-search.js @@ -36,7 +36,11 @@ $(document).ready(function () { $(document).on('keyup', 'input[name="dpd-street"]', function () { var city = $('select[name="dpd-city"]').val(); var street = $('input[name="dpd-street"]').val(); - updateParcelBlock(city, street); + var selectedCarrier = $('select[name="dpd-city"]').closest('.dpd-pudo-container'); + + var idCarrier = selectedCarrier.attr('data-id'); + + updateParcelBlock(city, street, idCarrier); }); if ($('.dpd-checkout-pickup-container').is(':visible')) { @@ -75,12 +79,7 @@ $( document ).ajaxComplete(function( event, request, settings ) { }); function updateStreetSelect(city) { - - var $this = $(this); - var $pudoId = $this.data('id'); - var $container = $this.closest('.dpd-pudo-container'); - var $submitInput = $container.find('input[name="dpd-pudo-id"]'); - var $idReference = $container.data('id'); + var $container = $(this).closest('.dpd-pudo-container'); $.ajax(dpdHookAjaxUrl, { type: 'POST', @@ -152,13 +151,14 @@ function saveSelectedStreet(city, street) { }); } -function updateParcelBlock(city, street) { +function updateParcelBlock(city, street, idCarrier) { $.ajax(dpdHookAjaxUrl, { type: 'POST', data: { 'ajax': 1, 'city': city, 'street': street, + 'id_carrier': idCarrier, 'action': 'updateParcelBlock', 'token': typeof prestashop !== 'undefined' ? prestashop.static_token : '' },