Note that there are some explanatory texts on larger screens.

plurals
  1. POOpencart: Query the database to get tax_rate data
    primarykey
    data
    text
    <p>I'm trying to get a calculator helper in product admin page, near the price input I want to add a textbox that helps users to calculate the price with Tax VAT exluded to insert. It's something similar to this <a href="http://www.opencart.com/index.php?route=extension/extension/info&amp;extension_id=7045" rel="nofollow">PLUGIN</a> but I need to query the database to get an array of all Tax Rates and compare them with the <code>tax_class_id</code> selected by user just below the price.</p> <p>I have found a sort of request in this page: <code>admin/controller/localisation/tax_rate.php</code></p> <pre class="lang-php prettyprint-override"><code>if (isset($this-&gt;request-&gt;post['rate'])) { $this-&gt;data['rate'] = $this-&gt;request-&gt;post['rate']; } elseif (!empty($tax_rate_info)) { $this-&gt;data['rate'] = $tax_rate_info['rate']; } else { $this-&gt;data['rate'] = ''; } </code></pre> <p>But I have no idea how to query the database and get the data inside the page <code>admin/view/template/catalog/product_form.tpl</code>. I'm trying to get a result similar to Prestashop's price management.</p> <p>Please give me some help!</p> <p>EDIT:</p> <p>I solved with this code added in <code>admin/controller/catalog/product.php</code> placed inside getForm() function:</p> <pre><code>$sql = 'SELECT tra.rate, tra.type, tru.tax_class_id FROM '.DB_PREFIX.'tax_rate tra LEFT JOIN '.DB_PREFIX.'tax_rule tru ON tru.tax_rate_id = tra.tax_rate_id WHERE tru.tax_class_id IS NOT NULL' ; $query = $this-&gt;db-&gt;query($sql); $rates = array(); foreach($query-&gt;rows as $result){ $rates[] = $result; } $this-&gt;data['rates'] = $rates; </code></pre> <p>thanks to all the participants</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload