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.5k stars 9.3k forks source link

Coupon with Fixed amount discount for whole cart apply rule not working in graphql #30719

Closed rani-priya closed 2 years ago

rani-priya commented 3 years ago

Preconditions (*)

  1. Magento version: 2.4
  2. php version : 7.3

Steps to reproduce (*)

  1. Go to magento backend

  2. create a cart price rule with this configuration(In Apply set "Fixed amount discount for whole cart") image

  3. Then apply the same coupon on cart in by using graphql

  4. In cart query check the grand total amount image image

Expected result (*)

  1. Discount should be deducted from the grand total in cart query graphql

Actual result (*)

  1. Discount is not deducting from the grand total in cart query graphql

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 3 years ago

Hi @rani-webkul. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


: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, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

bharat1811 commented 3 years ago

@magento I am working on this.

m2-assistant[bot] commented 3 years ago

Hi @bharat1811! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

bharat1811 commented 3 years ago

@magento add to contributors team

m2-assistant[bot] commented 3 years ago

Hi @bharat1811! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

bharat1811 commented 3 years ago

@magento I am working on this.

bharat1811 commented 3 years ago

@magento give me 2.4-develop instance

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

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

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

Hi @bharat1811, here is your Magento Instance: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering Admin access: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering/admin_1440 Login: 254116b9 Password: 5f7f638c1c5c

bharat1811 commented 3 years ago

@rani-webkul The issue is not reproducible in the latest version.

Issue: not reproducible

Steps to verify,

1. Get customer cart details, { customerCart { id items { id product { name sku } quantity } } }

2. Apply created promo code, mutation { applyCouponToCart( input: { cart_id: "HvzaWRCngNlChASgYZkP6kF5SpeufPcv" coupon_code: "FLAT10" } ) { cart { applied_coupons { code } } } }

3. Get cart details, { cart(cart_id: "HvzaWRCngNlChASgYZkP6kF5SpeufPcv") { email telephone billing_address { city country { code label } firstname lastname postcode region { code label } street telephone } shipping_addresses { firstname lastname street city region { code label } country { code label } available_shipping_methods { amount { currency value } available carrier_code carrier_title error_message method_code method_title price_excl_tax { value currency } price_incl_tax { value currency } } selected_shipping_method { amount { value currency } carrier_code carrier_title method_code method_title } } items { id product { name sku } quantity } available_payment_methods { code title } selected_payment_method { code title } applied_coupons { code } prices { subtotal_including_tax{ value currency }, discount{ amount{ value } } grand_total { value currency } } } }

rani-priya commented 3 years ago

@magento give me 2.4-develop instance

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

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

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

Hi @rani-webkul, here is your Magento Instance: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering Admin access: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering/admin_82fb Login: fb61d152 Password: abc997a2d2c6

rani-priya commented 3 years ago

@bharat1811 it's still reproduceable on upper instance as well. Please use below cart query and then check { cart(cart_id: "l2X1hXV1PBgtdtMZMTseGWsVQzEcVpAi") { email billing_address { city country { code label } firstname lastname postcode region { code label region_id } street telephone } shipping_addresses { firstname lastname street city region { code label region_id } country { code label } telephone available_shipping_methods { amount { currency value } available carrier_code carrier_title error_message method_code method_title price_excl_tax { value currency } price_incl_tax { value currency } } selected_shipping_method { amount { value currency } carrier_code carrier_title method_code method_title } } items { id prices { row_total{ value } row_total_including_tax { value } total_item_discount { value } price { value } discounts { label amount { value } } } ... on SimpleCartItem { customizable_options { label values { value } } } ... on ConfigurableCartItem { configurable_options { id option_label value_id value_label } } ... on BundleCartItem { bundle_options { id label type values { id label price quantity } } } product { name sku stock_status price_range{ minimum_price{ regular_price{ value currency } } maximum_price{ regular_price{ value currency } } } image { url label } ... on BundleProduct { dynamic_sku dynamic_price items { option_id title required type position sku options { id quantity position is_default price label product { id name sku image { url label } typename } } } } ... on CustomizableProductInterface { options { title required sort_order option_id typename ... on CustomizableDropDownOption { title value { price_type option_type_id title price sku } } } } ... on ConfigurableProduct { configurable_options { id label position use_default attribute_id attribute_code values { value_index label } product_id } variants { product { id name sku stock_status attribute_set_id ... on PhysicalProductInterface { weight } price_range{ minimum_price{ regular_price{ value currency } } } } attributes { label code value_index } } } crosssell_products { name sku price_range { minimum_price { regular_price { value currency } final_price { value currency }
discount { amount_off percent_off } } maximum_price { regular_price { value currency } final_price { value currency }
discount { amount_off percent_off }
} } image { url label } } } quantity } available_payment_methods { code title } selected_payment_method { code title } applied_coupons { code } prices { discounts { amount { value } label } grand_total{ value currency } subtotal_including_tax{ value currency } subtotal_excluding_tax{ value currency } subtotal_with_discount_excluding_tax{ value currency } applied_taxes{ amount { value currency } label } } } }

image image

rani-priya commented 3 years ago

@magento give me 2.4-develop instance

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

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

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

Hi @rani-webkul, here is your Magento Instance: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering Admin access: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering/admin_fdd7 Login: d35d23aa Password: 9f1a2d144b16

sathiyaaa commented 3 years ago

@magento I am working on this

sathiyaaa commented 3 years ago

@magento give me 2.4-develop instance

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

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

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

Hi @sathiyaaa, here is your Magento Instance: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering Admin access: https://fe87be1a7cb1187e050f71ad653096dc-2-4-develop.instances.magento-community.engineering/admin_86b5 Login: 88c9b072 Password: b1da997f8ec8

atishgoswami commented 3 years ago

Thanks @rani-webkul for reporting this issue, I was also facing the same issue

This is the patch for the issue if anyone else might be looking for it 😄 https://github.com/magento/quality-patches/blob/master/patches/os/MDVA-31363__fixes_cart_price_rule_coupon_does_not_apply_via_graphQl__2.4.0.patch

mariuscris commented 3 years ago

Thank you @atishgoswami for the patch link. I have the same issue and I have tried to fix it with this patch:

--- a/vendor/magento/module-sales-rule/Model/Rule/Action/Discount/CartFixed.php
+++ b/vendor/magento/module-sales-rule/Model/Rule/Action/Discount/CartFixed.php
@@ -96,7 +96,7 @@
         if (!isset($cartRules[$rule->getId()])) {
             $cartRules[$rule->getId()] = $rule->getDiscountAmount();
         }
-        $availableDiscountAmount = (float) $cartRules[$rule->getId()];
+        $availableDiscountAmount = (float) $rule->getDiscountAmount();
         $discountType = self::$discountType . $rule->getId();

I believe the main problem is linked with\Magento\SalesRule\Model\Rule\Action\Discount\CartFixed and how the calculate method was build. The purpose of getCartFixedRules' on quote is very confusing for me. I see this data linked with multi-shipping and "allow shipping discount" option. In my case, I use discount for the whole cart without shipping and no multi-shipping.

The issue described in https://github.com/magento/magento2/issues/31496 is most likely connected with this problem. For the moment I will use both fixes, just in case the reset case is missing or forgotten.

pykettk commented 3 years ago

+1 for the solution from @mariuscris - worked for me! 😃

JKair commented 3 years ago

I meet this bug too.

riconeitzel commented 2 years ago

Confirmed that https://github.com/magento/magento2/issues/30719#issuecomment-778826680 fixes the problem for us on 2.3.7-p2 in the regular checkout.

@mariuscris you have a typo in your comment ";;"

mariuscris commented 2 years ago

Thanks @riconeitzel for spotting the typo. It should be corrected by now

ithunter0428 commented 2 years ago

Hi, I have an issue with cart Cart Price Rules. If I make a new rule, it only apply to last product in cart. Can anyone explain about it?

m2-assistant[bot] commented 2 years ago

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:

m2-assistant[bot] commented 2 years ago

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

engcom-November commented 2 years ago

Hi @rani-priya Verified the issue on Magento 2.4-develop instance with query mentioned in comment and as per devdocs as well but the issue is not reproducible. Grand total is displayed after discount. Kindly recheck the issue on Magento 2.4-develop branch and provide missing steps if any if the issue is still reproducible. image

image

engcom-November commented 2 years ago

Hi @rani-priya , We are closing this issue as there has been no latest update on the same. Kindly reopen / create new issue if you are still facing any issues. Thank you.

engcom-Alfa commented 1 year ago

Hey all

as per discussion with the internal team confirming the ticket.