fix(spa): remove html in price for some opencart custom themes
This commit is contained in:
@@ -9,6 +9,7 @@ use Monolog\Handler\RotatingFileHandler;
|
|||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Openguru\OpenCartFramework\ImageTool\ImageTool;
|
use Openguru\OpenCartFramework\ImageTool\ImageTool;
|
||||||
use Openguru\OpenCartFramework\ImageTool\ImageToolInterface;
|
use Openguru\OpenCartFramework\ImageTool\ImageToolInterface;
|
||||||
|
use Openguru\OpenCartFramework\OpenCart\Currency as TelecartCurrency;
|
||||||
use Openguru\OpenCartFramework\OpenCart\Decorators\OcRegistryDecorator;
|
use Openguru\OpenCartFramework\OpenCart\Decorators\OcRegistryDecorator;
|
||||||
use Openguru\OpenCartFramework\Support\Arr;
|
use Openguru\OpenCartFramework\Support\Arr;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@@ -83,7 +84,7 @@ class ControllerExtensionTgshopHandle extends Controller
|
|||||||
});
|
});
|
||||||
|
|
||||||
$app->bind(Url::class, fn() => $this->url);
|
$app->bind(Url::class, fn() => $this->url);
|
||||||
$app->bind(Currency::class, fn() => $this->currency);
|
$app->bind(Currency::class, fn() => new TelecartCurrency($this->registry));
|
||||||
$app->bind(Tax::class, fn() => $this->tax);
|
$app->bind(Tax::class, fn() => $this->tax);
|
||||||
$app->bind(ImageToolInterface::class, fn() => new ImageTool(DIR_IMAGE, HTTPS_SERVER));
|
$app->bind(ImageToolInterface::class, fn() => new ImageTool(DIR_IMAGE, HTTPS_SERVER));
|
||||||
$app->bind(Cart::class, fn() => $this->cart);
|
$app->bind(Cart::class, fn() => $this->cart);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Openguru\OpenCartFramework\OpenCart;
|
||||||
|
|
||||||
|
class Currency extends \Cart\Currency
|
||||||
|
{
|
||||||
|
public function __construct($registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка html мусора, который некоторые OpenCart шаблоны добавляют в цену.
|
||||||
|
*
|
||||||
|
* @param $number
|
||||||
|
* @param $currency
|
||||||
|
* @param $value
|
||||||
|
* @param $format
|
||||||
|
* @return float|string|void
|
||||||
|
*/
|
||||||
|
public function format($number, $currency, $value = '', $format = true)
|
||||||
|
{
|
||||||
|
return PriceFormatter::clean(parent::format($number, $currency, $value, $format));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Openguru\OpenCartFramework\OpenCart;
|
||||||
|
|
||||||
|
class PriceFormatter
|
||||||
|
{
|
||||||
|
public static function clean(string $price): string
|
||||||
|
{
|
||||||
|
return trim(
|
||||||
|
html_entity_decode(
|
||||||
|
strip_tags($price),
|
||||||
|
ENT_QUOTES,
|
||||||
|
'UTF-8'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,10 @@ namespace Cart;
|
|||||||
|
|
||||||
class Currency
|
class Currency
|
||||||
{
|
{
|
||||||
|
public function __construct($registry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function format($number, $currency, $value = '', $format = true)
|
public function format($number, $currency, $value = '', $format = true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user