Skip to content

Commit 3c0be52

Browse files
order mail: hide total price for customers that are not allowed to see prices (#3719)
2 parents 0f60523 + a577bec commit 3c0be52

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Model/Order/Mail/OrderMail.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Shopsys\FrameworkBundle\Model\Order\OrderUrlGenerator;
1717
use Shopsys\FrameworkBundle\Model\Order\Status\OrderStatus;
1818
use Shopsys\FrameworkBundle\Twig\DateTimeFormatterExtension;
19+
use Shopsys\FrameworkBundle\Twig\HiddenPriceExtension;
1920
use Shopsys\FrameworkBundle\Twig\PriceExtension;
2021
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2122
use Twig\Environment;
@@ -49,6 +50,7 @@ class OrderMail implements MessageFactoryInterface
4950
* @param \Shopsys\FrameworkBundle\Twig\PriceExtension $priceExtension
5051
* @param \Shopsys\FrameworkBundle\Twig\DateTimeFormatterExtension $dateTimeFormatterExtension
5152
* @param \Shopsys\FrameworkBundle\Model\Order\OrderUrlGenerator $orderUrlGenerator
53+
* @param \Shopsys\FrameworkBundle\Twig\HiddenPriceExtension $hiddenPriceExtension
5254
*/
5355
public function __construct(
5456
protected readonly Setting $setting,
@@ -59,6 +61,7 @@ public function __construct(
5961
protected readonly PriceExtension $priceExtension,
6062
protected readonly DateTimeFormatterExtension $dateTimeFormatterExtension,
6163
protected readonly OrderUrlGenerator $orderUrlGenerator,
64+
protected readonly HiddenPriceExtension $hiddenPriceExtension,
6265
) {
6366
}
6467

@@ -155,13 +158,15 @@ protected function getVariablesReplacementsForSubject(Order $order)
155158
* @param \Shopsys\FrameworkBundle\Model\Order\Order $order
156159
* @return string
157160
*/
158-
protected function getFormattedPrice(Order $order)
161+
protected function getFormattedPrice(Order $order): string
159162
{
160-
return $this->priceExtension->priceTextWithCurrencyByCurrencyIdAndLocaleFilter(
163+
$price = $this->priceExtension->priceTextWithCurrencyByCurrencyIdAndLocaleFilter(
161164
$order->getTotalPriceWithVat(),
162165
$order->getCurrency()->getId(),
163166
$this->getDomainLocaleByOrder($order),
164167
);
168+
169+
return $this->hiddenPriceExtension->hidePriceFilter($price, $order->getCustomerUser());
165170
}
166171

167172
/**

0 commit comments

Comments
 (0)