- Posts: 17
- Thank you received: 0
Get the price with tax
15 years 1 month ago #24653
by Julien
Get the price with tax was created by Julien
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 !
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.
15 years 1 month ago #24656
by nicolas
Replied by nicolas on topic Re: Get the price with tax
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
$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.
15 years 1 month ago #24662
by Julien
Replied by Julien on topic Re: Get the price with tax
Thanks a lot for this and your rapididty. I'll try soon.
Please Log in or Create an account to join the conversation.
15 years 1 month ago #24710
by Julien
Replied by Julien on topic Re: Get the price with tax
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.
15 years 1 month ago #24712
by nicolas
Replied by nicolas on topic Re: Get the price with tax
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.
15 years 1 month ago #24713
by Julien
Replied by Julien on topic Re: Get the price with tax
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.
15 years 1 month ago #24715
by nicolas
Replied by nicolas on topic Re: Get the price with tax
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 ?
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.
15 years 1 month ago #24716
by Julien
Replied by Julien on topic Re: Get the price with tax
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.204 seconds