Closed ioweb-gr closed 5 months ago
Hi @ioweb-gr. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release@magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
@magento give me 2.4.6-p4 instance
Hi @ioweb-gr. Thank you for your request. I'm working on Magento instance for you.
Hi @ioweb-gr, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.
Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Issue: Confirmed
once verification is complete. Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Hi @ioweb-gr
Thanks for reporting and collaboration.
Verified the issue on magento 2.4 dev instance but the issue is not reproducable.
The coupon is applied succesfully on both cart and checkout.
Steps to reproduce:
Please refer the screenrecording.
Uploading 38746-1 (1).mov…
@engcom-Dash I cannot see the video, the attached screen recording is broken. Can you please show me the cart rule settings? From your description of the problem I can see that the rule isn't exactly what I've shown. The product needs to also belong to a specific category. Please confirm that the rules are correct.
I also have a problem deploying an instance for 2.4.6 p4 with magento bot.
@magento give me 2.4-develop instance
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Dash, here is your Magento Instance: https://c6939cdbaf717e2e390d09bcff2162b3.instances-prod.magento-community.engineering Admin access: https://c6939cdbaf717e2e390d09bcff2162b3.instances-prod.magento-community.engineering/admin_3fae Login: 4986b2ea Password: 1c049f5c53bb
Hi @ioweb-gr
Verified the issue again in magneto 2.4 dev instance. But the issue is not reproducable.
Able to apply the coupon code in both cart and checkout page
The rule has manufacturer and product belonging to a specific category.
Please refer the attached screenshots and recording.
https://github.com/magento/magento2/assets/60198592/dae32933-5328-4d9c-8d08-3f5c81df9b40
Hi @engcom-Dash ,
you've added two products but they are the same product and the rule is applicable to both of them. You need to add one product where the rule is applicable and another where the rule isn't. So the first product should be with manufacturer M1 and the rule is applied, and the second with manufacturer M2 and the rule isn't valid for this product.
While trying to debug this I notice it fails here
/**
* Validate coupon code.
*
* @param \Magento\Quote\Model\Quote $quote
* @return $this
*/
protected function _validateCouponCode(\Magento\Quote\Model\Quote $quote)
{
$code = $quote->getData('coupon_code');
if ($code !== null && strlen($code)) {
$addressHasCoupon = false;
$addresses = $quote->getAllAddresses();
if (count($addresses) > 0) {
foreach ($addresses as $address) {
if ($address->hasCouponCode()) {
$addressHasCoupon = true;
}
}
if (!$addressHasCoupon) {
$quote->setCouponCode('');
}
}
}
return $this;
}
While validating the code it's trying to check both shipping / billing address to verify if the coupon code is set. However, the coupon code is only set in the quote earlier
\Magento\Quote\Model\CouponManagement::set
try {
$quote->setCouponCode($couponCode);
$this->quoteRepository->save($quote->collectTotals());
} catch (LocalizedException $e) {
throw new CouldNotSaveException(__('The coupon code couldn\'t be applied: ' .$e->getMessage()), $e);
} catch (\Exception $e) {
throw new CouldNotSaveException(
__("The coupon code couldn't be applied. Verify the coupon code and try again."),
$e
);
}
So basically I'm assuming that the $quote->setCouponCode($couponCode);
should also trigger setting the coupon code into the address itself. But it doesn't
Could you point me to where the coupon code should be set in the address to see why it's not being set?
@magento give me 2.4.7 instance
Hi @ioweb-gr. Thank you for your request. I'm working on Magento instance for you.
@magento give me 2.4-develop instance
Hi @ioweb-gr. Thank you for your request. I'm working on Magento instance for you.
Hi @ioweb-gr, here is your Magento Instance: https://7857dcfddb63bdcae5c6a22ded0862ab.instances-prod.magento-community.engineering Admin access: https://7857dcfddb63bdcae5c6a22ded0862ab.instances-prod.magento-community.engineering/admin_7cb0 Login: c1622ff9 Password: 08cf0d872131
Hi @ioweb-gr, here is your Magento Instance: https://c6939cdbaf717e2e390d09bcff2162b3.instances-prod.magento-community.engineering Admin access: https://c6939cdbaf717e2e390d09bcff2162b3.instances-prod.magento-community.engineering/admin_9849 Login: f37e119c Password: c48e2e68f223
OK we found the culprit. There was a free shipping rule above X amount. When adding the two products, the free shipping rule was activating and preventing subsequent rules processing. Moreover, this was not enforced on cart but only on checkout hence the confusion.
After upgrading to 2.4.7 to test our instance, this difference was eliminated and our coupon was not applying in both cart and checkout which was correct due to the settings on the free shipping rule.
So there is an actual problem in 2.4.6-p4 where this use case causes mismatch but it's solved in 2.4.7.
We can safely close this issue
Preconditions and environment
Steps to reproduce
Expected result
The coupon is properly applied
Actual result
The coupon is not applied
Additional information
No response
Release note
No response
Triage and priority