[Skip to main content](#vessel-content)

#   How do i get price value with tax in Search Result

##

- **[888](/forum/user/32855-888 "View 888's Profile")**
- [![888's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/32855-888 "View 888's Profile") Topic Author
- [ Offline](/forum/user/32855-888)

Less More

- Posts: 57
- Thank you received: 1
-
-

12 years 1 month ago [\#175237](#175237) by [888](/forum/user/32855-888 "View 888's Profile")  *[How do i get price value with tax in Search Result](/forum/30-integrations/872257-how-do-i-get-price-value-with-tax-in-search-result#175237 "-- HikaShop version -- : 2.3.3 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.5.14-1  How do i get price value with tax in Search Result plugin  function getPrice($pid) { $arr = array(); $arr&#91;0&#93; = new stdClass(); $arr&#91;0&#93;-&gt;product&#95;id = $pid; $currency = hikashop&#95;get('type.currency'); $currencyClass = hikashop&#95;get('class.currency'); $zone = hikashop&#95;getZone(); $cur = hikashop&#95;getCurrency(); $currencyClass-&gt;getListingPrices($arr,$zone,$cur); $i=0; $currPrice = 0; foreach($arr&#91;0&#93;-&gt;prices as $k=&gt;$price) { if(!$i) { $currPrice = $price-&gt;price&#95;value&#95;with&#95;tax; } if($price-&gt;price&#95;value&#95;with&#95;tax price&#95;value&#95;with&#95;tax; $i++; } return $currencyClass-&gt;format($currPrice, $cur); }  Here is a little snippet from the prices what the search plugin gets from hikashop by products:  stdClass Object ( &#91;price&#95;id&#93; =&gt; 42 &#91;price&#95;currency&#95;id&#93; =&gt; 73 &#91;price&#95;product&#95;id&#93; =&gt; 56 &#91;price&#95;value&#93; =&gt; 233.64486 &#91;price&#95;min&#95;quantity&#93; =&gt; 10 &#91;price&#95;access&#93; =&gt; all &#91;price&#95;site&#95;id&#93; =&gt; &#91;price&#95;value&#95;with&#95;tax&#93; =&gt; 233.64 &#91;taxes&#93; =&gt; Array ( ) )  As you can see price and the price with tax is the same ? anyone with an idea how to i fix this?")* was created by *[888](/forum/user/32855-888 "View 888's Profile")*

-- HikaShop version -- : 2.3.3
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.5.14-1

How do i get price value with tax in Search Result plugin

function getPrice($pid) {
$arr = array();
$arr[0] = new stdClass();
$arr[0]-&gt;product_id = $pid;
$currency = hikashop_get('type.currency');
$currencyClass = hikashop_get('class.currency');
$zone = hikashop_getZone();
$cur = hikashop_getCurrency();
$currencyClass-&gt;getListingPrices($arr,$zone,$cur);
$i=0;
$currPrice = 0;
foreach($arr[0]-&gt;prices as $k=&gt;$price) {
if(!$i) {
$currPrice = $price-&gt;price_value_with_tax;
}
if($price-&gt;price_value_with_tax &lt; $currPrice) $currPrice = $price-&gt;price_value_with_tax;
$i++;
}
return $currencyClass-&gt;format($currPrice, $cur);
}

Here is a little snippet from the prices what the search plugin gets from hikashop by products:

stdClass Object ( [price_id] =&gt; 42 [price_currency_id] =&gt; 73 [price_product_id] =&gt; 56 [price_value] =&gt; 233.64486 [price_min_quantity] =&gt; 10 [price_access] =&gt; all [price_site_id] =&gt; [price_value_with_tax] =&gt; 233.64 [taxes] =&gt; Array ( ) )

As you can see price and the price with tax is the same ?
anyone with an idea how to i fix this?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy84NzIyNTctaG93LWRvLWktZ2V0LXByaWNlLXZhbHVlLXdpdGgtdGF4LWluLXNlYXJjaC1yZXN1bHQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

12 years 1 month ago [\#175239](#175239) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How do i get price value with tax in Search Result](/forum/30-integrations/872257-how-do-i-get-price-value-with-tax-in-search-result#175239 "-- HikaShop version -- : 2.3.3 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.5.14-1  How do i get price value with tax in Search Result plugin  function getPrice($pid) { $arr = array(); $arr&#91;0&#93; = new stdClass(); $arr&#91;0&#93;-&gt;product&#95;id = $pid; $currency = hikashop&#95;get('type.currency'); $currencyClass = hikashop&#95;get('class.currency'); $zone = hikashop&#95;getZone(); $cur = hikashop&#95;getCurrency(); $currencyClass-&gt;getListingPrices($arr,$zone,$cur); $i=0; $currPrice = 0; foreach($arr&#91;0&#93;-&gt;prices as $k=&gt;$price) { if(!$i) { $currPrice = $price-&gt;price&#95;value&#95;with&#95;tax; } if($price-&gt;price&#95;value&#95;with&#95;tax price&#95;value&#95;with&#95;tax; $i++; } return $currencyClass-&gt;format($currPrice, $cur); }  Here is a little snippet from the prices what the search plugin gets from hikashop by products:  stdClass Object ( &#91;price&#95;id&#93; =&gt; 42 &#91;price&#95;currency&#95;id&#93; =&gt; 73 &#91;price&#95;product&#95;id&#93; =&gt; 56 &#91;price&#95;value&#93; =&gt; 233.64486 &#91;price&#95;min&#95;quantity&#93; =&gt; 10 &#91;price&#95;access&#93; =&gt; all &#91;price&#95;site&#95;id&#93; =&gt; &#91;price&#95;value&#95;with&#95;tax&#93; =&gt; 233.64 &#91;taxes&#93; =&gt; Array ( ) )  As you can see price and the price with tax is the same ? anyone with an idea how to i fix this?")*

Hi,

The problem comes from the first lines:
$arr = array();
$arr[0] = new stdClass();
$arr[0]-&gt;product_id = $pid;

There, you need to also have that line:
$arr[0]-&gt;product_tax_id = $tax_id;

where $tax_id contains the id of the tax category of the product. Otherwise, it means that your product doesn't have any tax category and thus no tax rules will apply to it.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy84NzIyNTctaG93LWRvLWktZ2V0LXByaWNlLXZhbHVlLXdpdGgtdGF4LWluLXNlYXJjaC1yZXN1bHQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.040 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
