99use Drupal \commerce_price \RounderInterface ;
1010use Drupal \commerce_store \Entity \StoreInterface ;
1111use Drupal \commerce_tax \TaxZone ;
12+ use Drupal \commerce_tax \Resolver \ChainTaxRateResolverInterface ;
1213use Drupal \Core \Entity \EntityTypeManagerInterface ;
1314use Drupal \profile \Entity \ProfileInterface ;
1415use Symfony \Component \DependencyInjection \ContainerInterface ;
@@ -26,6 +27,13 @@ abstract class LocalTaxTypeBase extends TaxTypeBase implements LocalTaxTypeInter
2627 */
2728 protected $ rounder ;
2829
30+ /**
31+ * The chain tax rate resolver.
32+ *
33+ * @var \Drupal\commerce_tax\ChainTaxRateResolverInterface
34+ */
35+ protected $ chainRateResolver ;
36+
2937 /**
3038 * Constructs a new LocalTaxTypeBase object.
3139 *
@@ -41,11 +49,14 @@ abstract class LocalTaxTypeBase extends TaxTypeBase implements LocalTaxTypeInter
4149 * The event dispatcher.
4250 * @param \Drupal\commerce_price\RounderInterface $rounder
4351 * The rounder.
52+ * @param \Drupal\commerce_tax\ChainTaxRateResolverInterface $chain_rate_resolver
53+ * The chain tax rate resolver.
4454 */
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 ) {
4656 parent ::__construct ($ configuration , $ plugin_id , $ plugin_definition , $ entity_type_manager , $ event_dispatcher );
4757
4858 $ this ->rounder = $ rounder ;
59+ $ this ->chainRateResolver = $ chain_rate_resolver ;
4960 }
5061
5162 /**
@@ -58,7 +69,8 @@ public static function create(ContainerInterface $container, array $configuratio
5869 $ plugin_definition ,
5970 $ container ->get ('entity_type.manager ' ),
6071 $ 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 ' )
6274 );
6375 }
6476
@@ -93,8 +105,8 @@ public function apply(OrderInterface $order) {
93105
94106 $ zones = $ this ->resolveZones ($ order_item , $ customer_profile );
95107 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) ) {
98110 // No applicable rate found.
99111 continue ;
100112 }
0 commit comments