Skip to content

Wrong coupon usage handling for cart price rules with shipping discount #6693

Closed
@alexnos88

Description

@alexnos88

When placing an order using coupon code for shipping discount (provided via cart price rules) usage counter doesn't get updated.

Preconditions

  1. Magento 2.1.0
  2. Cart Price Rule applicable to some (any) cart
    2.1. Use specific coupon, any coupon code
    2.2. Actions providing only shipping discount
    2.3. Uses per coupon \ customer set to some value > 0

Steps to reproduce

  1. Add some product to cart,
  2. Checkout using coupon code from the rule you've created

Expected result

  1. Coupon usage counter increments

Actual result

  1. Coupon usage counter doesn't increment

Clue

Since 2.1.0 there is extra condition in

Magento\SalesRule\Observer\SalesOrderAfterPlaceObserver : 60

    if (!$order || $order->getDiscountAmount() == 0) {
        return $this;
    }

Which in previous versions was simpler: if (!$order)

When a rule provide only a shipping discount, getDiscountAmount() returns 0, and the script execution ends.

Proposed variant is the following:

    if (!$order || !$order->getAppliedRuleIds()) {
        return $this;
    }

In such way script will continue execution, and usage counters will get updated.

Please consider implementing this fix in the upcoming patches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions