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

andriy_gritsyuk

Newbie
  
  • Posts

    13
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

andriy_gritsyuk's Achievements

Apprentice

Apprentice (3/14)

  • Collaborator
  • First Post
  • Conversation Starter
  • One Month Later
  • Week One Done

Recent Badges

2

Reputation

  1. spectre - Большое спасибо Вам за помощь! Ребят, кто еще сомневается - поверьте, это действительно мастер своего дела!
  2. Проблема в том, что мне нужно задавать разный минимум для разных групп пользователей в скидках. А как это сделать по другому и без модулей не нашел
  3. Сколько возьмете за исправление? Если конечно можете это сделать
  4. Интересно почему так трудно помочь или хотя бы подсказать что нужно сделать? Я ведь не против учится, но как это можно сделать если не то что материалов никаких нет, но и "эксперты" не хотят проконсультировать
  5. Вот эти файлы. Контроллер: <?php class ControllerCommonCart extends Controller { public function index() { $this->load->language('common/cart'); // Totals $this->load->model('setting/extension'); $totals = array(); $taxes = $this->cart->getTaxes(); $total = 0; // Because __call can not keep var references so we put them into an array. $total_data = array( 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total ); // Display prices if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $sort_order = array(); $results = $this->model_setting_extension->getExtensions('total'); foreach ($results as $key => $value) { $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); } array_multisort($sort_order, SORT_ASC, $results); foreach ($results as $result) { if ($this->config->get('total_' . $result['code'] . '_status')) { $this->load->model('extension/total/' . $result['code']); // We have to put the totals in an array so that they pass by reference. $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); } } $sort_order = array(); foreach ($totals as $key => $value) { $sort_order[$key] = $value['sort_order']; } array_multisort($sort_order, SORT_ASC, $totals); } $data['text_items'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total, $this->session->data['currency'])); $this->load->model('tool/image'); $this->load->model('tool/upload'); $data['products'] = array(); foreach ($this->cart->getProducts() as $product) { if ($product['image']) { $image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height')); } $option_data = array(); foreach ($product['option'] as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); if ($upload_info) { $value = $upload_info['name']; } else { $value = ''; } } $option_data[] = array( 'name' => $option['name'], 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value), 'type' => $option['type'] ); } // Display prices if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')); $price = $this->currency->format($unit_price, $this->session->data['currency']); $total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']); } else { $price = false; $total = false; } $data['products'][] = array( 'cart_id' => $product['cart_id'], 'thumb' => $image, 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''), 'quantity' => $product['quantity'], 'price' => $price, 'total' => $total, 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']) ); } // Gift Voucher $data['vouchers'] = array(); if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $key => $voucher) { $data['vouchers'][] = array( 'key' => $key, 'description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency']) ); } } $data['totals'] = array(); foreach ($totals as $total) { $data['totals'][] = array( 'title' => $total['title'], 'text' => $this->currency->format($total['value'], $this->session->data['currency']), ); } $data['cart'] = $this->url->link('checkout/cart'); $data['checkout'] = $this->url->link('checkout/checkout', '', true); return $this->load->view('common/cart', $data); } public function info() { $this->response->setOutput($this->index()); } } system/library/cart/cart.php: <?php namespace Cart; class Cart { private $data = array(); public function __construct($registry) { $this->config = $registry->get('config'); $this->customer = $registry->get('customer'); $this->session = $registry->get('session'); $this->db = $registry->get('db'); $this->tax = $registry->get('tax'); $this->weight = $registry->get('weight'); // Remove all the expired carts with no customer ID $this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE (api_id > '0' OR customer_id = '0') AND date_added < DATE_SUB(NOW(), INTERVAL 1 HOUR)"); if ($this->customer->getId()) { // We want to change the session ID on all the old items in the customers cart $this->db->query("UPDATE " . DB_PREFIX . "cart SET session_id = '" . $this->db->escape($this->session->getId()) . "' WHERE api_id = '0' AND customer_id = '" . (int)$this->customer->getId() . "'"); // Once the customer is logged in we want to update the customers cart $cart_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '0' AND customer_id = '0' AND session_id = '" . $this->db->escape($this->session->getId()) . "'"); foreach ($cart_query->rows as $cart) { $this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '" . (int)$cart['cart_id'] . "'"); // The advantage of using $this->add is that it will check if the products already exist and increaser the quantity if necessary. $this->add($cart['product_id'], $cart['quantity'], json_decode($cart['option']), $cart['recurring_id']); } } } public function getProducts() { $product_data = array(); $cart_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "'"); foreach ($cart_query->rows as $cart) { $stock = true; $product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_store p2s LEFT JOIN " . DB_PREFIX . "product p ON (p2s.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND p2s.product_id = '" . (int)$cart['product_id'] . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.date_available <= NOW() AND p.status = '1'"); if ($product_query->num_rows && ($cart['quantity'] > 0)) { $option_price = 0; $option_points = 0; $option_weight = 0; $option_data = array(); foreach (json_decode($cart['option']) as $product_option_id => $value) { $option_query = $this->db->query("SELECT po.product_option_id, po.option_id, od.name, o.type FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_option_id = '" . (int)$product_option_id . "' AND po.product_id = '" . (int)$cart['product_id'] . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($option_query->num_rows) { if ($option_query->row['type'] == 'select' || $option_query->row['type'] == 'radio') { $option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.subtract, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$value . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($option_value_query->num_rows) { if ($option_value_query->row['price_prefix'] == '+') { $option_price += $option_value_query->row['price']; } elseif ($option_value_query->row['price_prefix'] == '-') { $option_price -= $option_value_query->row['price']; } if ($option_value_query->row['points_prefix'] == '+') { $option_points += $option_value_query->row['points']; } elseif ($option_value_query->row['points_prefix'] == '-') { $option_points -= $option_value_query->row['points']; } if ($option_value_query->row['weight_prefix'] == '+') { $option_weight += $option_value_query->row['weight']; } elseif ($option_value_query->row['weight_prefix'] == '-') { $option_weight -= $option_value_query->row['weight']; } if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $cart['quantity']))) { $stock = false; } $option_data[] = array( 'product_option_id' => $product_option_id, 'product_option_value_id' => $value, 'option_id' => $option_query->row['option_id'], 'option_value_id' => $option_value_query->row['option_value_id'], 'name' => $option_query->row['name'], 'value' => $option_value_query->row['name'], 'type' => $option_query->row['type'], 'quantity' => $option_value_query->row['quantity'], 'subtract' => $option_value_query->row['subtract'], 'price' => $option_value_query->row['price'], 'price_prefix' => $option_value_query->row['price_prefix'], 'points' => $option_value_query->row['points'], 'points_prefix' => $option_value_query->row['points_prefix'], 'weight' => $option_value_query->row['weight'], 'weight_prefix' => $option_value_query->row['weight_prefix'] ); } } elseif ($option_query->row['type'] == 'checkbox' && is_array($value)) { foreach ($value as $product_option_value_id) { $option_value_query = $this->db->query("SELECT pov.option_value_id, pov.quantity, pov.subtract, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix, ovd.name FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (pov.option_value_id = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($option_value_query->num_rows) { if ($option_value_query->row['price_prefix'] == '+') { $option_price += $option_value_query->row['price']; } elseif ($option_value_query->row['price_prefix'] == '-') { $option_price -= $option_value_query->row['price']; } if ($option_value_query->row['points_prefix'] == '+') { $option_points += $option_value_query->row['points']; } elseif ($option_value_query->row['points_prefix'] == '-') { $option_points -= $option_value_query->row['points']; } if ($option_value_query->row['weight_prefix'] == '+') { $option_weight += $option_value_query->row['weight']; } elseif ($option_value_query->row['weight_prefix'] == '-') { $option_weight -= $option_value_query->row['weight']; } if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $cart['quantity']))) { $stock = false; } $option_data[] = array( 'product_option_id' => $product_option_id, 'product_option_value_id' => $product_option_value_id, 'option_id' => $option_query->row['option_id'], 'option_value_id' => $option_value_query->row['option_value_id'], 'name' => $option_query->row['name'], 'value' => $option_value_query->row['name'], 'type' => $option_query->row['type'], 'quantity' => $option_value_query->row['quantity'], 'subtract' => $option_value_query->row['subtract'], 'price' => $option_value_query->row['price'], 'price_prefix' => $option_value_query->row['price_prefix'], 'points' => $option_value_query->row['points'], 'points_prefix' => $option_value_query->row['points_prefix'], 'weight' => $option_value_query->row['weight'], 'weight_prefix' => $option_value_query->row['weight_prefix'] ); } } } elseif ($option_query->row['type'] == 'text' || $option_query->row['type'] == 'textarea' || $option_query->row['type'] == 'file' || $option_query->row['type'] == 'date' || $option_query->row['type'] == 'datetime' || $option_query->row['type'] == 'time') { $option_data[] = array( 'product_option_id' => $product_option_id, 'product_option_value_id' => '', 'option_id' => $option_query->row['option_id'], 'option_value_id' => '', 'name' => $option_query->row['name'], 'value' => $value, 'type' => $option_query->row['type'], 'quantity' => '', 'subtract' => '', 'price' => '', 'price_prefix' => '', 'points' => '', 'points_prefix' => '', 'weight' => '', 'weight_prefix' => '' ); } } } $price = $product_query->row['price']; // Product Discounts $discount_quantity = 0; foreach ($cart_query->rows as $cart_2) { if ($cart_2['product_id'] == $cart['product_id']) { $discount_quantity += $cart_2['quantity']; } } $product_discount_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$cart['product_id'] . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity <= '" . (int)$discount_quantity . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity DESC, priority ASC, price ASC LIMIT 1"); if ($product_discount_query->num_rows) { $price = $product_discount_query->row['price']; } // Product Specials $product_special_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$cart['product_id'] . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY priority ASC, price ASC LIMIT 1"); if ($product_special_query->num_rows) { $price = $product_special_query->row['price']; } // Reward Points $product_reward_query = $this->db->query("SELECT points FROM " . DB_PREFIX . "product_reward WHERE product_id = '" . (int)$cart['product_id'] . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); if ($product_reward_query->num_rows) { $reward = $product_reward_query->row['points']; } else { $reward = 0; } // Downloads $download_data = array(); $download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_download p2d LEFT JOIN " . DB_PREFIX . "download d ON (p2d.download_id = d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE p2d.product_id = '" . (int)$cart['product_id'] . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); foreach ($download_query->rows as $download) { $download_data[] = array( 'download_id' => $download['download_id'], 'name' => $download['name'], 'filename' => $download['filename'], 'mask' => $download['mask'] ); } // Stock if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) { $stock = false; } $recurring_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r LEFT JOIN " . DB_PREFIX . "product_recurring pr ON (r.recurring_id = pr.recurring_id) LEFT JOIN " . DB_PREFIX . "recurring_description rd ON (r.recurring_id = rd.recurring_id) WHERE r.recurring_id = '" . (int)$cart['recurring_id'] . "' AND pr.product_id = '" . (int)$cart['product_id'] . "' AND rd.language_id = " . (int)$this->config->get('config_language_id') . " AND r.status = 1 AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); if ($recurring_query->num_rows) { $recurring = array( 'recurring_id' => $cart['recurring_id'], 'name' => $recurring_query->row['name'], 'frequency' => $recurring_query->row['frequency'], 'price' => $recurring_query->row['price'], 'cycle' => $recurring_query->row['cycle'], 'duration' => $recurring_query->row['duration'], 'trial' => $recurring_query->row['trial_status'], 'trial_frequency' => $recurring_query->row['trial_frequency'], 'trial_price' => $recurring_query->row['trial_price'], 'trial_cycle' => $recurring_query->row['trial_cycle'], 'trial_duration' => $recurring_query->row['trial_duration'] ); } else { $recurring = false; } $product_data[] = array( 'cart_id' => $cart['cart_id'], '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' => $cart['quantity'], 'minimum' => $product_query->row['minimum'], 'subtract' => $product_query->row['subtract'], 'stock' => $stock, 'price' => ($price + $option_price), 'total' => ($price + $option_price) * $cart['quantity'], 'reward' => $reward * $cart['quantity'], 'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $cart['quantity'] : 0), 'tax_class_id' => $product_query->row['tax_class_id'], 'weight' => ($product_query->row['weight'] + $option_weight) * $cart['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'], 'recurring' => $recurring ); } else { $this->remove($cart['cart_id']); } } return $product_data; } public function add($product_id, $quantity = 1, $option = array(), $recurring_id = 0) { $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "' AND product_id = '" . (int)$product_id . "' AND recurring_id = '" . (int)$recurring_id . "' AND `option` = '" . $this->db->escape(json_encode($option)) . "'"); if (!$query->row['total']) { $this->db->query("INSERT INTO " . DB_PREFIX . "cart SET api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "', customer_id = '" . (int)$this->customer->getId() . "', session_id = '" . $this->db->escape($this->session->getId()) . "', product_id = '" . (int)$product_id . "', recurring_id = '" . (int)$recurring_id . "', `option` = '" . $this->db->escape(json_encode($option)) . "', quantity = '" . (int)$quantity . "', date_added = NOW()"); } else { $this->db->query("UPDATE " . DB_PREFIX . "cart SET quantity = (quantity + " . (int)$quantity . ") WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "' AND product_id = '" . (int)$product_id . "' AND recurring_id = '" . (int)$recurring_id . "' AND `option` = '" . $this->db->escape(json_encode($option)) . "'"); } } public function update($cart_id, $quantity) { $this->db->query("UPDATE " . DB_PREFIX . "cart SET quantity = '" . (int)$quantity . "' WHERE cart_id = '" . (int)$cart_id . "' AND api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "'"); } public function remove($cart_id) { $this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '" . (int)$cart_id . "' AND api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "'"); } public function clear() { $this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "'"); } public function getRecurringProducts() { $product_data = array(); foreach ($this->getProducts() as $value) { if ($value['recurring']) { $product_data[] = $value; } } return $product_data; } public function getWeight() { $weight = 0; foreach ($this->getProducts() as $product) { if ($product['shipping']) { $weight += $this->weight->convert($product['weight'], $product['weight_class_id'], $this->config->get('config_weight_class_id')); } } return $weight; } public function getSubTotal() { $total = 0; foreach ($this->getProducts() as $product) { $total += $product['total']; } return $total; } public function getTaxes() { $tax_data = array(); foreach ($this->getProducts() as $product) { if ($product['tax_class_id']) { $tax_rates = $this->tax->getRates($product['price'], $product['tax_class_id']); foreach ($tax_rates as $tax_rate) { if (!isset($tax_data[$tax_rate['tax_rate_id']])) { $tax_data[$tax_rate['tax_rate_id']] = ($tax_rate['amount'] * $product['quantity']); } else { $tax_data[$tax_rate['tax_rate_id']] += ($tax_rate['amount'] * $product['quantity']); } } } } return $tax_data; } public function getTotal() { $total = 0; foreach ($this->getProducts() as $product) { $total += $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']; } return $total; } public function countProducts() { $product_total = 0; $products = $this->getProducts(); foreach ($products as $product) { $product_total += $product['quantity']; } return $product_total; } public function hasProducts() { return count($this->getProducts()); } public function hasRecurringProducts() { return count($this->getRecurringProducts()); } public function hasStock() { foreach ($this->getProducts() as $product) { if (!$product['stock']) { return false; } } return true; } public function hasShipping() { foreach ($this->getProducts() as $product) { if ($product['shipping']) { return true; } } return false; } public function hasDownload() { foreach ($this->getProducts() as $product) { if ($product['download']) { return true; } } return false; } } Подскажите пожалуйста что нужно сделать чтобы все заработало как надо
  6. Вот кстати весь файл: {{ header }} <div id="product-product" class="container"> <div class="row">{{ column_left }} {% if column_left and column_right %} {% set class = 'col-sm-6' %} {% elseif column_left or column_right %} {% set class = 'col-sm-9' %} {% else %} {% set class = 'col-sm-12' %} {% endif %} <div id="content" class="{{ class }}">{{ content_top }} <div class="row"> {% if column_left or column_right %} {% set class = 'col-sm-6' %} {% else %} {% set class = 'col-sm-8' %} {% endif %} <div class="{{ class }}"> {% if thumb or images %} <img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /> <div class="image-bottom"></div> {% endif %} </div> {% if column_left or column_right %} {% set class = 'col-sm-6' %} {% else %} {% set class = 'col-sm-4' %} {% endif %} <div class="{{ class }}"> <h1>{{ heading_title }}</h1> <ul class="list-unstyled"> <li class="model">{{ model }}</li> <li class="sku">{{ sku }}</li> </ul> <div class="description">{{ description }}</div> {% if price %} <div class="price-title">Dostępny na zamówienie</div> <div class="block-price"> {% if not special %} <div class="item-price"> {% if discounts %} {% for discount in discounts %} {{ discount.price }} {% endfor %} {% else %} {{ price }} {% endif %} </div> {% else %} <div><span style="text-decoration: line-through;">{{ price }}</span></div> <div> <h2>{{ special }}</h2> </div> {% endif %} </div> {% endif %} <div id="product" class="blk-buy"> <div class="form-group buy"> <label class="control-label" for="input-quantity">ILOŚĆ</label> <div class="add-cart"> <input type="number" name="quantity" min="{% if discounts %}{% for discount in discounts %}{{ discount.quantity }}{% endfor %}{% else %}{{ minimum }}{% endif %}" value="{% if discounts %}{% for discount in discounts %}{{ discount.quantity }}{% endfor %}{% else %}{{ minimum }}{% endif %}" size="2" id="input-quantity" class="form-control" /> <input type="hidden" name="product_id" value="{{ product_id }}" /> <button type="button" id="button-cart" data-loading-text="{{ text_loading }}" class="btn btn-primary btn-lg btn-block">Dodaj do koszyka</button> </div> </div> {% if minimum > 1 %} <div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_minimum }}</div> {% endif %}</div> </div> </div> </div> </div> </div> <div class="div-block-43"></div> <div class="container"> <div class="block-reviews"> <div class="reviews">Opinie</div> <div class="tab-content"> {% if review_status %} <div class="tab-pane active" id="tab-review"> <div id="review"></div> </div> <form class="form-horizontal-2" id="form-review"> {% if review_guest %} <div class="form-content"> <h2>Napisać recenzję</h2> <div class="form-group required"> <div class="col-sm-12"> <label class="control-label" for="input-name">TWOJE IMIĘ</label> <input type="text" name="name" value="{{ customer_name }}" id="input-name" class="form-control" /> </div> </div> <div class="form-group required"> <div class="col-sm-12"> <label class="control-label" for="input-review">SWOJĄ OPINIĘ</label> <textarea name="text" rows="2" id="input-review" class="form-control"></textarea> <div class="help-block"><span style="color: #FF0000;">Uwaga:</span> znaczniki HTML nie są obsługiwane! Użyj zwykłego tekstu.</div> </div> </div> <div class="form-group rating required"> <div class="col-sm-12"> <label class="control-label">OCENA</label> &nbsp;&nbsp;&nbsp; Źle&nbsp; <input type="radio" name="rating" value="1" /> &nbsp; <input type="radio" name="rating" value="2" /> &nbsp; <input type="radio" name="rating" value="3" /> &nbsp; <input type="radio" name="rating" value="4" /> &nbsp; <input type="radio" name="rating" value="5" checked /> &nbsp;Dobry</div> </div> {{ captcha }} <button type="button" id="button-review" data-loading-text="Wgrywanie..." class="btn btn-primary">Wysłać</button> <a class="close-form-btn" href="javascript:PopUpHide()">Zamknąć</a> {% else %} <div class="form-content"> <h2>Napisać recenzję</h2> <div class="review-login">Proszę <a href="/login">zaloguj sie</a> lub <a href="/create-account">utwórz konto</a> przed napisaniem recenzji</div> <a class="close-form-btn" href="javascript:PopUpHide()">Zamknąć</a> </div> {% endif %} </div> </form> {% endif %}</div> <div class="add-review"><a class="add-review-btn" href="javascript:PopUpShow()">Dodaj Opinie</a></div> </div> <div class="container"> {% if products %} <h3 class="heading-19">Nasze Rekomendacje</h3> <div class="row"> {% set i = 0 %} {% for product in products %} {% if column_left and column_right %} {% set class = 'col-xs-8 col-sm-6' %} {% elseif column_left or column_right %} {% set class = 'col-xs-6 col-md-4' %} {% else %} {% set class = 'col-xs-6 col-sm-3' %} {% endif %} <div class="{{ class }}"> <div class="product-thumb transition"> <div class="image"> <a href="{{ product.href }}"> <img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive" /> </a> </div> <div class="caption"></div> <div class="new-prod-desc"> <a class="product-title" href="{{ product.href }}">{{ product.name }}</a> <a class="cat-prod" href="#">Zobacz Produkt</a> {% if product.price %} <p class="price"> {% if not product.special %} {{ product.price }} {% else %} <p class="price">{{ product.special }}</p> {% endif %} </p> {% endif %} </div> </div> </div> {% if column_left and column_right and (i + 1) % 2 == 0 %} <div class="clearfix visible-md visible-sm"></div> {% elseif column_left or column_right and (i + 1) % 3 == 0 %} <div class="clearfix visible-md"></div> {% elseif (i + 1) % 4 == 0 %} <div class="clearfix visible-md"></div> {% endif %} {% set i = i + 1 %} {% endfor %} </div> {% endif %} </div> </div> {{ content_bottom }} {{ column_right }} <script> $(document).ready(function(){ PopUpHide(); }); function PopUpShow(){ $("#form-review").show(); } function PopUpHide(){ $("#form-review").hide(); } </script> <script type="text/javascript"><!-- $('select[name=\'recurring_id\'], input[name="quantity"]').change(function(){ $.ajax({ url: 'index.php?route=product/product/getRecurringDescription', type: 'post', data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'), dataType: 'json', beforeSend: function() { $('#recurring-description').html(''); }, success: function(json) { $('.alert-dismissible, .text-danger').remove(); if (json['success']) { $('#recurring-description').html(json['success']); } } }); }); //--></script> <script type="text/javascript"><!-- $('#button-cart').on('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'), dataType: 'json', beforeSend: function() { $('#button-cart').button('loading'); }, complete: function() { $('#button-cart').button('reset'); }, success: function(json) { $('.alert-dismissible, .text-danger').remove(); $('.form-group').removeClass('has-error'); if (json['error']) { if (json['error']['option']) { for (i in json['error']['option']) { var element = $('#input-option' + i.replace('_', '-')); if (element.parent().hasClass('input-group')) { element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); } else { element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); } } } if (json['error']['recurring']) { $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>'); } // Highlight any found errors $('.text-danger').parent().addClass('has-error'); } if (json['success']) { $('.breadcrumb').after('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>'); $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); //$('html, body').animate({ scrollTop: 0 }, 'slow'); $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); //--></script> <script type="text/javascript"><!-- $('.date').datetimepicker({ language: '{{ datepicker }}', pickTime: false }); $('.datetime').datetimepicker({ language: '{{ datepicker }}', pickDate: true, pickTime: true }); $('.time').datetimepicker({ language: '{{ datepicker }}', pickDate: false }); $('button[id^=\'button-upload\']').on('click', function() { var node = this; $('#form-upload').remove(); $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>'); $('#form-upload input[name=\'file\']').trigger('click'); if (typeof timer != 'undefined') { clearInterval(timer); } timer = setInterval(function() { if ($('#form-upload input[name=\'file\']').val() != '') { clearInterval(timer); $.ajax({ url: 'index.php?route=tool/upload', type: 'post', dataType: 'json', data: new FormData($('#form-upload')[0]), cache: false, contentType: false, processData: false, beforeSend: function() { $(node).button('loading'); }, complete: function() { $(node).button('reset'); }, success: function(json) { $('.text-danger').remove(); if (json['error']) { $(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>'); } if (json['success']) { alert(json['success']); $(node).parent().find('input').val(json['code']); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } }, 500); }); //--></script> <script type="text/javascript"><!-- $('#review').delegate('.pagination a', 'click', function(e) { e.preventDefault(); $('#review').fadeOut('slow'); $('#review').load(this.href); $('#review').fadeIn('slow'); }); $('#review').load('index.php?route=product/product/review&product_id={{ product_id }}'); $('#button-review').on('click', function() { $.ajax({ url: 'index.php?route=product/product/write&product_id={{ product_id }}', type: 'post', dataType: 'json', data: $("#form-review").serialize(), beforeSend: function() { $('#button-review').button('loading'); }, complete: function() { $('#button-review').button('reset'); }, success: function(json) { $('.alert-dismissible').remove(); if (json['error']) { $('#review').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>'); } if (json['success']) { $('#review').after('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>'); $('input[name=\'name\']').val(''); $('textarea[name=\'text\']').val(''); $('input[name=\'rating\']:checked').prop('checked', false); } } }); }); $(document).ready(function() { $('.thumbnails').magnificPopup({ type:'image', delegate: 'a', gallery: { enabled: true } }); }); //--></script> {{ footer }} Версия ocStore 3.0.3.7
  7. Привет всем! Прошу помощи с устранением ошибки. Добавил функцию минимального значения в зависимости от группы пользователей с помощью скидок discount, при этом изменил всего несколько строк в файле product.twig: <input type="number" name="quantity" min="{% if discounts %}{% for discount in discounts %}{{ discount.quantity }}{% endfor %}{% else %}{{ minimum }}{% endif %}" value="{% if discounts %}{% for discount in discounts %}{{ discount.quantity }}{% endfor %}{% else %}{{ minimum }}{% endif %}" size="2" id="input-quantity" class="form-control" /> А также: <div class="block-price"> {% if not special %} <div class="item-price"> {% if discounts %} {% for discount in discounts %} {{ discount.price }} {% endfor %} {% else %} {{ price }} {% endif %} </div> {% else %} <div><span style="text-decoration: line-through;">{{ price }}</span></div> <div> <h2>{{ special }}</h2> </div> {% endif %} </div> Проблема заключается в следующем: если не использовать скидки, то товары добавляются в корзину отлично. Но как только добавить скидки к товару, то вместо скидки в корзину отправляется обычная цена, а вместо нужного количества только 1 единица (к примеру, если минимальное количество 10, то добавляется 1 шт., а если хочешь добавить еще то приходится заново возвращаться к товару и добавлять заново, но минимум все также передается как 1 шт.). При этом итоговая сумма в корзине также формируется по старой цене и с неверным количеством товаров. Подскажите пожалуйста где я напортачил и как это исправить
  8. Всем привет! Может кто помочь понять где проблема? Вот шаблон product.twig: {{ header }} <div id="product-product" class="container"> <div class="row">{{ column_left }} {% if column_left and column_right %} {% set class = 'col-sm-6' %} {% elseif column_left or column_right %} {% set class = 'col-sm-9' %} {% else %} {% set class = 'col-sm-12' %} {% endif %} <div id="content" class="{{ class }}">{{ content_top }} <div class="row"> {% if column_left or column_right %} {% set class = 'col-sm-6' %} {% else %} {% set class = 'col-sm-8' %} {% endif %} <div class="{{ class }}"> {% if thumb or images %} <img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /> <div class="image-bottom"></div> {% endif %} </div> {% if column_left or column_right %} {% set class = 'col-sm-6' %} {% else %} {% set class = 'col-sm-4' %} {% endif %} <div class="{{ class }}"> <h1>{{ heading_title }}</h1> <ul class="list-unstyled"> <li class="model">{{ model }}</li> <li class="sku">{{ sku }}</li> </ul> <div class="description">{{ description }}</div> {% if price %} <div class="price-title">Dostępny na zamówienie</div> <div class="block-price"> {% if not special %} <div class="item-price"> {% if discounts %} {% for discount in discounts %} {{ discount.price }} {% endfor %} {% else %} {{ price }} {% endif %} </div> {% else %} <div><span style="text-decoration: line-through;">{{ price }}</span></div> <div> <h2>{{ special }}</h2> </div> {% endif %} {% if tax %} <div>{{ text_tax }} {{ tax }}</div> {% endif %} {% if points %} <div>{{ text_points }} {{ points }}</div> {% endif %} </div> <div class="form-group buy"> <label class="control-label" for="input-quantity">ILOŚĆ</label> <div class="add-cart"> <input type="number" name="quantity" value="{% if discounts %}{% for discount in discounts %}{{ discount.quantity }}{% endfor %}{% else %}{{ minimum }}{% endif %}" size="2" id="input-quantity" class="form-control" /> <input type="hidden" name="product_id" value="{{ product_id }}" /> <button type="button" id="button-cart" data-loading-text="{{ text_loading }}" class="btn btn-primary btn-lg btn-block">Dodaj do koszyka</button> </div> </div> {% if minimum > 1 %} <div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_minimum }}</div> {% endif %}</div> {% endif %} <div id="product"> {% if options %} <hr> <h3>{{ text_option }}</h3> {% for option in options %} {% if option.type == 'select' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <select name="option[{{ option.product_option_id }}]" id="input-option{{ option.product_option_id }}" class="form-control"> <option value="">{{ text_select }}</option> {% for option_value in option.product_option_value %} <option value="{{ option_value.product_option_value_id }}">{{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </option> {% endfor %} </select> </div> {% endif %} {% if option.type == 'radio' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %} <div class="radio"> <label> <input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" /> {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %} {{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </label> </div> {% endfor %} </div> </div> {% endif %} {% if option.type == 'checkbox' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %} <div class="checkbox"> <label> <input type="checkbox" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" /> {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %} {{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </label> </div> {% endfor %} </div> </div> {% endif %} {% if option.type == 'text' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control" /> </div> {% endif %} {% if option.type == 'textarea' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <textarea name="option[{{ option.product_option_id }}]" rows="5" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control">{{ option.value }}</textarea> </div> {% endif %} {% if option.type == 'file' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <button type="button" id="button-upload{{ option.product_option_id }}" data-loading-text="{{ text_loading }}" class="btn btn-default btn-block"><i class="fa fa-upload"></i> {{ button_upload }}</button> <input type="hidden" name="option[{{ option.product_option_id }}]" value="" id="input-option{{ option.product_option_id }}" /> </div> {% endif %} {% if option.type == 'date' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <div class="input-group date"> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD" id="input-option{{ option.product_option_id }}" class="form-control" /> <span class="input-group-btn"> <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button> </span></div> </div> {% endif %} {% if option.type == 'datetime' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <div class="input-group datetime"> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" /> <span class="input-group-btn"> <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> </span></div> </div> {% endif %} {% if option.type == 'time' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <div class="input-group time"> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" /> <span class="input-group-btn"> <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> </span></div> </div> {% endif %} {% endfor %} {% endif %} {% if recurrings %} <hr> <h3>{{ text_payment_recurring }}</h3> <div class="form-group required"> <select name="recurring_id" class="form-control"> <option value="">{{ text_select }}</option> {% for recurring in recurrings %} <option value="{{ recurring.recurring_id }}">{{ recurring.name }}</option> {% endfor %} </select> <div class="help-block" id="recurring-description"></div> </div> {% endif %} </div> </div> {% if tags %} <p>{{ text_tags }} {% for i in 0..tags|length - 1 %} {% if i < (tags|length - 1) %} <a href="{{ tags[i].href }}">{{ tags[i].tag }}</a>, {% else %} <a href="{{ tags[i].href }}">{{ tags[i].tag }}</a> {% endif %} {% endfor %} </p> {% endif %} {{ content_bottom }}</div> {{ column_right }}</div> </div> <div class="div-block-43"></div> <div class="container"> <div class="block-reviews"> <div class="reviews">Opinie</div> <div class="tab-content"> {% if review_status %} <div class="tab-pane active" id="tab-review"> <div id="review"></div> </div> <form class="form-horizontal" id="form-review"> {% if review_guest %} <div class="form-content"> <h2>Napisać recenzję</h2> <div class="form-group required"> <div class="col-sm-12"> <label class="control-label" for="input-name">TWOJE IMIĘ</label> <input type="text" name="name" value="{{ customer_name }}" id="input-name" class="form-control" /> </div> </div> <div class="form-group required"> <div class="col-sm-12"> <label class="control-label" for="input-review">SWOJĄ OPINIĘ</label> <textarea name="text" rows="2" id="input-review" class="form-control"></textarea> <div class="help-block"><span style="color: #FF0000;">Uwaga:</span> znaczniki HTML nie są obsługiwane! Użyj zwykłego tekstu.</div> </div> </div> <div class="form-group rating required"> <div class="col-sm-12"> <label class="control-label">OCENA</label> &nbsp;&nbsp;&nbsp; Źle&nbsp; <input type="radio" name="rating" value="1" /> &nbsp; <input type="radio" name="rating" value="2" /> &nbsp; <input type="radio" name="rating" value="3" /> &nbsp; <input type="radio" name="rating" value="4" /> &nbsp; <input type="radio" name="rating" value="5" checked /> &nbsp;Dobry</div> </div> {{ captcha }} <button type="button" id="button-review" data-loading-text="Wgrywanie..." class="btn btn-primary">Wysłać</button> <a class="close-form-btn" href="javascript:PopUpHide()">Zamknąć</a> {% else %} <div class="form-content"> <h2>Napisać recenzję</h2> <div class="review-login">Proszę <a href="/login">zaloguj sie</a> lub <a href="/create-account">utwórz konto</a> przed napisaniem recenzji</div> <a class="close-form-btn" href="javascript:PopUpHide()">Zamknąć</a> </div> {% endif %} </div> </form> {% endif %}</div> <div class="add-review"><a class="add-review-btn" href="javascript:PopUpShow()">Dodaj Opinie</a></div> </div> <div class="container"> {% if products %} <h3 class="heading-19">Nasze Rekomendacje</h3> <div class="row"> {% set i = 0 %} {% for product in products %} {% if column_left and column_right %} {% set class = 'col-xs-8 col-sm-6' %} {% elseif column_left or column_right %} {% set class = 'col-xs-6 col-md-4' %} {% else %} {% set class = 'col-xs-6 col-sm-3' %} {% endif %} <div class="{{ class }}"> <div class="product-thumb transition"> <div class="image"> <a href="{{ product.href }}"> <img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive" /> </a> </div> <div class="caption"></div> <div class="new-prod-desc"> <a class="product-title" href="{{ product.href }}">{{ product.name }}</a> <a class="cat-prod" href="#">Zobacz Produkt</a> {% if product.price %} <p class="price"> {% if not product.special %} {{ product.price }} {% else %} <p class="price">{{ product.special }}</p> {% endif %} </p> {% endif %} </div> </div> </div> {% if column_left and column_right and (i + 1) % 2 == 0 %} <div class="clearfix visible-md visible-sm"></div> {% elseif column_left or column_right and (i + 1) % 3 == 0 %} <div class="clearfix visible-md"></div> {% elseif (i + 1) % 4 == 0 %} <div class="clearfix visible-md"></div> {% endif %} {% set i = i + 1 %} {% endfor %} </div> {% endif %} </div> </div> <script> $(document).ready(function(){ PopUpHide(); }); function PopUpShow(){ $("#form-review").show(); } function PopUpHide(){ $("#form-review").hide(); } </script> <script type="text/javascript"><!-- $('select[name=\'recurring_id\'], input[name="quantity"]').change(function(){ $.ajax({ url: 'index.php?route=product/product/getRecurringDescription', type: 'post', data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'), dataType: 'json', beforeSend: function() { $('#recurring-description').html(''); }, success: function(json) { $('.alert-dismissible, .text-danger').remove(); if (json['success']) { $('#recurring-description').html(json['success']); } } }); }); //--></script> <script type="text/javascript"><!-- $('#button-cart').on('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'), dataType: 'json', beforeSend: function() { $('#button-cart').button('loading'); }, complete: function() { $('#button-cart').button('reset'); }, success: function(json) { $('.alert-dismissible, .text-danger').remove(); $('.form-group').removeClass('has-error'); if (json['error']) { if (json['error']['option']) { for (i in json['error']['option']) { var element = $('#input-option' + i.replace('_', '-')); if (element.parent().hasClass('input-group')) { element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); } else { element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); } } } if (json['error']['recurring']) { $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>'); } // Highlight any found errors $('.text-danger').parent().addClass('has-error'); } if (json['success']) { $('.breadcrumb').after('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>'); $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); $('html, body').animate({ scrollTop: 0 }, 'slow'); $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); //--></script> <script type="text/javascript"><!-- $('.date').datetimepicker({ language: '{{ datepicker }}', pickTime: false }); $('.datetime').datetimepicker({ language: '{{ datepicker }}', pickDate: true, pickTime: true }); $('.time').datetimepicker({ language: '{{ datepicker }}', pickDate: false }); $('button[id^=\'button-upload\']').on('click', function() { var node = this; $('#form-upload').remove(); $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>'); $('#form-upload input[name=\'file\']').trigger('click'); if (typeof timer != 'undefined') { clearInterval(timer); } timer = setInterval(function() { if ($('#form-upload input[name=\'file\']').val() != '') { clearInterval(timer); $.ajax({ url: 'index.php?route=tool/upload', type: 'post', dataType: 'json', data: new FormData($('#form-upload')[0]), cache: false, contentType: false, processData: false, beforeSend: function() { $(node).button('loading'); }, complete: function() { $(node).button('reset'); }, success: function(json) { $('.text-danger').remove(); if (json['error']) { $(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>'); } if (json['success']) { alert(json['success']); $(node).parent().find('input').val(json['code']); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } }, 500); }); //--></script> <script type="text/javascript"><!-- $('#review').delegate('.pagination a', 'click', function(e) { e.preventDefault(); $('#review').fadeOut('slow'); $('#review').load(this.href); $('#review').fadeIn('slow'); }); $('#review').load('index.php?route=product/product/review&product_id={{ product_id }}'); $('#button-review').on('click', function() { $.ajax({ url: 'index.php?route=product/product/write&product_id={{ product_id }}', type: 'post', dataType: 'json', data: $("#form-review").serialize(), beforeSend: function() { $('#button-review').button('loading'); }, complete: function() { $('#button-review').button('reset'); }, success: function(json) { $('.alert-dismissible').remove(); if (json['error']) { $('.rating').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>'); } if (json['success']) { $('.rating').after('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>'); $('input[name=\'name\']').val(''); $('textarea[name=\'text\']').val(''); $('input[name=\'rating\']:checked').prop('checked', false); } } }); }); $(document).ready(function() { $('.thumbnails').magnificPopup({ type:'image', delegate: 'a', gallery: { enabled: true } }); }); //--></script> {{ footer }} Сам функционал немного изменен, чтобы пользователи различных групп могли покупать один и тот же товар по разным ценам и с разным минимальным количеством
  9. Привет! Не знаю актуально ли еще, но для этого можно заменить функцию в этом же сайте на следующий код: public function render() { $total = $this->total; if ($this->page < 1) { $page = 1; } else { $page = $this->page; } if (!(int)$this->limit) { $limit = 10; } else { $limit = $this->limit; } $num_links = $this->num_links; $num_pages = ceil($total / $limit); $this->url = str_replace('%7Bpage%7D', '{page}', $this->url); $output = '<ul class="pagination">'; if ($page > 1) { $output .= '<li><a href="' . str_replace('{page}', $page - 1, $this->url) . '">' . $this->text_prev . '</a></li>'; } if ($page < $num_pages) { $output .= '<li><a href="' . str_replace('{page}', $page + 1, $this->url) . '">' . $this->text_next . '</a></li>'; } $output .= '</ul>'; if ($num_pages > 1) { return $output; } else { return ''; } }
  10. Как ее отключить в стилях или шаблоне я знаю. Мне нужно сделать так чтобы фильтрация происходила без нее. Т.е. кликнул на пункт фильтра и тебе показались нужные товары
  11. А можете хотя бы подсказать как избавиться от кнопки? Сейчас установлено "Ajax стандартный фильтр", который убрал перезагрузку страницы и часть проблемы вроде как убирает. И почему не происходит фильтрация по названию? Если тестировать на простой html-странице, то все работает
  12. К сожалению я не силен в javascript и сам точно не справлюсь. Поэтому буду очень благодарен за любую помощь в создании такого фильтра. Я пробовал разные модули, но единственное что удалось сделать фильтр на аяксе с кнопкой. Но такой вариант мне не подходит
  13. Всем привет! Помогите пожалуйста решить проблему над которой бьюсь уже несколько дней. Суть в следующем: есть сайт на базе ocStore-3.0.3.7 со стандартным шаблоном. В нем нужно сделать фильтр товаров как здесь https://www.reviderm.pl/klient-indywidualny/produkty. Т.е. фильтрация должна происходить по введенном названии https://prnt.sc/T3eaPnOWAgjv, а также при нажатии на определенный пункт из внесенных фильтров https://prnt.sc/vvYqVeAOCT_M. Все это должно происходить сразу после ввода/нажатия на пункт без использования кнопки https://prnt.sc/NX2GusfIMRDC и перезагрузки страницы. При этом выбранные значения фильтров должны показываться как здесь https://prnt.sc/x8VtwsvUk4JU, а количество товаров должно автоматически менятся здесь https://prnt.sc/cIC4xm7S42Nv. Пробовал сделать вывод результатов фильтра по названию с помощью javascript, но он почему-то не работает. Вот код файла filter.twig: <div class="panel panel-default"> <input type="text" id="filter-name"> <div>{{ results }}</div> <div class="list-group"> {% for filter_group in filter_groups %} <a class="list-group-item">{{ filter_group.name }}</a> <div class="list-group-item"> <div id="filter-group{{ filter_group.filter_group_id }}">{% for filter in filter_group.filter %} <div class="checkbox"> <label>{% if filter.filter_id in filter_category %} <input type="checkbox" name="filter[]" value="{{ filter.filter_id }}" checked="checked" /> {{ filter.name }} {% else %} <input type="checkbox" name="filter[]" value="{{ filter.filter_id }}" /> {{ filter.name }} {% endif %}</label> </div> {% endfor %}</div> </div> {% endfor %}</div> <div class="panel-footer text-right"> <button type="button" id="button-filter" class="btn btn-primary">{{ button_filter }}</button> </div> </div> <script type="text/javascript"> let filter = function () { let input = document.getElementById(elementid: 'filter-name'); input.addEventListener(type: 'keyup', listener: function (){ let filter = input.value.toLowerCase(), filterElements = document.querySelectorAll(selectors: '.product-title'); filterElements.forEach (callbackfn: item =>{ if(item.innerHTML.toLowerCase().indexOf(filter) > -1) { item.style.display = ''; } else { item.style.display = 'none'; } }) }) } </script> Файл category.twig: {{ header }} <div id="product-category" class="container"> <div class="row">{{ column_left }} {% if column_left and column_right %} {% set class = 'col-sm-6' %} {% elseif column_left or column_right %} {% set class = 'col-sm-9' %} {% else %} {% set class = 'col-sm-12' %} {% endif %} <div id="content" class="{{ class }}">{{ content_top }} {% if thumb or description %} <div class="row"> {% if thumb %} <div class="col-sm-2"><img src="{{ thumb }}" alt="{{ heading_title }}" title="{{ heading_title }}" class="img-thumbnail" /></div> {% endif %} {% if description %} <div class="col-sm-10">{{ description }}</div> {% endif %}</div> <hr> {% endif %} {% if categories %} <h3>{{ text_refine }}</h3> {% if categories|length <= 5 %} <div class="row"> <div class="col-sm-3"> <ul> {% for category in categories %} <li><a href="{{ category.href }}">{{ category.name }}</a></li> {% endfor %} </ul> </div> </div> {% else %} <div class="row">{% for category in categories|batch((categories|length / 4)|round(1, 'ceil')) %} <div class="col-sm-3"> <ul> {% for child in category %} <li><a href="{{ child.href }}">{{ child.name }}</a></li> {% endfor %} </ul> </div> {% endfor %}</div> <br /> {% endif %} {% endif %} {% if products %} <div class="row"> {% for product in products %} <div class="product-layout col-lg-3 col-md-3 col-sm-6 col-xs-12"> <div class="product-thumb transition"> <div class="image"> <a href="{{ product.href }}"> <img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive" /> </a> </div> <div class="caption"></div> <div class="new-prod-desc"> <a class="product-title" href="{{ product.href }}">{{ product.name }}</a> <a class="cat-prod" href="#">Zobacz Produkt</a> {% if product.price %} <p class="price"> {% if not product.special %} {{ product.price }} {% else %} <p class="price">{{ product.special }}</p> {% endif %} </p> {% endif %} </div> </div> </div> {% endfor %} </div> <div class="row"> <div class="col-sm-6 text-left">{{ pagination }}</div> </div> {% endif %} {{ content_bottom }}</div> {{ column_right }}</div> </div> {{ footer }} Может кто помочь разобраться с этим?
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.