Skip to content

Commit

Permalink
Merge pull request #1994 from breakone/master
Browse files Browse the repository at this point in the history
[CoreBundle] use TaxationDisplayProvider in CarrierChoiceType
  • Loading branch information
dpfaffenbauer authored May 5, 2022
2 parents c4fa5a0 + c6afc8c commit f1348b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use CoreShop\Component\Core\Model\CarrierInterface;
use CoreShop\Component\Core\Model\OrderInterface;
use CoreShop\Component\Core\Repository\CarrierRepositoryInterface;
use CoreShop\Component\Core\Taxation\TaxationDisplayProviderInterface;
use CoreShop\Component\Order\Cart\CartContextResolverInterface;
use CoreShop\Component\Shipping\Calculator\TaxedShippingCalculatorInterface;
use CoreShop\Component\Shipping\Resolver\CarriersResolverInterface;
Expand All @@ -35,7 +36,8 @@ public function __construct(
private CarrierRepositoryInterface $repository,
private CarriersResolverInterface $carriersResolver,
private TaxedShippingCalculatorInterface $taxedShippingCalculator,
private CartContextResolverInterface $cartContextResolver
private CartContextResolverInterface $cartContextResolver,
private TaxationDisplayProviderInterface $taxationDisplayProvider
) {
parent::__construct($dataClass, $validationGroups);
}
Expand All @@ -60,7 +62,6 @@ public function configureOptions(OptionsResolver $resolver): void
'cart',
])
->setDefault('show_carrier_price', true)
->setDefault('show_carrier_price_with_tax', true)
->setAllowedTypes('cart', OrderInterface::class);
}

Expand All @@ -79,12 +80,14 @@ public function buildView(FormView $view, FormInterface $form, array $options):
continue;
}

$context = $this->cartContextResolver->resolveCartContext($cart);

$price = $this->taxedShippingCalculator->getPrice(
$carrier,
$cart,
$cart->getShippingAddress(),
$options['show_carrier_price_with_tax'],
$this->cartContextResolver->resolveCartContext($cart)
$this->taxationDisplayProvider->displayWithTax($context),
$context
);

$prices[$choice->value] = $price;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ services:
- '@CoreShop\Component\Shipping\Resolver\CarriersResolverInterface'
- '@CoreShop\Component\Shipping\Calculator\TaxedShippingCalculatorInterface'
- '@CoreShop\Component\Order\Cart\CartContextResolverInterface'
- '@CoreShop\Component\Core\Taxation\TaxationDisplayProviderInterface'
tags:
- { name: form.type }

0 comments on commit f1348b0

Please sign in to comment.