-
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
add coupon code to totals model #32797
Conversation
Hi @SilinMykola. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
1 similar comment
@magento run all tests |
Hi @SilinMykola, thank you for your contribution! |
e429790
to
2df5978
Compare
@magento run all tests |
@magento run Functional Tests CE, Functional Tests EE, Functional Tests B2B |
@magento run Integration Tests |
@@ -6,7 +6,7 @@ | |||
namespace Magento\Sales\Block\Order; | |||
|
|||
use Magento\Sales\Model\Order; | |||
|
|||
use Magento\Sales\Model\Order\Invoice; |
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
use Magento\Sales\Model\Order\Invoice; | |
use Magento\Sales\Model\Order\Invoice; | |
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.
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.
Hi @SilinMykola
Thank you for your work. Please, check my comment below.
if ($this->getSource() instanceof Invoice) { | ||
$discountSource = $this->getSource()->getOrder(); | ||
} else { | ||
$discountSource = $this->getSource(); | ||
} | ||
if ($this->getSource()->getCouponCode()) { | ||
$discountLabel = __('Discount (%1)', $discountSource->getCouponCode()); |
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.
As I see from the suggested solution, the coupon code description will not be shown anymore, but it was expected to be shown. In other words, this solution replaces coupon code description with its code. It is not correct from the user experience.
It is also impossible to change the $discountLabel
text because this class is an @api
(BIC change).
I can suggest to implement something like this:
$discountLabel = $this->getSource()->getDiscountDescription()
? __('Discount (%1)', $source->getDiscountDescription())
: __('Discount (%1)', $source->getCouponCode());
With this, we will have a coupon code or description in the Discount line. And not the BIC change.
45bf54c
to
d84562b
Compare
Hi @SilinMykola, |
Hi @coderimus, yes, I need help with this issue. I think about where I should create the settings in admin panel to choose what to show in "totals" (coupon description, coupon code or both) and how to split description in a few strings. |
Hi @sivaschenko |
Description (*)
I changed \Magento\Sales\Block\Order\Totals class to add Coupon Code to order.total block
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)