magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Coupon code feature is not working properly in the checkout page on Magento 2.4.7

Open TuVanDev opened this issue 1 year ago • 22 comments

Preconditions and environment

  • Magento version: 2.4.7
  • The checkout page only contains "Review & Payments" step as the cart only contains virtual or/and downloadable product types.

Steps to reproduce

Example:

  1. Create a Virtual/Downloadable product.
  2. Navigate to storefront as a guest.
  3. Click “Add to Cart” on the Virtual/Downloadable Product.
  4. Open mini shopping cart and click “Proceed to Checkout”.
  5. Click "Apply Discount Code" text to expand the coupon code form.

Expected result

The discount code/coupon input can be filled in, and the button title text displays as "Apply Discount".

Actual result

The discount code/coupon input is disabled, and the button title text displays as "Cancel coupon". coupon_code_feature_not_working_properly

Additional information

It's important to note that I've tested this issue on Magento 2.4.6 and it didn't occurs.

Release note

No response

Triage and priority

  • [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [X] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

TuVanDev avatar Jun 13 '24 09:06 TuVanDev

Hi @TuVanDev. 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:


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.

m2-assistant[bot] avatar Jun 13 '24 09:06 m2-assistant[bot]

@magento give me 2.4-develop instance

TuVanDev avatar Jun 13 '24 10:06 TuVanDev

Hi @TuVanDev. Thank you for your request. I'm working on Magento instance for you.

Hi @TuVanDev, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

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:

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

m2-assistant[bot] avatar Jun 13 '24 10:06 m2-assistant[bot]

Hi @TuVanDev the file attached is a patch file that seems to resolve the issue. I have looked at Magento develop branch and previous Magento versions and this file has not changed in a while. That means this may not address the root of the issue. However, the patch change is low risk and I hope it may be sufficient to get this problem addressed discount-issue.zip

digitalrisedorset avatar Jun 13 '24 12:06 digitalrisedorset

Hey @digitalrisedorset, thanks for your assist.

Yep, the code isApplied(couponCode() != null); in the file vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js hasn't changes for years. It now has an empty value instead of null. Therefore, isApplied(couponCode() != null); should be changed to isApplied(couponCode() !== '');

I'll try to find the root cause and confirm if this is the best solution for this issue.

FYI, you can post the patch in your comment instead of sharing a zip file for more visibility.

TuVanDev avatar Jun 13 '24 18:06 TuVanDev

the patch file code is:

`diff --git a/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js b/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js index 79e4085..ad3c109 100644 --- a/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js +++ b/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js @@ -21,7 +21,7 @@ define([ if (totals()) { couponCode(totals()['coupon_code']); }

  • isApplied(couponCode() != null);
  • isApplied(couponCode() != '');

    return Component.extend({ defaults: {`

digitalrisedorset avatar Jun 14 '24 07:06 digitalrisedorset

@digitalrisedorset GitHub supports Markdown, so you can use triple backticks. You can check it out at https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

diff --git a/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js b/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js
index 79e4085..ad3c109 100644
--- a/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js
+++ b/vendor/magento/module-sales-rule/view/frontend/web/js/view/payment/discount.js
@@ -21,7 +21,7 @@ define([
     if (totals()) {
         couponCode(totals()['coupon_code']);
     }
-    isApplied(couponCode() != null);
+    isApplied(couponCode() !== '');
 
     return Component.extend({
         defaults: {

However, this will break the feature if the cart contains an item that is not virtual. Therefore, I've investigated and found the root cause of the issue. I'll create a pull request soon!

@magento I am working on this

TuVanDev avatar Jun 14 '24 10:06 TuVanDev

@magento give me 2.4-develop instance

engcom-Dash avatar Jun 17 '24 09:06 engcom-Dash

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

Hi @engcom-Dash, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

Hi @TuVanDev

Thanks for reporting and collaboration.

Verified the issue Magento 2.4 dev instance and the issue is reproducible.

The coupon code feature is not working properly on the checkout page

Steps to reproduce:

  1. Create a Virtual/Downloadable product.
  2. Navigate to storefront as a guest.
  3. Click “Add to Cart” on the Virtual/Downloadable Product.
  4. Open mini shopping cart and click “Proceed to Checkout”.
  5. Click "Apply Discount Code" text to expand the coupon code form.

Please refer the screenshots.

Screenshot 2024-06-17 at 3 24 03 PM

engcom-Dash avatar Jun 17 '24 13:06 engcom-Dash

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12170 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Jun 17 '24 13:06 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-Dash. Thank you for verifying the issue.
Issue Available: @engcom-Dash, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Jun 17 '24 13:06 m2-assistant[bot]

@magento give me 2.4-develop instance

slavvka avatar Jun 17 '24 14:06 slavvka

Hi @slavvka. Thank you for your request. I'm working on Magento instance for you.

Hi @slavvka, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@magento give me 2.4-develop instance

slavvka avatar Jun 17 '24 18:06 slavvka

Hi @slavvka. Thank you for your request. I'm working on Magento instance for you.

Hi @slavvka, here is your Magento Instance: https://9ceeb01fdafc117bec5bf7142b7b61a8.instances-prod.magento-community.engineering Admin access: https://9ceeb01fdafc117bec5bf7142b7b61a8.instances-prod.magento-community.engineering/admin_82b0 Login: 6463eb33 Password: 3b63bd84622c

Hi @TuVanDev,

Internal team has started to work on it”

Thanks.

engcom-Bravo avatar Jun 20 '24 05:06 engcom-Bravo

@hostep Thanks for your contribution!!.

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-12710 by the internal team Related commits: https://github.com/search?q=repo%3Amagento%2Fmagento2+AC+12170&type=commits

Based on the Jira ticket, the target version is 2.4.8-beta1.

Thanks

engcom-Bravo avatar Jul 05 '24 07:07 engcom-Bravo

The link provided above doesn't work, but this one does: https://github.com/search?q=repo%3Amagento%2Fmagento2+AC+12170&type=commits

hostep avatar Jul 05 '24 10:07 hostep