Skip to content

Added option to exclude discount for minimum order amount calculation #19136

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

Merged

Conversation

ccasciotti
Copy link
Contributor

@ccasciotti ccasciotti commented Nov 9, 2018

Description

This PR adds option for store manager to include or exclude discount amount from minimum order amount calculation. Sometimes client wants to exclude discount amount from minimum order and want that only subtotal is used. The default option is set to "Yes" so Magento will use the current behavior.

Fixed Issues (if relevant)

none

Manual testing scenarios

  1. Access backend
  2. Go to Stores > Configuration > Sales > Sales > Minimum Order Amount
  3. Leave "Yes" in "Include Discount Amount" field to test normal behaviour.
  4. Set "No" in "Include Discount Amount" field to test new behaviour without discount.

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)

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ccasciotti thanks for the contribution, please see my code review notes

@@ -2289,7 +2298,11 @@ public function validateMinimumAmount($multishipping = false)
$baseTotal = 0;
foreach ($addresses as $address) {
$taxes = ($taxInclude) ? $address->getBaseTaxAmount() : 0;
$baseTotal += $address->getBaseSubtotalWithDiscount() + $taxes;
if ($includeDiscount) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation of getBaseSubtotalWithDiscount method is as simple as $this->getBaseSubtotal() + $this->getBaseDiscountAmount(). If there is no bugs related to tax in current implementation I would suggest simply returning $this->getBaseSubtotal() + $taxes or $address->getBaseSubtotalWithDiscount() + $taxes depending on includeDiscount configuration value.

Please consider the same for other instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sivaschenko,
changes implemented

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.1 milestone Jan 18, 2019
@magento-engcom-team
Copy link
Contributor

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

@sivaschenko sivaschenko changed the title [Up-port 2.3] Added option to exclude discount for minimum order amount calculation Added option to exclude discount for minimum order amount calculation Jan 26, 2019
@magento-engcom-team magento-engcom-team merged commit 8d4e4a2 into magento:2.3-develop Jan 27, 2019
@ghost
Copy link

ghost commented Jan 27, 2019

Hi @ccasciotti, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

magento-engcom-team pushed a commit that referenced this pull request Jan 27, 2019
@magento-engcom-team
Copy link
Contributor

Hi @ccasciotti. Thank you for your contribution.
We will aim to release these changes as part of 2.3.1.
Please check the release notes for final confirmation.

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.

4 participants