9
9
use Drupal \commerce_price \RounderInterface ;
10
10
use Drupal \commerce_store \Entity \StoreInterface ;
11
11
use Drupal \commerce_tax \TaxZone ;
12
+ use Drupal \commerce_tax \Resolver \ChainTaxRateResolverInterface ;
12
13
use Drupal \Core \Entity \EntityTypeManagerInterface ;
13
14
use Drupal \profile \Entity \ProfileInterface ;
14
15
use Symfony \Component \DependencyInjection \ContainerInterface ;
@@ -26,6 +27,13 @@ abstract class LocalTaxTypeBase extends TaxTypeBase implements LocalTaxTypeInter
26
27
*/
27
28
protected $ rounder ;
28
29
30
+ /**
31
+ * The chain tax rate resolver.
32
+ *
33
+ * @var \Drupal\commerce_tax\ChainTaxRateResolverInterface
34
+ */
35
+ protected $ chainRateResolver ;
36
+
29
37
/**
30
38
* Constructs a new LocalTaxTypeBase object.
31
39
*
@@ -41,11 +49,14 @@ abstract class LocalTaxTypeBase extends TaxTypeBase implements LocalTaxTypeInter
41
49
* The event dispatcher.
42
50
* @param \Drupal\commerce_price\RounderInterface $rounder
43
51
* The rounder.
52
+ * @param \Drupal\commerce_tax\ChainTaxRateResolverInterface $chain_rate_resolver
53
+ * The chain tax rate resolver.
44
54
*/
45
- public function __construct (array $ configuration , $ plugin_id , $ plugin_definition , EntityTypeManagerInterface $ entity_type_manager , EventDispatcherInterface $ event_dispatcher , RounderInterface $ rounder ) {
55
+ public function __construct (array $ configuration , $ plugin_id , $ plugin_definition , EntityTypeManagerInterface $ entity_type_manager , EventDispatcherInterface $ event_dispatcher , RounderInterface $ rounder, ChainTaxRateResolverInterface $ chain_rate_resolver ) {
46
56
parent ::__construct ($ configuration , $ plugin_id , $ plugin_definition , $ entity_type_manager , $ event_dispatcher );
47
57
48
58
$ this ->rounder = $ rounder ;
59
+ $ this ->chainRateResolver = $ chain_rate_resolver ;
49
60
}
50
61
51
62
/**
@@ -58,7 +69,8 @@ public static function create(ContainerInterface $container, array $configuratio
58
69
$ plugin_definition ,
59
70
$ container ->get ('entity_type.manager ' ),
60
71
$ container ->get ('event_dispatcher ' ),
61
- $ container ->get ('commerce_price.rounder ' )
72
+ $ container ->get ('commerce_price.rounder ' ),
73
+ $ container ->get ('commerce_tax.chain_tax_rate_resolver ' )
62
74
);
63
75
}
64
76
@@ -93,8 +105,8 @@ public function apply(OrderInterface $order) {
93
105
94
106
$ zones = $ this ->resolveZones ($ order_item , $ customer_profile );
95
107
foreach ($ zones as $ zone ) {
96
- $ rate = $ this ->resolveRate ($ zone , $ order_item , $ customer_profile );
97
- if (!$ rate ) {
108
+ $ rate = $ this ->chainRateResolver -> resolve ($ zone , $ order_item , $ customer_profile );
109
+ if (!is_object ( $ rate) ) {
98
110
// No applicable rate found.
99
111
continue ;
100
112
}
0 commit comments