magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

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

Closed TuVanDev closed 2 months ago

TuVanDev commented 3 months ago

Preconditions and environment

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

m2-assistant[bot] commented 3 months ago

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:

TuVanDev commented 3 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 months ago

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

magento-deployment-service[bot] commented 3 months ago

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

m2-assistant[bot] commented 3 months ago

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:


digitalrisedorset commented 3 months ago

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

TuVanDev commented 3 months ago

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.

digitalrisedorset commented 3 months ago

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']); }

TuVanDev commented 3 months ago

@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

engcom-Dash commented 3 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 months ago

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

magento-deployment-service[bot] commented 3 months ago

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

engcom-Dash commented 3 months ago

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
github-jira-sync-bot commented 3 months ago

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

m2-assistant[bot] commented 3 months ago

: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.

slavvka commented 3 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 months ago

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

magento-deployment-service[bot] commented 3 months ago

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

slavvka commented 3 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 months ago

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

magento-deployment-service[bot] commented 3 months ago

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

engcom-Bravo commented 3 months ago

Hi @TuVanDev,

Internal team has started to work on it”

Thanks.

hostep commented 2 months ago

Probably fixed by AC:12170 :: Coupon code feature is not working properly in the checkout page on Magento 2.4.7?

engcom-Bravo commented 2 months ago

@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

hostep commented 2 months ago

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