From 50a6b89239e0b99810cfd7e70def691fe770f805 Mon Sep 17 00:00:00 2001 From: reindertvetter Date: Mon, 17 Oct 2016 11:31:41 +0200 Subject: [PATCH 1/5] save and show browser data --- .../Block/Adminhtml/Sales/Order/View/ShippingInfo.php | 7 +++++-- .../TIG/MyParcel2014/Model/Observer/SavePgAddress.php | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/View/ShippingInfo.php b/app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/View/ShippingInfo.php index 9734976c..63ffa70b 100755 --- a/app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/View/ShippingInfo.php +++ b/app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/View/ShippingInfo.php @@ -73,7 +73,7 @@ public function getCheckoutOptionsHtml() if ($pgAddress && $this->_helper->shippingMethodIsPakjegemak($shippingMethod)) { - if($data){ + if(key_exists('location', $data)){ $dateTime = date('d-m-Y H:i', strtotime($data['date'] . ' ' . $data['start_time'])); $html .= $this->__('PostNL location:') . ' ' . $dateTime; if($data['price_comment'] != 'retail') @@ -90,7 +90,7 @@ public function getCheckoutOptionsHtml() if($totalWeight !== false){ $html .= $this->_helper->getPackageType($totalWeight, $this->_order->getShippingAddress()->getCountryId(), true) . ' '; - if($data){ + if(key_exists('date', $data)){ $dateTime = date('d-m-Y H:i', strtotime($data['date']. ' ' . $data['time'][0]['start'])); $html .= $this->__('deliver:') .' ' . $dateTime; @@ -106,6 +106,9 @@ public function getCheckoutOptionsHtml() } } + if (key_exists('browser', $data)) + $html = ' '.$html.''; + return $html !== false ? '
' . $html : '' ; } diff --git a/app/code/community/TIG/MyParcel2014/Model/Observer/SavePgAddress.php b/app/code/community/TIG/MyParcel2014/Model/Observer/SavePgAddress.php index b77ea733..b38ffe79 100755 --- a/app/code/community/TIG/MyParcel2014/Model/Observer/SavePgAddress.php +++ b/app/code/community/TIG/MyParcel2014/Model/Observer/SavePgAddress.php @@ -117,15 +117,17 @@ public function copyAddressToOrder(Varien_Event_Observer $observer) * Set myparcel json data from checkout */ $myParcelData = $quote->getMyparcelData(); - $order->setMyparcelData($myParcelData); + $myParcelData = $myParcelData == null ? [] : json_decode($myParcelData, true); + $myParcelData['browser'] = $_SERVER['HTTP_USER_AGENT']; + $order->setMyparcelData(json_encode($myParcelData)); - if(json_decode($myParcelData) === null && json_decode($myParcelData)->location === null){ + if(key_exists('location', $myParcelData)){ Mage::getModel('tig_myparcel/checkout_service')->removePgAddress($quote); return $this; } $order->setShippingMethod('myparcel_pakjegemak'); - $aMyParcelData = json_decode($myParcelData, true); + $aMyParcelData = $myParcelData; if (key_exists('date', $aMyParcelData)) { $dateTime = strtotime($aMyParcelData['date'] . ' 00:00:00'); $dropOffDate = $helper->getDropOffDay($dateTime); From 3446bc0ac4682b01c0cb126a2ae0c108eed31283 Mon Sep 17 00:00:00 2001 From: reindertvetter Date: Mon, 17 Oct 2016 11:38:16 +0200 Subject: [PATCH 2/5] remove address lines --- .../TIG/MyParcel2014/Helper/AddressValidation.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php b/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php index 72543d68..97400749 100755 --- a/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php +++ b/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php @@ -135,6 +135,7 @@ public function getQuoteAddress(Mage_Sales_Model_Quote $quote) ) { $address['full_street'] = $quote->getBillingAddress()->getStreetFull(); if($address['full_street']){ + $this->removeAddressLines($address['full_street']); $address['type'] = 'billing'; $address['country'] = $quote->getBillingAddress()->getCountry(); $address['postal_code'] = $quote->getBillingAddress()->getPostcode(); @@ -148,6 +149,7 @@ public function getQuoteAddress(Mage_Sales_Model_Quote $quote) } else { $address['full_street'] = $quote->getShippingAddress()->getStreetFull(); if($address['full_street']){ + $this->removeAddressLines($address['full_street']); $address['type'] = 'shipping'; $address['country'] = $quote->getShippingAddress()->getCountry(); $address['postal_code'] = $quote->getShippingAddress()->getPostcode(); @@ -167,6 +169,7 @@ public function getQuoteAddress(Mage_Sales_Model_Quote $quote) $address['country'] = $tmpAddress->getCountry(); $address['postal_code'] = $tmpAddress->getPostcode(); $address['full_street'] = $tmpAddress->getStreetFull(); + $this->removeAddressLines($address['full_street']); if (!preg_match('/[0-9]/', $address['full_street'])) { return false; } @@ -175,8 +178,17 @@ public function getQuoteAddress(Mage_Sales_Model_Quote $quote) $address['number'] = $streetData['housenumber']; } } - $address['full_street'] = preg_replace("/[\n\r]/", " ", $address['full_street']); return $address; } + + /** + * Remove address lines when address has multiple rows + * + * @param $street + */ + private function removeAddressLines(&$street){ + + $street = preg_replace("/[\n\r]/", " ", $street); + } } From df0557b05ee270bf19c4a4a7ff615f1ec00b6912 Mon Sep 17 00:00:00 2001 From: reindertvetter Date: Mon, 17 Oct 2016 11:41:11 +0200 Subject: [PATCH 3/5] typo --- .../community/TIG/MyParcel2014/Helper/AddressValidation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php b/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php index 97400749..b39db03a 100755 --- a/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php +++ b/app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php @@ -183,7 +183,7 @@ public function getQuoteAddress(Mage_Sales_Model_Quote $quote) } /** - * Remove address lines when address has multiple rows + * Remove multiple rows. For example, if the house number on a different row. * * @param $street */ From 36928e95c8b132886b8deeca944858bdc4d80481 Mon Sep 17 00:00:00 2001 From: reindertvetter Date: Mon, 17 Oct 2016 11:44:59 +0200 Subject: [PATCH 4/5] Set version 1.7.13 --- app/code/community/TIG/MyParcel2014/etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/TIG/MyParcel2014/etc/config.xml b/app/code/community/TIG/MyParcel2014/etc/config.xml index bc56318f..60d2bde9 100755 --- a/app/code/community/TIG/MyParcel2014/etc/config.xml +++ b/app/code/community/TIG/MyParcel2014/etc/config.xml @@ -1,7 +1,7 @@ - 1.7.12 + 1.7.13 From 2c7aa9dff321c474b1e5fccbf9d978c7164f6490 Mon Sep 17 00:00:00 2001 From: reindertvetter Date: Mon, 17 Oct 2016 12:19:01 +0200 Subject: [PATCH 5/5] fix key signed from data --- app/code/community/TIG/MyParcel2014/Helper/Data.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/community/TIG/MyParcel2014/Helper/Data.php b/app/code/community/TIG/MyParcel2014/Helper/Data.php index ff320ddc..33d25f9e 100755 --- a/app/code/community/TIG/MyParcel2014/Helper/Data.php +++ b/app/code/community/TIG/MyParcel2014/Helper/Data.php @@ -1155,18 +1155,18 @@ public function calculatePrice() } if( - $data['home_address_only'] === true && + key_exists('home_address_only', $data) && $priceComment != 'night' && $priceComment != 'morning' && - $data['signed'] === true && + key_exists('signed', $data) && $this->getConfig('signature_and_only_recipient', 'delivery') > 0 ) { $price += (float)$this->getConfig('signature_and_only_recipient', 'delivery'); } else { - if ($data['home_address_only'] === true && $priceComment != 'night' && $priceComment != 'morning') + if (key_exists('home_address_only', $data) && $priceComment != 'night' && $priceComment != 'morning') $price += (float)$this->getConfig('only_recipient_fee', 'delivery'); - if ($data['signed'] === true) + if (key_exists('signed', $data)) $price += (float)$this->getConfig('signature_fee', 'delivery'); } } else {