Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

ilyash

Newbie
  
  • Posts

    5
  • Joined

  • Last visited

ilyash's Achievements

Newbie

Newbie (1/14)

  • Dedicated Rare
  • First Post
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

1

Reputation

  1. В чистом виде да. Вместо количества можно написать размер или заменить слайдером. Чуть доработать если надо дробное число вместо целого. В опции указать цену за единицу длинны. Если укаывать за 1м например, то в обработке корзины (в модуле) добавить деление на 100. Но в случае более сложных вычислений - создать пост обработчик отдельный. Туда перенести все вычисления по продукту с передачей опций. И делать два запроса при добавлении в корзину: 1. assinc: false к обработчику цены, второй уже с полученными параметрами в корзину.
  2. тут как раз не то. нужно формирование динамической цены в зависимости от выбираемых параметров или расчет по формуле. фактически, то что я привел выше, можна обрабатывать и на стороне сервера post запросом, тогда пропадет риск занижения цены
  3. Вопрос решил таким образом. Добавил input type=hidden к отправке формы с name=custom_price В POST запрос в обработчике корзины добавил custom_price. В cart.php в функцию add добавил $custom_price = $_POST['custom_price']; $_SESSION['custom'] = $custom_price; и в library/cart.php в начало idex if (!isset($_SESSION['custom'])) { $custom_price = 0; } else { $custom_price = $_SESSION['custom']; } потом находим массив из getProduct и добавляем к нему условие if ($custom_price == 0) { $this->data[$key] = array( 'key' => $key, 'product_id' => $product_query->row['product_id'], 'name' => $product_query->row['name'], 'model' => $product_query->row['model'], 'shipping' => $product_query->row['shipping'], 'image' => $product_query->row['image'], 'option' => $option_data, 'download' => $download_data, 'quantity' => $quantity, 'minimum' => $product_query->row['minimum'], 'subtract' => $product_query->row['subtract'], 'stock' => $stock, 'price' => ($price + $option_price), 'total' => ($price + $option_price) * $quantity, 'reward' => $reward * $quantity, 'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $quantity : 0), 'tax_class_id' => $product_query->row['tax_class_id'], 'weight' => ($product_query->row['weight'] + $option_weight) * $quantity, 'weight_class_id' => $product_query->row['weight_class_id'], 'length' => $product_query->row['length'], 'width' => $product_query->row['width'], 'height' => $product_query->row['height'], 'length_class_id' => $product_query->row['length_class_id'] ); } else { $this->data[$key] = array( 'key' => $key, 'product_id' => $product_query->row['product_id'], 'name' => $product_query->row['name'], 'model' => $product_query->row['model'], 'shipping' => $product_query->row['shipping'], 'image' => $product_query->row['image'], 'option' => $option_data, 'download' => $download_data, 'quantity' => $quantity, 'minimum' => $product_query->row['minimum'], 'subtract' => $product_query->row['subtract'], 'stock' => $stock, 'price' => $custom_price,//($price + $option_price), 'total' => $custom_price * $quantity,//($price + $option_price) * $quantity, 'reward' => $reward * $quantity, 'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $quantity : 0), 'tax_class_id' => $product_query->row['tax_class_id'], 'weight' => ($product_query->row['weight'] + $option_weight) * $quantity, 'weight_class_id' => $product_query->row['weight_class_id'], 'length' => $product_query->row['length'], 'width' => $product_query->row['width'], 'height' => $product_query->row['height'], 'length_class_id' => $product_query->row['length_class_id'] ); Все работает на ура! Удачи! Трудился всю ночь, перегрыз все процедуры формирования корзины, но более адекватного решения не нашел. Да и под конец при передаче json обратно нужно аннулировать сессию!!!
Guest
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.