Правки в модуле Prestashop
Старую версия самописного модуля поставили на 1,7,8,7
Всплыла ошибка при работе другого функционала
Notice: Trying to get property 'precision' of non-object in /classes/Context.php on line 498
Fatal error: Uncaught TypeError: Argument 1 passed to Notice: Trying to get property 'precision' of non-object in /sites/testsite.com/classes/Context.php on line 498
Fatal error: Uncaught TypeError: Argument 1 passed to PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision::getPrecision() must be of the type int, null given, called in /sites/testsite.com/classes/Context.php on line 498 and defined in /sites/ikrinka.lv/src/Core/Localization/CLDR/ComputingPrecision.php:41
Stack trace:
#0 /sites/testsite.com/classes/Context.php(498): PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision->getPrecision(NULL)
#1 /sites/testsite.com/classes/order/Order.php(614): ContextCore->getComputingPrecision()
#2 /sites/testsite.com/classes/order/Order.php(667): OrderCore->setProductPrices(Array)
#3 /sites/testsite.com/modules/dg_productlot/dg_productlot.php(121): OrderCore->getProducts()
#4 /sites/testsite.com/modules/dg_productlot/dg_productlot.php(279): Dg_ProductLot->getOrderProducts(20)
#5 /sites/testsite.com/classes/Hook.php(1007): Dg_ProductLot->hookActionOrderStatusUpdate(Array)
#6 /sites/testsite.com/classes/Hook.php(431): HookCore::coreCallHook(Object(Dg_ProductLot), 'hookActionOrder...', in /sites/testsite.com/src/Core/Localization/CLDR/ComputingPrecision.php on line 41
После удаления модуля из хука hookActionOrderStatusUpdate работе другого функционала возобновляется
Код модуля в для этого хука
public function hookActionOrderStatusUpdate($params)
{
$products_with_lots = ModuleTools::getProductsWithLots();
$newOrderStatus = $params['newOrderStatus'];
$id_order = $params['id_order'];
if ($newOrderStatus->id == ConfPL::getConf('STATUS_PROCESS_BUY')
&& !$this->hasOrderStateInOrder($id_order, (int)ConfPL::getConf('STATUS_PROCESS_BUY'))) {
foreach ($this->getOrderProducts($id_order) as $product) {
if (!Pack::isPack($product['product_id'])) {
if (!in_array($product['product_id'], $products_with_lots)) {
continue;
}
$this->processBuyProduct($product, $product['product_quantity']);
} else {
/**
* var Product[] $items
*/
$items = Pack::getItems($product['product_id'], $this->context->language->id);
if (is_array($items) && count($items)) {
foreach ($items as $item) {
$quantity = (int)$product['product_quantity'] * (int)$item->pack_quantity;
$prod = array(
'id_order_detail' => (int)$product['id_order_detail'],
'product_id' => (int)$item->id,
'product_attribute_id' => (int)$item->id_pack_product_attribute,
'product_quantity' => $quantity,
'id_order' => (int)$product['id_order']
);
$this->processBuyProduct($prod, $prod['product_quantity']);
}
}
}
}
} else if ($newOrderStatus->id == ConfPL::getConf('STATUS_REFUND')
&& !$this->hasOrderStateInOrder($id_order, (int)ConfPL::getConf('STATUS_REFUND'))) {
foreach ($this->getOrderProducts($id_order) as $product) {
if (!in_array($product['id_product'], $products_with_lots)) {
continue;
}
$this->processRefundProduct($product);
}
} else {
foreach ($this->getOrderProducts($id_order) as $product) {
if (!in_array($product['id_product'], $products_with_lots)) {
continue;
}
//$this->processBuyProduct($product, $product['product_quantity']);
}
}
$order = new Order($id_order);
$this->updateQuantityProductsByOrder($order);
}
в классе /classes/Context.php такой код (жирным строка 498)
/*** Returns the computing precision according to the current currency return int */
public function getComputingPrecision()
{ if ($this->priceComputingPrecision === null) {
$computingPrecision = new ComputingPrecision();
$this->priceComputingPrecision = $computingPrecision->getPrecision($this->currency->precision);
}
return $this->priceComputingPrecision;
}
и в /Core/Localization/CLDR/ComputingPrecision.php
public function getPrecision(int $displayPrecision) (41строка)
{
// the MULTIPLIER attribute is set to 1 for now, so that it matches display precision
$computingPrecision = $displayPrecision * self::MULTIPLIER;
return ($computingPrecision < self::MINIMAL_VALUE) ? self::MINIMAL_VALUE : $computingPrecision;
}
после
Возможно в самом модуле как-то прописать значение этого параметра задав ему константу в функции для хука?
-
491 15 0 ответ по первой ошибке нагуглил тут:
https://www.prestashop.com/forums/topic/505618-notice-trying-to-get-property-of-non-object/
Актуальные фриланс-проекты в категории PHP
Ищу White-label решение Букмекерской конторы под аренду |
Разработка веб-сайта WordPress
1002 UAH
|
Сломалась корзина WooCommerce (WordPress) — не добавляет товар и не открывается страница корзиныНа сайте интернет-магазина https://www.dobryi-gospodar.com/ (WordPress + WooCommerce) полностью перестала работать функция оформления заказа. При нажатии на кнопку "Добавить в корзину" (как в карточке товара, так и в каталоге) начинается длительная загрузка (индикатор крутится),… CMS, PHP ∙ 2 дня 7 часов назад ∙ 60 ставок |
Функция поиска товаров по изображениюНеобходимо разработать и интегрировать на сайт функциюпоиска товаров по изображению.Что нужно реализоватьКнопка«Поиск по фото»на сайте.Загрузка изображения пользователем: JPG.Поиск визуально похожих товаров в каталоге.Вывод результатов в виде стандартных карточек товаров: фото,… PHP, Веб-программирование ∙ 2 дня 14 часов назад ∙ 45 ставок |
Парсер expireddomains.net
5000 UAH
Нужен парсер expireddomains.net на сайте нужно сначала залогиниться, проблема в том что блокирует ИП при попытке парсить данные, нужно парсить тематические домены по списку ключевых слов, кто не уверен в своих силах не пишите PHP, Веб-программирование ∙ 4 дня 13 часов назад ∙ 51 ставка |