From 3423dd172748845ce5177ea6bf5894a6da977c37 Mon Sep 17 00:00:00 2001 From: Nikita Kiselev Date: Thu, 4 Dec 2025 14:01:16 +0300 Subject: [PATCH] fix(spa): remove html in price for some opencart custom themes --- .../src/Services/CartService.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/CartService.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/CartService.php index cf5e4af..9b49fb4 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/CartService.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/CartService.php @@ -3,17 +3,20 @@ namespace App\Services; use Cart\Cart; +use Cart\Currency; use Openguru\OpenCartFramework\OpenCart\Decorators\OcRegistryDecorator; class CartService { private OcRegistryDecorator $oc; private Cart $cart; + private Currency $currency; - public function __construct(OcRegistryDecorator $registry, Cart $cart) + public function __construct(OcRegistryDecorator $registry, Cart $cart, Currency $currency) { $this->oc = $registry; $this->cart = $cart; + $this->currency = $currency; } public function getCart(): array @@ -138,8 +141,8 @@ class CartService $priceNumeric = $unit_price; $totalNumeric = $unit_price * $product['quantity']; - $price = $this->oc->currency->format($unit_price, $this->oc->session->data['currency']); - $total = $this->oc->currency->format($totalNumeric, $this->oc->session->data['currency']); + $price = $this->currency->format($unit_price, $this->oc->session->data['currency']); + $total = $this->currency->format($totalNumeric, $this->oc->session->data['currency']); } else { $price = false; $total = false; @@ -159,7 +162,7 @@ class CartService if ($product['recurring']['trial']) { $recurring = sprintf( $this->oc->language->get('text_trial_description'), - $this->oc->currency->format( + $this->currency->format( $this->oc->tax->calculate( $product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], @@ -176,7 +179,7 @@ class CartService if ($product['recurring']['duration']) { $recurring .= sprintf( $this->oc->language->get('text_payment_description'), - $this->oc->currency->format( + $this->currency->format( $this->oc->tax->calculate( $product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], @@ -191,7 +194,7 @@ class CartService } else { $recurring .= sprintf( $this->oc->language->get('text_payment_cancel'), - $this->oc->currency->format( + $this->currency->format( $this->oc->tax->calculate( $product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], @@ -281,14 +284,14 @@ class CartService 'title' => $total['title'], 'value' => $total['value'], 'sort_order' => $total['sort_order'], - 'text' => $this->oc->currency->format($total['value'], $this->oc->session->data['currency']), + 'text' => $this->currency->format($total['value'], $this->oc->session->data['currency']), ]; } $lastTotal = $totals[count($totals) - 1] ?? false; $data['total'] = $lastTotal ? $lastTotal['value'] : 0; $data['total_text'] = $lastTotal - ? $this->oc->currency->format($lastTotal['value'], $this->oc->session->data['currency']) + ? $this->currency->format($lastTotal['value'], $this->oc->session->data['currency']) : 0; $data['total_products_count'] = $this->oc->cart->countProducts(); } else {