Search code examples
phpjquerye-commerceopencartvqmod

Opencart - Notice: Undefined index: saving in


I'm using Opencart 1.5.6.1.

In this page: http://jefferson.com.my/test/index.php?route=product/results&category=[75]&path=0&filterProduct=1

There's error in some products, SAVE Notice: Undefined index: saving in /home/jefferso/public_html/test/vqmod/vqcache/vq2-catalog_view_theme_pav_fashion_template_product_category.tpl on line 147%

It's because I install a mod that display the discounted percentage. It doesn't have problem displaying in category page, product page and home page, but if you try the filter on the left (tick T-shirt) which resulted in the page above, the error will show out.

I don't know how to deal with that cache file, and the theme developer doesn't want to help at all.


Solution

  • Go to your source > vqmod > xml > & then find & open "webvet_percentage_to_specials_v6.xml" file > & then below code add in bottom of the page above </modification> tag. > & then check it.

    // FILTER PAGE
    <file name="catalog/controller/product/results.php">
    
        <operation>
            <search position="after"><![CDATA[
            'special'     => $special,
            ]]></search>
    
            <add><![CDATA[
            'saving'     => round((($result['price'] - $result['special'])/$result['price'])*100, 0),
            ]]></add>
        </operation>
    </file>
    
    <file name="catalog/view/theme/*/template/product/result.tpl">
    
        <operation>
            <search position="after"><![CDATA[
            <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
            ]]></search>
    
            <add><![CDATA[
            <br /><span style="color: red;">SAVE <?php echo $product['saving']; ?>%</span>
            ]]></add>
        </operation>
    </file>