Skip to content
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
4 changes: 4 additions & 0 deletions .jeeves.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ Mygento:
type: varchar
error:
type: boolean
info:
type: boolean
error_message:
type: varchar
info_message:
type: varchar
longitude:
type: varchar
28 changes: 28 additions & 0 deletions Api/Data/CalculateResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ interface CalculateResultInterface extends ExtensibleDataInterface
public const PICKUP_POINTS = 'pickup_points';
public const LATITUDE = 'latitude';
public const ERROR = 'error';
public const INFO = 'info';
public const ERROR_MESSAGE = 'error_message';
public const INFO_MESSAGE = 'info_message';
public const LONGITUDE = 'longitude';

/**
Expand Down Expand Up @@ -197,6 +199,19 @@ public function getError();
*/
public function setError($error);

/**
* Get info
* @return bool|null
*/
public function getInfo();

/**
* Set info
* @param bool $info
* @return $this
*/
public function setInfo($info);

/**
* Get error message
* @return string|null
Expand All @@ -210,6 +225,19 @@ public function getErrorMessage();
*/
public function setErrorMessage($errorMessage);

/**
* Get info message
* @return string|null
*/
public function getInfoMessage();

/**
* Set info message
* @param string $infoMessage
* @return $this
*/
public function setInfoMessage($infoMessage);

/**
* Get longitude
* @return string|null
Expand Down
18 changes: 18 additions & 0 deletions Model/AbstractCarrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function convertCity(RateRequest $request, $mode = MB_CASE_TITLE): string
*/
public function createRateMethod(CalculateResultInterface $method)
{
if ($method->getInfo()) {
return $this->returnInfo($method->getInfoMessage());
}

if ($method->getError()) {
return $this->returnError($method->getErrorMessage());
}
Expand Down Expand Up @@ -225,4 +229,18 @@ protected function getPostCode(RateRequest $request)

return null;
}

/**
* @param string $message
* @return bool|\Magento\Quote\Model\Quote\Address\RateResult\Error
*/
private function returnInfo(string $message)
{
$error = $this->_rateErrorFactory->create();
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$error->setErrorMessage(__($message));

return $error;
}
}
38 changes: 38 additions & 0 deletions Model/Service/CalculateResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,25 @@ public function setError($error)
return $this->setData(self::ERROR, $error);
}

/**
* Get info
* @return bool|null
*/
public function getInfo()
{
return $this->getData(self::INFO);
}

/**
* Set info
* @param bool $info
* @return $this
*/
public function setInfo($info)
{
return $this->setData(self::INFO, $info);
}

/**
* Get error message
* @return string|null
Expand All @@ -296,6 +315,25 @@ public function setErrorMessage($errorMessage)
return $this->setData(self::ERROR_MESSAGE, $errorMessage);
}

/**
* Get info message
* @return string|null
*/
public function getInfoMessage()
{
return $this->getData(self::INFO_MESSAGE);
}

/**
* Set info message
* @param string $infoMessage
* @return $this
*/
public function setInfoMessage($infoMessage)
{
return $this->setData(self::INFO_MESSAGE, $infoMessage);
}

/**
* Get longitude
* @return string|null
Expand Down
1 change: 0 additions & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ grumphp:
warning_severity: 0
xmllint:
phpstan:
autoload_file: 'vendor/mygento/coding-standard/stan/autoload.php'
ignore_patterns: ['Test']
level: 1
Loading