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

Cart price rule save/edit sets coupon expiration date to today #7135

Closed
kandrejevs opened this issue Oct 21, 2016 · 2 comments
Closed

Cart price rule save/edit sets coupon expiration date to today #7135

kandrejevs opened this issue Oct 21, 2016 · 2 comments

Comments

@kandrejevs
Copy link

kandrejevs commented Oct 21, 2016

Creating new cart price rule with specific coupon sets exipiration_date for coupon to today causing coupons to stop working after midnight (takes in account only Y-m-d)

Magento CE and EE 2.1.2, nginx, php7

Steps to reproduce

  1. Create cart price rule
  2. Leave "From" and "To" dates empty (they are not required)
  3. Save cart price rule
  4. Expiration dates are set to today

for rule settings please reference this screenshot: http://i.imgur.com/cwx8WN2.png

Expected result

  1. expiration date should be NULL therefore never expires.

Actual result

  1. Cart price rule and coupon expiration date is today's date and the coupon is not working after midnight.

This problem is a blocker for enterprise edition because coupon and cart rule state is managed by staging module. This means that after creating or editing cart price rule it will work only for 1 day without direct access to a database and editing salesrule_coupon table directly by deleting expiration_date. there is no way to change expiration date through an admin panel.

Some info from debugging:
file: vendor/magento/module-sales-rule/Controller/Adminhtml/Promo/Quote/Save.php

                    $inputFilter = new \Zend_Filter_Input(
                        ['from_date' => $this->_dateFilter, 'to_date' => $this->_dateFilter],
                        [],
                        $data
                    );
                    $data = $inputFilter->getUnescaped();

Zend_Filter_Input returns empty to_date and from_date values as today's date.
after removing this code coupon expiration date still is set as today

I was able to trace it till vendor/magento/module-sales-rule/Model/ResourceModel/Coupon.php line 37. in _beforeSave() method, $object already have expiration_date and I was not able to backtrace it further where empty value is transformed to today's date.

@kandrejevs kandrejevs changed the title Cart price rule edit sets expiration date to today Cart price rule save/edit sets coupon expiration date to today Oct 21, 2016
@sergiojovanig
Copy link

sergiojovanig commented Oct 28, 2016

This is fixed in #6762

@kandrejevs
Copy link
Author

nice, closing as a duplicate then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants