Get the price with tax

  • Posts: 17
  • Thank you received: 0
12 years 8 months ago #24653

Hi everybody,

I don't find my question on the forum so I post here.
I'm writing a classical Joomla module and I search an easy way to get prices of a product which I've the id_product.
I find getPrices() in hikashopCurrencyClass but it seems a little complex.

Thanks for answers !

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13099
  • MODERATOR
12 years 8 months ago #24656

That's indeed the function you should use.
$productClass = hikashop_get('class.product');
$product = $productClass ->get($id);
$currencyClass = hikashop_get('class.currency');
$products = array(&$product);
$ids = array($id);
$config =& hikashop_config();
$main_currency = $currency_id = (int)$config->get('main_currency',1);
$zone_id = explode(',',$config->get('main_tax_zone',0));
if(count($zone_id)){
$zone_id = array_shift($zone_id);
}else{
$zone_id=0;
}
$discount_before_tax = (int)$config->get('discount_before_tax',0);
$currencyClass->getPrices($products,$ids,hikashop_getCurrency(),$main_currency,$zone_id,$discount_before_tax);

Then, the prices will be in $products[0]->prices

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
12 years 8 months ago #24662

Thanks a lot for this and your rapididty. I'll try soon.

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
12 years 8 months ago #24710

Thanks for the code, it was exactly what I want. But I've a new problem, getPrices() return anything when the product have a price_min_quantity, does anybody know why ?

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13099
  • MODERATOR
12 years 8 months ago #24712

getPrices returns all the prices of the product. There is no reason it wouldn't.

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
12 years 8 months ago #24713

When I print_r($products) I've no informations about prices. When I do the same thing on a product which have no price_min_quantity, I've right informations.

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13099
  • MODERATOR
12 years 8 months ago #24715

Are you sure that it's not something else like the currency of your prices which are different ?
Also, do you have a price without a minimum quantity ? You can have prices with a minimum quantity, but you always need a price without a minimum quantity. Maybe that's your problem ?

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
12 years 8 months ago #24716

Ok that's it, you're right (like always ?). Thanks a lot again.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum