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

Prevent duplicate entry when updating salesrule_coupon_usage #1117

Merged

Conversation

drwilliams
Copy link
Contributor

Description (*)

If you cancel a customer order with a promo code and try to place an order with the same promo code it fails because of an Integrity constraint violation: 1062 Duplicate entry on salesrule_coupon_usage since times_used goes to 0 when the order is canceled. I removed the check for $timesUsed > 0 so that it will run as an update instead of an insert.

Related Pull Requests

#1031

Fixed Issues (if relevant)

  1. Fixes Unable to place order after canceled order #1116

Manual testing scenarios (*)

  1. Log in to customer account
  2. Place an order with a promo code
  3. Cancel the order
  4. While still logged in, place another order with the same promo code (This failed before making this change.)

@colinmollenhour
Copy link
Member

I haven't had a chance to look at this closely but is it related to #1031 which has already been merged? /cc @mattdavenport

@github-actions github-actions bot added the Component: SalesRule Relates to Mage_SalesRule label Jul 24, 2020
@VincentMarmiesse
Copy link
Contributor

I haven't had a chance to look at this closely but is it related to #1031 which has already been merged? /cc @mattdavenport

Yes it is, but #1031 caused some issues, especially #1116.
This is critical as the user is not able to place an order in the following scenario:

  • User uses a coupon
  • User cancels his order
  • User re-uses the same coupon => he's not able to place his order

@sreichel sreichel added the bug label Aug 19, 2020
Copy link
Contributor

@sreichel sreichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with latest 19.4.6

@colinmollenhour colinmollenhour dismissed kkrieger85’s stale review August 21, 2020 05:45

The new code has a second if clause that would addresses the concern.

@colinmollenhour colinmollenhour merged commit 1b97c6f into OpenMage:1.9.4.x Aug 21, 2020
colinmollenhour pushed a commit that referenced this pull request Aug 21, 2020
* remove $timesUsed > 0 check to prevent duplicate entry

* Prevent $timesUsed from going less than 0
@sreichel sreichel added this to the Release 19.4.7 / 20.0.3 milestone Aug 21, 2020
edannenberg pushed a commit to edannenberg/magento-lts that referenced this pull request Aug 24, 2020
* Remove $timesUsed > 0 check to prevent duplicate entry
* Prevent $timesUsed from going less than 0

refs: OpenMage#1031
sreichel added a commit that referenced this pull request Mar 11, 2021
#1302)

* bump version

* Fix _addUrlRewrite() ignoring collection store scope. (#510)

While Mage_Catalog_Model_Resource_Product_Collection::addUrlRewrite()
does respect any set storeId on the collection it's helper that does
the actual work is hard-coded to the current active store.

* Add doc comments to image related classes (#1146)

* Prevent duplicate entry when updating salesrule_coupon_usage (#1117)

* remove $timesUsed > 0 check to prevent duplicate entry

* Prevent $timesUsed from going less than 0

* Fix a bug where media upload via API are not possible anymore: #1178

* revert unwanted changes

* Update lib/Varien/Io/File.php

Co-authored-by: Flyingmana <flyingmana@googlemail.com>
Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
Co-authored-by: Erik Dannenberg <ed@reshape.de>
Co-authored-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Co-authored-by: Dean Williams <me@deanwilliams.org>
Co-authored-by: sv3n <github-sr@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Component: SalesRule Relates to Mage_SalesRule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to place order after canceled order
5 participants