Navigation Menu

Skip to content
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

Can't Cancel Order #19230

Closed
friendscottn opened this issue Nov 15, 2018 · 29 comments
Closed

Can't Cancel Order #19230

friendscottn opened this issue Nov 15, 2018 · 29 comments
Assignees
Labels
Component: Sales Component: SalesRule Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release

Comments

@friendscottn
Copy link

friendscottn commented Nov 15, 2018

Preconditions (*)

  1. 2.2.6
  2. Allow guest checkout
  3. Have a coupon you can use

Steps to reproduce (*)

  1. Checkout as a guest using a valid coupon
  2. After placing the order, register an account using the create account button on the order confirmation page.
  3. Login to the admin
  4. Make sure to get the order to a processing state.
  5. Try to cancel the order

Expected result (*)

  1. The order is canceled

Actual result (*)

  1. You receive the generic errror "You have not canceled the item"
  2. The underlying error is:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`mage`.`salesrule_customer`, CONSTRAINT `SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`) ON DELETE CASCADE), query was: INSERT INTO `salesrule_customer` () VALUES () {"exception":"[object] (Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`mage`.`salesrule_customer`, CONSTRAINT `SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`) ON DELETE CASCADE), query was: INSERT INTO `salesrule_customer` () VALUES () at /www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`mage`.`salesrule_customer`, CONSTRAINT `SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`) ON DELETE CASCADE) at /www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228)"} []

Related Issues

#16779

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Nov 15, 2018

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

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@friendscottn do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Nov 15, 2018
@mahesh-rajawat mahesh-rajawat self-assigned this Nov 15, 2018
@magento-engcom-team
Copy link
Contributor

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

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@mahesh-rajawat
Copy link
Member

@magento-engcom-team give me 2.2-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @maheshWebkul721. Thank you for your request. I'm working on Magento 2.2-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @maheshWebkul721, here is your Magento instance.
Admin access: http://34.228.235.121/i-19230-2-2-develop//admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@mahesh-rajawat mahesh-rajawat added Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Component: Sales Component: SalesRule Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Nov 15, 2018
@magento-engcom-team
Copy link
Contributor

@maheshWebkul721 Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-96384 were created

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Nov 15, 2018
@machaka
Copy link

machaka commented Nov 16, 2018

Hi there, I'm able to reproduce it, I'm facing the same issue on magento 2.2.6

@dudzio12
Copy link
Member

Same for me

@Winfle
Copy link
Contributor

Winfle commented Nov 24, 2018

Reproducible on 2.2.7-dev

@magento-engcom-team
Copy link
Contributor

Hi @KravetsAndriy. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@SamB-GB
Copy link

SamB-GB commented Dec 18, 2018

Does anyone know if this is an issue in 2.2.3?

@Winfle
Copy link
Contributor

Winfle commented Dec 21, 2018

@SamB-GB Hello. It doesn't throw exception, however expected behaviour is not valid, because after making an account, it doesn't increase coupon usage for newly created customer.
So, I think, that make reverse bugs, however, if you you're interested only in canceling order, you won't have a bug, described here.

@ghost ghost self-assigned this Jan 9, 2019
@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-tomash. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@ghost
Copy link

ghost commented Jan 9, 2019

@magento-engcom-team give me 2.3.0 instance

@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-tomash, here is your Magento instance.
Admin access: https://i-19230-2-3-0.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ghost ghost added Fixed in 2.3.x The issue has been fixed in 2.3 release line and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Jan 9, 2019
@ghost ghost added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Jan 9, 2019
@ghost
Copy link

ghost commented Jan 9, 2019

@friendscottn, thank you for reporting this isuue. The latest released version of Magento (2.3.0) is not affected by this issue. After the order is invoiced you cannot cancel the order. By if the merchant ships the order without invoicing than order gets status processing and also he is able to cancel it until invoice is not created. In such conditions order has no problems with cancelation

@ghost ghost closed this as completed Jan 9, 2019
@ghost ghost removed their assignment Jan 9, 2019
@Winfle
Copy link
Contributor

Winfle commented Jan 9, 2019

@engcom-backlog-tomash I think, when user makes guest order with coupon code and then registers an account, coupon code usage should be increased and coupon usage per customer should be increased , the same way as customer made account BEFORE checkout with given coupon.
In fact, coupon has been used, but amount of usages will be the same as before. This behaviour exists in 2.3.
If its not relevant to current scope ( Canceling an order), I can make separated issue.

@ghost
Copy link

ghost commented Jan 9, 2019

@Winfle, yes please create new one if it's not already created.

@sidolov
Copy link
Contributor

sidolov commented Jan 14, 2019

@MageCloudTeam
Copy link

@sidolov the same issue in Magento 2.2.9

engcom-Foxtrot pushed a commit to p-bystritsky/magento2 that referenced this issue Aug 7, 2019
@magento-engcom-team
Copy link
Contributor

Hi @friendscottn. Thank you for your report.
The issue has been fixed in #20577 by @p-bystritsky in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.4 release.

@parekhreena
Copy link

parekhreena commented Sep 16, 2019

The issue still happens with Guest Users. The issue originates from \Magento\SalesRule\Model\Coupon\UpdateCouponUsages::updateCustomerRuleUsages and this line $ruleCustomer->save(); was causing the issue. I am on enterprise version.

@mertgokceimam
Copy link

mertgokceimam commented Sep 17, 2019

@magento-engcom-team Can you please release a patch for this on 2.2.x for EE customers. Orders can't be cancelled have big effect on stock values within the system

@simonmaass
Copy link

i am still having this issue in magento 2.3.3 CE:

[2020-01-03 10:42:12] main.CRITICAL: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (xxxx.salesrule_customer, CONSTRAINT SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID FOREIGN KEY (rule_id) REFERENCES salesrule (rule_id) ON DELETE CASCADE), query was: INSERT INTO salesrule_customer () VALUES () {"exception":"[object] (Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (xxxx.salesrule_customer, CONSTRAINT SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID FOREIGN KEY (rule_id) REFERENCES salesrule (rule_id) ON DELETE CASCADE), query was: INSERT INTO salesrule_customer () VALUES () at /var/www/html/magento2/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (dbzn3lqcchilq.salesrule_customer, CONSTRAINT SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID FOREIGN KEY (rule_id) REFERENCES salesrule (rule_id) ON DELETE CASCADE) at /var/www/html/magento2/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []

@khoimm92
Copy link
Contributor

khoimm92 commented Aug 3, 2021

This issue still exists on Magento 2.4.2

@simonmaass
Copy link

can still confirm this issue in 2.4.3-p1

@igi8819
Copy link

igi8819 commented Mar 15, 2022

This issue still exist on Magento 2.4.3-p1

Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`salesrule_customer`, CONSTRAINT `SALESRULE_CUSTOMER_RULE_ID_SEQUENCE_SALESRULE_SEQUENCE_VALUE` FOREIGN KEY (`rule_id`) REFERENCES `sequence_salesrule` (`sequence_value`) ON DELETE C), query was: INSERT INTO `salesrule_customer` () VALUES () {"exception":"[object] (Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`salesrule_customer`, CONSTRAINT `SALESRULE_CUSTOMER_RULE_ID_SEQUENCE_SALESRULE_SEQUENCE_VALUE` FOREIGN KEY (`rule_id`) REFERENCES `sequence_salesrule` (`sequence_value`) ON DELETE C), query was: INSERT INTO `salesrule_customer` () VALUES () at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`salesrule_customer`, CONSTRAINT `SALESRULE_CUSTOMER_RULE_ID_SEQUENCE_SALESRULE_SEQUENCE_VALUE` FOREIGN KEY (`rule_id`) REFERENCES `sequence_salesrule` (`sequence_value`) ON DELETE C) at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []

@johnorourke
Copy link
Contributor

@simonmaass @igi8819 on 2.4.3-p1 you might have the same issue I did - trying to cancel an order via the REST API immediately after it's placed caused this error. I added a short pause (1 second) between the order place event and the API call to cancel it, and the problem went away. I think it's because the call to place an order is done from javascript, so perhaps the call to cancel the order can happen before the place order code has completed and the database is fully up to date.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Sales Component: SalesRule Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release
Projects
None yet
Development

No branches or pull requests