-
Notifications
You must be signed in to change notification settings - Fork 9.4k
add coupon code to totals model #32797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| namespace Magento\Sales\Block\Order; | ||
|
|
||
| use Magento\Sales\Model\Order; | ||
| use Magento\Sales\Model\Order\Invoice; | ||
|
|
||
| /** | ||
| * Order totals. | ||
|
|
@@ -126,16 +127,21 @@ protected function _initTotals() | |
| * Add discount | ||
| */ | ||
| if ((double)$this->getSource()->getDiscountAmount() != 0) { | ||
| if ($this->getSource()->getDiscountDescription()) { | ||
| $discountLabel = __('Discount (%1)', $source->getDiscountDescription()); | ||
| if ($this->getSource() instanceof Invoice) { | ||
| $discountSource = $this->getSource()->getOrder(); | ||
| } else { | ||
| $discountSource = $this->getSource(); | ||
| } | ||
| if ($this->getSource()->getCouponCode()) { | ||
| $discountLabel = __('Discount (%1)', $discountSource->getCouponCode()); | ||
|
||
| } else { | ||
| $discountLabel = __('Discount'); | ||
| } | ||
| $this->_totals['discount'] = new \Magento\Framework\DataObject( | ||
| [ | ||
| 'code' => 'discount', | ||
| 'field' => 'discount_amount', | ||
| 'value' => $source->getDiscountAmount(), | ||
| 'value' => $discountSource->getDiscountAmount(), | ||
| 'label' => $discountLabel, | ||
| ] | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @SilinMykola
Thank you for your contribution;
Please don't forget to keep an empty string after imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @andrewbess
Thanks for your reviewing, I fixed your remark.