fix(spa): remove html in price for some opencart custom themes
This commit is contained in:
@@ -3,17 +3,20 @@
|
|||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use Cart\Cart;
|
use Cart\Cart;
|
||||||
|
use Cart\Currency;
|
||||||
use Openguru\OpenCartFramework\OpenCart\Decorators\OcRegistryDecorator;
|
use Openguru\OpenCartFramework\OpenCart\Decorators\OcRegistryDecorator;
|
||||||
|
|
||||||
class CartService
|
class CartService
|
||||||
{
|
{
|
||||||
private OcRegistryDecorator $oc;
|
private OcRegistryDecorator $oc;
|
||||||
private Cart $cart;
|
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->oc = $registry;
|
||||||
$this->cart = $cart;
|
$this->cart = $cart;
|
||||||
|
$this->currency = $currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCart(): array
|
public function getCart(): array
|
||||||
@@ -138,8 +141,8 @@ class CartService
|
|||||||
$priceNumeric = $unit_price;
|
$priceNumeric = $unit_price;
|
||||||
$totalNumeric = $unit_price * $product['quantity'];
|
$totalNumeric = $unit_price * $product['quantity'];
|
||||||
|
|
||||||
$price = $this->oc->currency->format($unit_price, $this->oc->session->data['currency']);
|
$price = $this->currency->format($unit_price, $this->oc->session->data['currency']);
|
||||||
$total = $this->oc->currency->format($totalNumeric, $this->oc->session->data['currency']);
|
$total = $this->currency->format($totalNumeric, $this->oc->session->data['currency']);
|
||||||
} else {
|
} else {
|
||||||
$price = false;
|
$price = false;
|
||||||
$total = false;
|
$total = false;
|
||||||
@@ -159,7 +162,7 @@ class CartService
|
|||||||
if ($product['recurring']['trial']) {
|
if ($product['recurring']['trial']) {
|
||||||
$recurring = sprintf(
|
$recurring = sprintf(
|
||||||
$this->oc->language->get('text_trial_description'),
|
$this->oc->language->get('text_trial_description'),
|
||||||
$this->oc->currency->format(
|
$this->currency->format(
|
||||||
$this->oc->tax->calculate(
|
$this->oc->tax->calculate(
|
||||||
$product['recurring']['trial_price'] * $product['quantity'],
|
$product['recurring']['trial_price'] * $product['quantity'],
|
||||||
$product['tax_class_id'],
|
$product['tax_class_id'],
|
||||||
@@ -176,7 +179,7 @@ class CartService
|
|||||||
if ($product['recurring']['duration']) {
|
if ($product['recurring']['duration']) {
|
||||||
$recurring .= sprintf(
|
$recurring .= sprintf(
|
||||||
$this->oc->language->get('text_payment_description'),
|
$this->oc->language->get('text_payment_description'),
|
||||||
$this->oc->currency->format(
|
$this->currency->format(
|
||||||
$this->oc->tax->calculate(
|
$this->oc->tax->calculate(
|
||||||
$product['recurring']['price'] * $product['quantity'],
|
$product['recurring']['price'] * $product['quantity'],
|
||||||
$product['tax_class_id'],
|
$product['tax_class_id'],
|
||||||
@@ -191,7 +194,7 @@ class CartService
|
|||||||
} else {
|
} else {
|
||||||
$recurring .= sprintf(
|
$recurring .= sprintf(
|
||||||
$this->oc->language->get('text_payment_cancel'),
|
$this->oc->language->get('text_payment_cancel'),
|
||||||
$this->oc->currency->format(
|
$this->currency->format(
|
||||||
$this->oc->tax->calculate(
|
$this->oc->tax->calculate(
|
||||||
$product['recurring']['price'] * $product['quantity'],
|
$product['recurring']['price'] * $product['quantity'],
|
||||||
$product['tax_class_id'],
|
$product['tax_class_id'],
|
||||||
@@ -281,14 +284,14 @@ class CartService
|
|||||||
'title' => $total['title'],
|
'title' => $total['title'],
|
||||||
'value' => $total['value'],
|
'value' => $total['value'],
|
||||||
'sort_order' => $total['sort_order'],
|
'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;
|
$lastTotal = $totals[count($totals) - 1] ?? false;
|
||||||
$data['total'] = $lastTotal ? $lastTotal['value'] : 0;
|
$data['total'] = $lastTotal ? $lastTotal['value'] : 0;
|
||||||
$data['total_text'] = $lastTotal
|
$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;
|
: 0;
|
||||||
$data['total_products_count'] = $this->oc->cart->countProducts();
|
$data['total_products_count'] = $this->oc->cart->countProducts();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user