File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
app/code/Magento/Sales/Model/Order/Creditmemo/Total Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class Discount extends AbstractTotal
1010 /**
1111 * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
1212 * @return $this
13+ * @throws \Magento\Framework\Exception\LocalizedException
1314 */
1415 public function collect (\Magento \Sales \Model \Order \Creditmemo $ creditmemo )
1516 {
@@ -26,6 +27,16 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
2627 * basing on how much shipping should be refunded.
2728 */
2829 $ baseShippingAmount = $ this ->getBaseShippingAmount ($ creditmemo );
30+
31+ /**
32+ * If credit memo's shipping amount is set and Order's shipping amount is 0,
33+ * throw exception with differente message
34+ */
35+ if ( $ baseShippingAmount && $ order ->getBaseShippingAmount () <= 0 ) {
36+ throw new \Magento \Framework \Exception \LocalizedException (
37+ new \Magento \Framework \Phrase ("You can not refund shipping if there is no shipping amount. " ,[])
38+ );
39+ }
2940 if ($ baseShippingAmount ) {
3041 $ baseShippingDiscount = $ baseShippingAmount *
3142 $ order ->getBaseShippingDiscountAmount () /
You can’t perform that action at this time.
0 commit comments