How do i get price value with tax in Search Result

  • Posts: 57
  • Thank you received: 1
10 years 3 weeks ago #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[0] = new stdClass();
$arr[0]->product_id = $pid;
$currency = hikashop_get('type.currency');
$currencyClass = hikashop_get('class.currency');
$zone = hikashop_getZone();
$cur = hikashop_getCurrency();
$currencyClass->getListingPrices($arr,$zone,$cur);
$i=0;
$currPrice = 0;
foreach($arr[0]->prices as $k=>$price) {
if(!$i) {
$currPrice = $price->price_value_with_tax;
}
if($price->price_value_with_tax < $currPrice) $currPrice = $price->price_value_with_tax;
$i++;
}
return $currencyClass->format($currPrice, $cur);
}

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

stdClass Object ( [price_id] => 42 [price_currency_id] => 73 [price_product_id] => 56 [price_value] => 233.64486 [price_min_quantity] => 10 [price_access] => all [price_site_id] => [price_value_with_tax] => 233.64 [taxes] => 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 or Create an account to join the conversation.

  • Posts: 82683
  • Thank you received: 13338
  • MODERATOR
10 years 2 weeks ago #175239

Hi,

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

There, you need to also have that line:
$arr[0]->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 or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum