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

Add "Times used" indicator field to promo rule quote grid #1853

Merged
merged 4 commits into from
Jun 21, 2022

Conversation

spinsch
Copy link
Contributor

@spinsch spinsch commented Oct 6, 2021

Description (*)

When I use a single coupon code without the generator, there is no indicator to check how many times the coupon has been used.
And when i cancel an order the "times_used" field from the "salesrule" table was not decremented.
This PR will show the "times_used" field in the promo rule quote grid and fixes the decrementing while cancel an order.

Manual testing scenarios (*)

  1. Goto Backend > Promotions > Shopping Cart Price Rules > Add New Rule
  2. Create the new Rule with the "Specific Coupon"-Option and set the Coupon Code manually (without the generator)
  3. Trigger the Rule
  4. Goto Backend > Promotions > Shopping Cart Price Rules and check the "Times used" field.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added the Component: Adminhtml Relates to Mage_Adminhtml label Oct 6, 2021
@github-actions github-actions bot added Component: Admin Relates to Mage_Admin Component: Bundle Relates to Mage_Bundle Component: Catalog Relates to Mage_Catalog Component: CatalogSearch Relates to Mage_CatalogSearch Component: Centinel Relates to Mage_Centinel Component: Checkout Relates to Mage_Checkout Component: Cms Relates to Mage_Cms Component: Core Relates to Mage_Core Component: Customer Relates to Mage_Customer Component: Dataflow Relates to Mage_Dataflow Component: Directory Relates to Mage_Directory Component: Downloadable Relates to Mage_Downloadable Component: Eav Relates to Mage_Eav Component: Index Relates to Mage_Index Component: Install Relates to Mage_Install Component: lib/Zend Component: lib/Varien Relates to lib/Varien Component: lib/Mage Relates to lib/Mage Component: lib/* Relates to lib/* Component: Log Relates to Mage_Log Component: Page Relates to Mage_Page Component: Paygate Relates to Mage_Paygate Component: Payment Relates to Mage_Payment Component: Reports Relates to Mage_Reports Component: Rule Relates to Mage_Rule Component: Sales Relates to Mage_Sales Component: SalesRule Relates to Mage_SalesRule Component: Shipping Relates to Mage_Shipping Component: Tax Relates to Mage_Tax labels Oct 13, 2021
@github-actions github-actions bot removed Component: Cms Relates to Mage_Cms Component: CatalogSearch Relates to Mage_CatalogSearch labels Oct 13, 2021
@spinsch spinsch marked this pull request as ready for review October 13, 2021 15:28
@m-overlund
Copy link
Contributor

When i filter by times used i'm getting an error report: where clause is ambigious

Integrity constraint violation: 1052 Column 'times_used' in where clause is ambiguous, query was: SELECT COUNT(*) FROM `salesrule` AS `main_table`
 LEFT JOIN `salesrule_coupon` AS `rule_coupons` ON main_table.rule_id = rule_coupons.rule_id AND rule_coupons.is_primary = 1 WHERE (`times_used` >= '1')

Also there seems to be discrepancies between times used in the grid, and times used under Manage Coupon Codes for auto generation rules.
Some times the grid says times used is 1, while Manage Coupon Codes for that rule, says the (single) coupon code is not used.

@spinsch
Copy link
Contributor Author

spinsch commented Oct 22, 2021

Hmm interesting, maybe this is the reason why this field wasn't yet in the main grid. i will fix this asap.
thank you

@spinsch spinsch marked this pull request as draft October 22, 2021 13:55
@spinsch spinsch force-pushed the 1.9.4.x branch 2 times, most recently from 4b7f3ea to 843b373 Compare October 25, 2021 12:47
@m-overlund
Copy link
Contributor

m-overlund commented Oct 25, 2021

Fixed my sorting issues.

Still not sure why times used sometimes don't match, when coupon code is autogenerated, though.
times-used

EDIT:
It seem's like the times_used on Grid is 1 higher than it actually should be - in 95% of my cases.
For autogenerated coupon codes, that is.

@github-actions github-actions bot added the Component: SalesRule Relates to Mage_SalesRule label Oct 26, 2021
@spinsch
Copy link
Contributor Author

spinsch commented Oct 26, 2021

With the latest version on my dev i can only trigger the wrong "times_used" counter from "salesrule" table when i cancel the order.
Last year there were a few pr's that fixed this problem with counting (#1031 and #1117 ).
The counting problem was resolved on my production shop after this two pull requests was merged and live.

@spinsch spinsch marked this pull request as ready for review October 26, 2021 10:13
@fballiano
Copy link
Contributor

With the latest version on my dev i can only trigger the wrong "times_used" counter from "salesrule" table when i cancel the order. Last year there were a few pr's that fixed this problem with counting (#1031 and #1117 ). The counting problem was resolved on my production shop after this two pull requests was merged and live.

@spinsch if it's resolve do we still need this PR? thank you!

@spinsch
Copy link
Contributor Author

spinsch commented Jun 8, 2022

@fballiano this pr should actually only insert a column in the table with the value of "times_used" so that you can see how many times the rule was applied and is to be considered as a feature.

the discussed problem after that refers to the wrong counting of the counter which appeared by the way. if i merge my pr with the other two, then everything had worked as desired for me.

fballiano
fballiano previously approved these changes Jun 16, 2022
Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

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

ok tested and working, if payment is canceled the salesrule table wasn't updated, with the patch it works

When I use a single coupon code without the generator, there is no field in the main grid to check how many times the coupon has been used.
@fballiano fballiano merged commit 2740724 into OpenMage:1.9.4.x Jun 21, 2022
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
7 runs  ±0  5 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit 2740724. ± Comparison against base commit 7afc8a1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml Component: SalesRule Relates to Mage_SalesRule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants