Post by hlf-one » Sat Nov 09, 2019 10:19 am

Hello guys I need some help!

I need to display the progressive discounts on the product listing on the promotion page (special.tpl), I can add on all other pages such as categories, highlights, product and etc but only with the promotion does not work.

I added the instructions in "catalog/controller/product/special.php" and when I call the variable it says it was not defined and testing the variable with "if (isset ()" informs that it does not exist.

Code used in the control catalog/controller/product/special.php

Code: Select all

      $data['text_discount'] = '%s ou mais %s';
        if (isset($this->data)) { $this->data = array_merge($this->data, $data); }
        $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'], $this->config->get('config_tax')), $this->session->data['currency'])
Code used view catalog/view/theme/*/template/product/special.tpl

Code: Select all

      <?php if ($product['discounts']) { ?>
            <div class="discount">
              <dd><?php foreach ($product['discounts'] as $discount) { ?></dd>
              <dd><b>Na compra de <?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?></b></dd>
              <?php } ?>
        <?php } ?>
Product listing image in category showing quantity and price correctly Image

Error image on promotions page (special.tpl): Image

thanks for the help!



Sat Nov 09, 2019 10:13 am

Post by webdew » Wed Nov 13, 2019 5:50 am

Is it just me or did you forget to add the discounts info to the product array?



Wed Nov 13, 2019 5:49 am
Who is online

Users browsing this forum: No registered users and 11 guests