Skip to content

Commit cc3db8e

Browse files
committed
MC-38939: Subtotal Cart Price Rule excludes product tax for fixed amount
- Add "Subtotal (Incl. Tax)" to cart price rule condition
1 parent c4bbe24 commit cc3db8e

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

app/code/Magento/SalesRule/Model/Rule/Condition/Address.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function loadAttributeOptions()
6262
{
6363
$attributes = [
6464
'base_subtotal_with_discount' => __('Subtotal (Excl. Tax)'),
65+
'base_subtotal_total_incl_tax' => __('Subtotal (Incl. Tax)'),
6566
'base_subtotal' => __('Subtotal'),
6667
'total_qty' => __('Total Items Quantity'),
6768
'weight' => __('Total Weight'),
@@ -99,6 +100,7 @@ public function getInputType()
99100
{
100101
switch ($this->getAttribute()) {
101102
case 'base_subtotal':
103+
case 'base_subtotal_total_incl_tax':
102104
case 'weight':
103105
case 'total_qty':
104106
return 'numeric';
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\SalesRule\Test\Unit\Model\Rule\Condition;
9+
10+
use Magento\SalesRule\Model\Rule\Condition\Address;
11+
use PHPUnit\Framework\TestCase;
12+
13+
/**
14+
* Test for address rule condition
15+
*/
16+
class AddressTest extends TestCase
17+
{
18+
/**
19+
* @var Address
20+
*/
21+
private $model;
22+
23+
/**
24+
* @inheritDoc
25+
*/
26+
protected function setUp()
27+
{
28+
parent::setUp();
29+
$context = $this->createMock(\Magento\Rule\Model\Condition\Context::class);
30+
$directoryCountry = $this->createMock(\Magento\Directory\Model\Config\Source\Country::class);
31+
$directoryAllregion = $this->createMock(\Magento\Directory\Model\Config\Source\Allregion::class);
32+
$shippingAllmethods = $this->createMock(\Magento\Shipping\Model\Config\Source\Allmethods::class);
33+
$paymentAllmethods = $this->createMock(\Magento\Payment\Model\Config\Source\Allmethods::class);
34+
$this->model = new Address(
35+
$context,
36+
$directoryCountry,
37+
$directoryAllregion,
38+
$shippingAllmethods,
39+
$paymentAllmethods
40+
);
41+
}
42+
43+
/**
44+
* Test that all attributes are present in options list
45+
*/
46+
public function testLoadAttributeOptions(): void
47+
{
48+
$attributes = [
49+
'base_subtotal_with_discount',
50+
'base_subtotal_total_incl_tax',
51+
'base_subtotal',
52+
'total_qty',
53+
'weight',
54+
'payment_method',
55+
'shipping_method',
56+
'postcode',
57+
'region',
58+
'region_id',
59+
'country_id',
60+
];
61+
62+
$this->model->loadAttributeOptions();
63+
$this->assertEquals($attributes, array_keys($this->model->getAttributeOption()));
64+
}
65+
}

0 commit comments

Comments
 (0)