Skip to content

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

Closed
@kandrejevs

Description

@kandrejevs

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions