Помощь Как вывести скидки от количества в категории

romzes6961

Гуру форума
Регистрация
6 Дек 2014
Сообщения
141
Реакции
86
Здравствуйте, меня интересует как реализовать такое
vqmod_qty_discount_category.png

нашел статью
Скрытое содержимое доступно для зарегистрированных пользователей!

все делаю как написано, но ничего не меняется, шаблон не родной, версия опенкарт 1.5.5.1.2 может кто подскажет как это реализовать? или может в статье ошибка?!
 
ну 2.1.0.1 я себе еще не ставил, но по сути тут логика такая:
попробовать сделать все согласно этим советам Для просмотра ссылки Войди или Зарегистрируйся
с той разницей, что в 1.5 переменные в контроллере формируются
$this->data
а в 2.Х
$data
по идее код для контроллера будет выглядеть:
Код:
$data['text_discount'] = '%s or more %s';
                $discount_query = $this->model_catalog_product->getProductDiscounts($result['product_id']);

                $discounts = array();

                foreach ($discount_query as $discount) {
                    $discounts[] = array(
                        'quantity' => $discount['quantity'],
                        'price'    => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')))
                    );
                }
 
ну 2.1.0.1 я себе еще не ставил, но по сути тут логика такая:
попробовать сделать все согласно этим советам Для просмотра ссылки Войди или Зарегистрируйся
с той разницей, что в 1.5 переменные в контроллере формируются
$this->data
а в 2.Х
$data
чего-то не работает(((
вот кусок кода контроллера

Код:
//category discounts               
                $discount_query = $this->model_catalog_product->getProductDiscounts($result['product_id']);

                $discounts = array();

                foreach ($discount_query as $discount) {
                    $discounts[] = array(
                        'quantity' => $discount['quantity'],
                        'price'    => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')))
                    );
                }
               
//category discounts                
                $data['products'][] = array(
                    'product_id'  => $result['product_id'],
                    'thumb'       => $image,
                    'name'        => $result['name'],
                    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
                    'price'       => $price,
                    'special'     => $special,
                    'discounts'   => $discount,
                   
                    'tax'         => $tax,
                    'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
                    'rating'      => $result['rating'],
                    'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
                );
            }

и кусок кода в category.tpl
Код:
 <?php if ($product['price']) { ?>
                <p class="price custom-style-price">
                  <?php if (!$product['special']) { ?>
                  <?php echo $product['price']; ?>
                  <?php } else { ?>
                  <span class="price-new pull-left">ОПТ(от 50шт)<br><?php echo $product['special']; ?></span> <span class="price-old pull-right">Розн<br><?php echo $product['price']; ?></span>
                  <?php } ?>
                  <?php if ($product['tax']) { ?>
                  <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
                  <?php } ?>
                  <?php if ($discounts) { ?>
            <li>
              <hr>
            </li>
            <?php foreach ($discounts as $discount) { ?>
            <li><?php echo $discounts['quantity']; ?><?php echo $text_discount; ?><?php echo $discount['price']; ?></li>
            <?php } ?>
            <?php } ?>
                </p>
                <?php } ?>
 
в журнале ошибок- какие?
код контроллера неправильный, попробуйте этот
Код:
//category discounts  
$data['text_discount'] = '%s or more %s';
           
                $discount_query = $this->model_catalog_product->getProductDiscounts($result['product_id']);

                $discounts = array();

                foreach ($discount_query as $discount) {
                    $discounts[] = array(
                        'quantity' => $discount['quantity'],
                        'price'    => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')))
                    );
                }
             
//category discounts              
                $data['products'][] = array(
                    'product_id'  => $result['product_id'],
                    'thumb'       => $image,
                    'name'        => $result['name'],
                    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
                    'price'       => $price,
                    'special'     => $special,
                    'discounts'   => $discounts,
                 
                    'tax'         => $tax,
                    'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
                    'rating'      => $result['rating'],
                    'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
                );
            }
 
2015-11-26 15:46:46 - PHP Notice: Trying to get property of non-object in /www/admin/controller/extension/modification.php on line 142

о на сайте появилось
Notice: Undefined variable: discounts in/www/system/storage/modification/catalog/view/theme/default/template/product/category.tplon line 142
 
Последнее редактирование:
Назад
Сверху