Проблема: У вас уже максимальное количество этого товара доступное для покупки.

fantats

Постоялец
Регистрация
30 Ноя 2014
Сообщения
327
Реакции
195
Пока все едят в дождь шашлык .... с 1 мая

Короче помогите пожалуйста.
После изменения стандартных файлов корзины (хотел дописать поле пожелания по цвету или уточнения к товару) столкнулся с проблемой, уже замучился искать.
upload_2019-5-1_14-27-54.png
ссылка на сайт Для просмотра ссылки Войди или Зарегистрируйся
 
1. Проверить настройки магазина на предмет использования запасов Для просмотра ссылки Войди или Зарегистрируйся
2. Проверять в карточках товаров состояние запасов Для просмотра ссылки Войди или Зарегистрируйся
Можно все выставить как на скриншотах. В этом случае, управление запасами будет отключено и пользователь сможет заказывать любое количество.
Если не помогло, ищите ошибку в коде.
 
"настройки магазина на предмет использования запасов" - эти настройки выставлено правильно (за количеством и наличии стараемся следить)
Подозрения на ошибки могут быть здесь

....classes\Cart.php

public function updateQty($quantity, $id_product, $id_product_attribute = null, $id_customization = false,
$operator = 'up', $id_address_delivery = 0, Shop $shop = null, $auto_add_cart_rule = true, $note = null)

или тут

....themes\panda\js\modules\blockcart\ajax-cart.js

$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseUri + '?rand=' + new Date().getTime(),
async: true,
cache: false,
dataType : "json",
data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + '&note='+$('#product_note').val()+ ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination:( '' + '&id_customization=' + ((typeof customizationId !== 'undefined') ? customizationId : 0)),
success: function(jsonData,textStatus,jqXHR)

... где note это комментарий
 
Пока все едят в дождь шашлык .... с 1 мая

Короче помогите пожалуйста.
После изменения стандартных файлов корзины (хотел дописать поле пожелания по цвету или уточнения к товару) столкнулся с проблемой, уже замучился искать.
Посмотреть вложение 103689
ссылка на сайт Для просмотра ссылки Войди или Зарегистрируйся
Попробуй вернуть старые файлы .js , проблема устранится? если Да, значит покажите логи F12, вероятно у вас ошибка в JS, ошибки могут это сообщение показывать.
 
Вернул все js (..modules\blockcart, ..themes\panda\js\modules\blockcart) и ....classes\Cart.php Ошибка исчезла.
Залил js - ошибка не выскакивает
Залил ....classes\Cart.php - отображается ошибка
Модифицированный файл приложил (расширение изменил на txt-не разрешало загрузку)
 

Вложения

  • Cart.txt
    171,8 KB · Просмотры: 6
Вернул все js (..modules\blockcart, ..themes\panda\js\modules\blockcart) и ....classes\Cart.php Ошибка исчезла.
Залил js - ошибка не выскакивает
Залил ....classes\Cart.php - отображается ошибка
Модифицированный файл приложил (расширение изменил на txt-не разрешало загрузку)
Вы выложили измененный cart ? оригинальный тоже приложите. вообще пришлите все файлы которые вы изменили, я на тестовом своем посмотрю, к себе залью.
 
Оригинальный это версия Prestashop 1.6.23 ... в папке classes лежит (сейчас нет возможности залить-пишу с телефона)

Какая цена решения проблемы? Кто готов обяснить как исправить ошибку?

Включил отображение ошибок (может
Для просмотра ссылки Войди или Зарегистрируйся

....Получаю картинку ...

Impossible to add the product to the cart.
textStatus: 'error'
errorThrown: ''
responseText:

Warning: openssl_decrypt(:( IV passed is only 7 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /home/uh190269/domains/trikotazhik.pro/public_html/classes/Rijndael.php on line 91

[PrestaShopDatabaseException]
Unknown column 'note' in 'field list'


INSERT INTO `ps_cart_product` (`id_product`, `id_product_attribute`, `id_cart`, `id_address_delivery`, `id_shop`, `quantity`, `note`, `date_add`) VALUES ('54217', '129282', '1', '0', '1', '1', '1', '2019-05-07 17:57:38')

at line 791 in file classes/db/Db.php


786. if ($webservice_call && $errno) {
787. $dbg = debug_backtrace();
788. WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
789. } elseif (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) {
790. if ($sql) {
791. throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');
792. }
793.
794. throw new PrestaShopDatabaseException($this->getMsgError());
795. }
796. }

  • DbCore->displayError - [line 425 - classes/db/Db.php] - [1 Arguments]
    420. $this->result = $this->_query($sql);
    421. }
    422. }
    423.
    424. if (_PS_DEBUG_SQL_) {
    425. $this->displayError($sql);
    426. }
    427.
    428. return $this->result;
    429. }
    430.

    Argument [0]
    INSERT INTO `ps_cart_product` (`id_product`, `id_product_attribute`, `id_cart`, `id_address_delivery`, `id_shop`, `quantity`, `note`, `date_add`) VALUES ('54217', '129282', '1', '0', '1', '1', '1', '2019-05-07 17:57:38')

  • DbCore->query - [line 763 - classes/db/Db.php] - [1 Arguments]
    758. if ($sql instanceof DbQuery) {
    759. $sql = $sql->build();
    760. }
    761.
    762. $this->result = false;
    763. $result = $this->query($sql);
    764. if ($use_cache && $this->is_cache_enabled) {
    765. Cache::getInstance()->deleteQuery($sql);
    766. }
    767.
    768. if (_PS_DEBUG_SQL_) {

    Argument [0]
    INSERT INTO `ps_cart_product` (`id_product`, `id_product_attribute`, `id_cart`, `id_address_delivery`, `id_shop`, `quantity`, `note`, `date_add`) VALUES ('54217', '129282', '1', '0', '1', '1', '1', '2019-05-07 17:57:38')

  • DbCore->q - [line 514 - classes/db/Db.php] - [2 Arguments]
    509. $sql = $insert_keyword.' INTO `'.$table.'` ('.$keys_stringified.') VALUES '.implode(', ', $values_stringified);
    510. if ($type == Db::ON_DUPLICATE_KEY) {
    511. $sql .= ' ON DUPLICATE KEY UPDATE '.substr($duplicate_key_stringified, 0, -1);
    512. }
    513.
    514. return (bool)$this->q($sql, $use_cache);
    515. }
    516.
    517. /**
    518. * Executes an UPDATE query
    519. *

    Argument [0]
    INSERT INTO `ps_cart_product` (`id_product`, `id_product_attribute`, `id_cart`, `id_address_delivery`, `id_shop`, `quantity`, `note`, `date_add`) VALUES ('54217', '129282', '1', '0', '1', '1', '1', '2019-05-07 17:57:38')
    Argument [1]
    1

  • DbCore->insert - [line 1073 - classes/Cart.php] - [2 Arguments]
    1068. 'id_cart' => (int)$this->id,
    1069. 'id_address_delivery' => (int)$id_address_delivery,
    1070. 'id_shop' => $shop->id,
    1071. 'quantity' => (int)$quantity,
    1072. 'note' => $note,
    1073. 'date_add' => date('Y-m-d H:i:s')
    1074. ));
    1075.
    1076. if (!$result_add) {
    1077. return false;
    1078. }

  • CartCore->updateQty - [line 303 - controllers/front/CartController.php] - [9 Arguments]
    298. }
    299.
    300. if (!$this->errors) {
    301. $cart_rules = $this->context->cart->getCartRules();
    302. $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, (isset($this->context->customer->id) ? $this->context->customer->id : 0), true, true, true, $this->context->cart, false, true);
    303. $update_quantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'), $this->id_address_delivery, null, true, $this->note);
    304. if ($update_quantity < 0) {
    305. // If product has attribute, minimal quantity is set with minimal quantity of attribute
    306. $minimal_quantity = ($this->id_product_attribute) ? Attribute::getAttributeMinimalQty($this->id_product_attribute) : $product->minimal_quantity;
    307. $this->errors[] = sprintf(Tools::displayError('You must add %d minimum quantity', !Tools::getValue('ajax')), $minimal_quantity);
    308. } elseif (!$update_quantity) {

    Argument [0]
    1
    Argument [1]
    54217
    Argument [2]
    129282
    Argument [3]
    0
    Argument [4]
    up
    Argument [5]
    0
    Argument [6]
    Shop Object
    (
    [id_shop_group] => 1
    [id_category] => 2
    [id_theme] => 4
    [name] => Трикотажик
    [active] => 1
    [deleted] => 0
    [theme_name] => panda
    [theme_directory] => panda
    [physical_uri] => /
    [virtual_uri] =>
    [domain] => trikotazhik.pro
    [domain_ssl] => trikotazhik.pro
    [group:protected] => ShopGroup Object
    (
    [name] => Default
    [active] => 1
    [share_customer] => 0
    [share_stock] => 0
    [share_order] => 0
    [deleted] => 0
    [id] => 1
    [id_lang:protected] =>
    [id_shop:protected] =>
    [id_shop_list] =>
    [get_shop_from_context:protected] => 1
    [table:protected] => shop_group
    [identifier:protected] => id_shop_group
    [fieldsRequired:protected] => Array
    (
    [0] => name
    )

    [fieldsSize:protected] => Array
    (
    [name] => 64
    )

    [fieldsValidate:protected] => Array
    (
    [name] => isGenericName
    [share_customer] => isBool
    [share_order] => isBool
    [share_stock] => isBool
    [active] => isBool
    [deleted] => isBool
    )

    [fieldsRequiredLang:protected] => Array
    (
    )

    [fieldsSizeLang:protected] => Array
    (
    )

    [fieldsValidateLang:protected] => Array
    (
    )

    [tables:protected] => Array
    (
    )

    [webserviceParameters:protected] => Array
    (
    )

    [image_dir:protected] =>
    [image_format:protected] => jpg
    [def:protected] => Array
    (
    => shop_group
    [primary] => id_shop_group
    [fields] => Array
    (
    [name] => Array
    (
    [type] => 3
    [validate] => isGenericName
    [required] => 1
    [size] => 64
    )

    [share_customer] => Array
    (
    [type] => 2
    [validate] => isBool
    )

    [share_order] => Array
    (
    [type] => 2
    [validate] => isBool
    )

    [share_stock] => Array
    (
    [type] => 2
    [validate] => isBool
    )

    [active] => Array
    (
    [type] => 2
    [validate] => isBool
    )

    [deleted] => Array
    (
    [type] => 2
    [validate] => isBool
    )

    )

    [classname] => ShopGroup
    )

    [update_fields:protected] =>
    [force_id] =>
    )

    [webserviceParameters:protected] => Array
    (
    [fields] => Array
    (
    [id_shop_group] => Array
    (
    [xlink_resource] => shop_groups
    )

    [id_category] => Array
    (
    )

    [id_theme] => Array
    (
    )

    )

    )

    [id] => 1
    [id_lang:protected] =>
    [id_shop:protected] =>
    [id_shop_list] =>
    [get_shop_from_context:protected] => 1
    [table:protected] => shop
    [identifier:protected] => id_shop
    [fieldsRequired:protected] => Array
    (
    [0] => name
    [1] => id_theme
    [2] => id_category
    [3] => id_shop_group
    )

    [fieldsSize:protected] => Array
    (
    [name] => 64
    )

    [fieldsValidate:protected] => Array
    (
    [active] => isBool
    [deleted] => isBool
    [name] => isGenericName
    )

    [fieldsRequiredLang:protected] => Array
    (
    )

    [fieldsSizeLang:protected] => Array
    (
    )

    [fieldsValidateLang:protected] => Array
    (
    )

    [tables:protected] => Array
    (
    )

    [image_dir:protected] =>
    [image_format:protected] => jpg
    [def:protected] => Array
    (
    => shop
    [primary] => id_shop
    [fields] => Array
    (
    [active] => Array
    (
    [type] => 2
    [validate] => isBool
    )

    [deleted] => Array
    (
    [type] => 2
    [validate] => isBool
    )

    [name] => Array
    (
    [type] => 3
    [validate] => isGenericName
    [required] => 1
    [size] => 64
    )

    [id_theme] => Array
    (
    [type] => 1
    [required] => 1
    )

    [id_category] => Array
    (
    [type] => 1
    [required] => 1
    )

    [id_shop_group] => Array
    (
    [type] => 1
    [required] => 1
    )

    )

    [classname] => Shop
    )

    [update_fields:protected] =>
    [force_id] =>
    [theme_id] => 4
    )

    Argument [7]
    1
    Argument [8]
    1


    [*] CartControllerCore->processChangeProductInCart - [line 76 - controllers/front/CartController.php]
    71. public function postProcess()
    72. {
    73. // Update the cart ONLY if $this->cookies are available, in order to avoid ghost carts created by bots
    74. if ($this->context->cookie->exists() && !$this->errors && !($this->context->customer->isLogged() && !$this->isTokenValid())) {
    75. if (Tools::getIsset('add') || Tools::getIsset('update')) {
    76. $this->processChangeProductInCart();
    77. } elseif (Tools::getIsset('delete')) {
    78. $this->processDeleteProductInCart();
    79. } elseif (Tools::getIsset('changeAddressDelivery')) {
    80. $this->processChangeProductAddressDelivery();
    81. } elseif (Tools::getIsset('allowSeperatedPackage')) {


    [*] CartControllerCore->postProcess - [line 72 - override/classes/controller/FrontController.php]
    67. $this->init();
    68. if ($this->checkAccess())
    69. {
    70. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
    71. $this->setMedia();
    72. $this->postProcess();
    73. if (!empty($this->redirect_after))
    74. $this->redirect();
    75. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
    76. $this->initHeader();
    77. if ($this->viewAccess()) {


    [*] FrontController->run - [line 367 - classes/Dispatcher.php]
    362. if (isset($params_hook_action_dispatcher)) {
    363. Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
    364. }
    365.
    366. // Running controller
    367. $controller->run();
    368. } catch (PrestaShopException $e) {
    369. $e->displayMessage();
    370. }
    371. }
    372.


    [*] DispatcherCore->dispatch - [line 28 - index.php]
    23. * @license Для просмотра ссылки Войди или Зарегистрируйся Open Software License (OSL 3.0)
    24. * International Registered Trademark & Property of PrestaShop SA
    25. */
    26.
    27. require(dirname(__FILE__).'/config/config.inc.php');
    28. Dispatcher::getInstance()->dispatch();



кто-то поможет ?
 
Последнее редактирование модератором:
на странице категории Для просмотра ссылки Войди или Зарегистрируйся когда бросаеш в корзину выскакивает сообщение
upload_2019-5-17_20-4-29.png

Код функции
Код:
 protected function processChangeProductInCart()
    {

$rk=explode(',',$_POST['id_product']);
$this->id_product=$rk[0];
$this->note=$rk[1];    /**This on line 232 */

        $mode = (Tools::getIsset('update') && $this->id_product) ? 'update' : 'add';

        if ($this->qty == 0) {
            $this->errors[] = Tools::displayError('Null quantity.', !Tools::getValue('ajax'));
        } elseif (!$this->id_product) {
            $this->errors[] = Tools::displayError('Product not found', !Tools::getValue('ajax'));
        }

        $product = new Product($this->id_product, true, $this->context->language->id);
        if (!$product->id || !$product->active || !$product->checkAccess($this->context->cart->id_customer)) {
            $this->errors[] = Tools::displayError('This product is no longer available.', !Tools::getValue('ajax'));
            return;
        }

        $qty_to_check = $this->qty;
        $cart_products = $this->context->cart->getProducts();

        if (is_array($cart_products)) {
            foreach ($cart_products as $cart_product) {
                if ((!isset($this->id_product_attribute) || $cart_product['id_product_attribute'] == $this->id_product_attribute) &&
                    (isset($this->id_product) && $cart_product['id_product'] == $this->id_product)) {
                    $qty_to_check = $cart_product['cart_quantity'];

                    if (Tools::getValue('op', 'up') == 'down') {
                        $qty_to_check -= $this->qty;
                    } else {
                        $qty_to_check += $this->qty;
                    }

                    break;
                }
            }
        }

не могу добить задачу
 
Последнее редактирование:
Назад
Сверху