Skip to content

Commit

Permalink
Merge pull request #183 from myparcelnl/show-browser-settings
Browse files Browse the repository at this point in the history
Show browser settings
  • Loading branch information
Reindert authored Oct 17, 2016
2 parents b3e2910 + df0557b commit b74e093
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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;

Expand All @@ -106,6 +106,9 @@ public function getCheckoutOptionsHtml()
}
}

if (key_exists('browser', $data))
$html = ' <span title="'.$data['browser'].'"">'.$html.'</span>';

return $html !== false ? '<br>' . $html : '' ;
}

Expand Down
14 changes: 13 additions & 1 deletion app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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;
}
Expand All @@ -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 multiple rows. For example, if the house number on a different row.
*
* @param $street
*/
private function removeAddressLines(&$street){

$street = preg_replace("/[\n\r]/", " ", $street);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b74e093

Please sign in to comment.