Skip to content

Commit

Permalink
Merge pull request #474 from myparcelnl/Exception-total-weight-digita…
Browse files Browse the repository at this point in the history
…l-stamp

Fix: message for total weight digital stamp
  • Loading branch information
RichardPerdaan authored Aug 21, 2019
2 parents b300022 + 485bfd0 commit 18c719c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public function setApiKey($apiKey)

/**
* @return int
* @throws \Mage_Core_Model_Store_Exception
*/
public function getStoreId()
{
Expand Down Expand Up @@ -293,7 +294,7 @@ protected function _setRequestParameters($requestString, $requestType, $requestH
$header[] = $requestHeader . 'charset=utf-8';
$header[] = 'Authorization: basic ' . base64_encode($this->apiKey);
$header[] = 'User-Agent:'. $this->_getUserAgent();

$this->requestHeader = $header;

return $this;
Expand Down Expand Up @@ -454,6 +455,7 @@ public function sendRequest($method = 'POST', $checkConfig = true)
* @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
*
* @return $this
* @throws \TIG_MyParcel2014_Exception
*/
public function createConsignmentRequest(TIG_MyParcel2014_Model_Shipment $myParcelShipment)
{
Expand Down Expand Up @@ -797,13 +799,14 @@ protected function _getConsignmentData(TIG_MyParcel2014_Model_Shipment $myParcel
}
unset($data['options']['delivery_date']);
unset($data['options']['weight']);
}
// throw Exception when the weight of the digital stamp is more than 2000 grams
if ($WeightData['total_weight'] > $myParcelShipment::WEIGHT_DIGITAL_STAMP){
throw new TIG_MyParcel2014_Exception(
$helper->__('The total weight of the order is more than 2000 grams and can not be sent with a digital stamp.'),
'MYPA-0028'
);

// Throw Exception when the weight of the digital stamp is more than 2000 grams
if ($WeightData['total_weight'] > $myParcelShipment::WEIGHT_DIGITAL_STAMP){
throw new TIG_MyParcel2014_Exception(
$helper->__('The total weight of the order is more than 2000 grams and can not be sent with a digital stamp.'),
'MYPA-0028'
);
}
}

if ($WeightData['total_weight']){
Expand Down

0 comments on commit 18c719c

Please sign in to comment.