Skip to content

Added check for coupon expiration date #3029

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

Closed
wants to merge 487 commits into from
Closed

Added check for coupon expiration date #3029

wants to merge 487 commits into from

Conversation

fballiano
Copy link

Mage_SalesRule_Model_Validator::_canProcessRule() checks the validity of a coupon code that is in the process of being added to the cart, but it doesn't check for the single coupon expiration date. This PR adds this check.

Manual testing scenarios (*)

  1. in the backend go to "promotions -> Shopping Cart Price Rules"
  2. create a new rule with "specific coupon" (but also autogenerated coupons have the same issue) and type a coupon code
  3. be sure that the rule also has some "action", ex: 10% discount
  4. save the rule and check that it's working on the frontend

Now, what we're about to check isn't really supported by the core but I think it's still worth fixing.

  1. open your database console and check for the salesrule_coupon table, you'll find a record with the coupon code you just created above
  2. modify the expiration_date column for that specific coupon and set it in the past
  3. go to the frontend, apply the coupon and notice that it gets applied anyway

It is true that the core wouldn't manage the expiration_date column but, since it exists, I know extensions (actually I was developing one today when I found this bug) that set the expiration_data for a single coupon (let's say you want a coupon to be usable only for 7 days after its generation), and it doesn't make sense to me that the core doesn't check for the expiration_date of a coupon.

After applying this PR you'll notice that the expiration_date gets correctly checked, if present.

sreichel and others added 30 commits November 29, 2022 07:31
* PHP-CS-Fixer fixes

Signed-off-by: Sven Reichel <github-sr@hotmail.com>

* Updated workflow

Signed-off-by: Sven Reichel <github-sr@hotmail.com>

* Added php-cs-fixer workflow

Signed-off-by: Sven Reichel <github-sr@hotmail.com>

* Added PHPCompatibility check

* PHPCompatibility check can fail

* Fixes: Node.js 12 actions are deprecated

* Fixes: PSR12.ControlStructures.ControlStructureSpacing.LineIndent

* Fixes: PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine

* Dond check CM_Redis every time

* Add .php-cs-fixer.cache to .gitignore

* Fixes class name (wrong place ... i know)

* Minor fixes

* Combined workflows

* Added app/Mage.php and files from root to rulesets

* Remove unused phpstan_experimental_level.neon

* Updated phpstan.neon (for upcoming commits)

* Set PhpStan level to 5 (from 3)

* Update phpstan to v1.9.2

* Updated phpstan-baseline.neon

* Updated phpstan-baseline.neon

* Update app/code/core/Mage/Tag/Model/Resource/Tag.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Update lib/Varien/Db/Adapter/Pdo/Mysql.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Set workflow include paths (skip other files)

* Updated labeler.yml

* Removed travis label

* Improved workflow (#26)

* Fixed grep modifier to get correct count

* Updated ECG sniff baseline

* Added Mage_Centinal to PhpStan checks

* Added Mage_PaypalUk to PhpStan checks

* Update app/code/core/Mage/Paypal/Model/Config.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

Signed-off-by: Sven Reichel <github-sr@hotmail.com>
Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
Co-authored-by: sv3n <github-sr@hotmail.com>
* Just updated docs ...

* ... and updated phpstan baseline.

* Apply suggestions from code review

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Update app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
@fballiano fballiano deleted the couponexpire branch April 5, 2023 08:31
@github-actions github-actions bot added Component: Adminhtml Relates to Mage_Adminhtml Component: Api PageRelates to Mage_Api Component: Api2 Relates to Mage_Api2 Component: Authorizenet Relates to Mage_Authorizenet Component: Bundle Relates to Mage_Bundle Component: Captcha Relates to Mage_Captcha Component: Catalog Relates to Mage_Catalog Component: CatalogInventory Relates to Mage_CatalogInventory Component: CatalogRule Relates to Mage_CatalogRule Component: CatalogIndex Relates to Mage_CatalogIndex 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: ConfigurableSwatches Relates to Mage_ConfigurableSwatches Component: Contacts Relates to Mage_Contacts Component: Core Relates to Mage_Core Component: Cron Relates to Mage_Cron Component: CurrencySymbol Relates to Mage_CurrencySymbol 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 documentation environment JavaScript Relates to js/* translations Relates to app/locale labels Apr 5, 2023
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: Api PageRelates to Mage_Api Component: Api2 Relates to Mage_Api2 Component: Authorizenet Relates to Mage_Authorizenet Component: Bundle Relates to Mage_Bundle Component: Captcha Relates to Mage_Captcha Component: Catalog Relates to Mage_Catalog Component: CatalogIndex Relates to Mage_CatalogIndex Component: CatalogInventory Relates to Mage_CatalogInventory Component: CatalogRule Relates to Mage_CatalogRule 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: ConfigurableSwatches Relates to Mage_ConfigurableSwatches Component: Contacts Relates to Mage_Contacts Component: Core Relates to Mage_Core Component: Cron Relates to Mage_Cron Component: CurrencySymbol Relates to Mage_CurrencySymbol 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: SalesRule Relates to Mage_SalesRule documentation environment JavaScript Relates to js/* translations Relates to app/locale
Projects
None yet
Development

Successfully merging this pull request may close these issues.