Skip to content

[Forwardport] Fix shipping discount failed to apply during place order #18230

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 1 commit into from
Closed

[Forwardport] Fix shipping discount failed to apply during place order #18230

wants to merge 1 commit into from

Conversation

mage2pratik
Copy link
Contributor

Original Pull Request

#18098

Description

Caused by #13185, \Magento\Tax\Model\Sales\Total\Quote\Tax::clearValues() is called to unset the total before collecting total. null is expected (representing unset state) in below condition however 0 is set and failed the condition necessary to calculate correct shipping discount.

- expected
+ actual
// \Magento\SalesRule\Model\Validator::processShippingAmount
    public function processShippingAmount(Address $address)
    {
-        // $shippingAmount = null
+        // $shippingAmount = 0
        $shippingAmount = $address->getShippingAmountForDiscount();
        if ($shippingAmount !== null) {
            $baseShippingAmount = $address->getBaseShippingAmountForDiscount();
        } else {
            $shippingAmount = $address->getShippingAmount();
            $baseShippingAmount = $address->getBaseShippingAmount();
        }
        // ...
        $discountAmount = ($shippingAmount - $address->getShippingDiscountAmount()) * $rulePercent / 100;
        // ...
    }

Shipping discount fail to apply to an order, when:

  • order is checking out with payment method which do not collect total after savePaymentInformation() (for example, credit card methods usually meet this criteria, while paypal methods not)
  • order is applied with a promotional rule with shipping discount

Fixed Issues (if relevant)

Can't found any related issue so far

Manual testing scenarios

  1. Create coupon of 20%off discount and set it to applicable to shipping
  2. Apply the coupon
  3. Check out with Braintree
  4. After placed the order, go to account page to view the order

Expected result: Order discount contains shipping amount

Actual result: Order discount does not contain shipping amount

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @mage2pratik. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me $VERSION instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-3041 has been created to process this Pull Request

@sidolov
Copy link
Contributor

sidolov commented Oct 2, 2018

Hi @mage2pratik , we can't reproduce this issue on the vanilla 2.3-develop instance

Manual testing scenario:

  1. Create coupon of 20% discount and set it applicable to shipping
  2. Apply the coupon
  3. Check out with Braintree
  4. After the order has been placed, proceed to account page to view the order

Actual result:
Order discount contains shipping amount

Please, provide additional steps for validation.
Thank you!

@sidolov
Copy link
Contributor

sidolov commented Oct 16, 2018

Hi @mage2pratik , I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@sidolov sidolov closed this Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants