- Posts: 3
- Thank you received: 0
How can I get the checkout cart subtotal price?
1 year 5 months ago #366495
by m.mihov
How can I get the checkout cart subtotal price? was created by m.mihov
Hello,
I'm working on a module.
How can I get the checkout cart subtotal price?
I'm working on a module.
How can I get the checkout cart subtotal price?
Please Log in or Create an account to join the conversation.
1 year 5 months ago #366497
by nicolas
Replied by nicolas on topic How can I get the checkout cart subtotal price?
Hi,
First, you want to load HikaShop, in case it's not already loaded on the page by the time Joomla runs your module:
Then, you want to load the cart:
You could loop through the products in $cart->products to sum the products price. But a simpler solution would be to directly get the subtotal :
And if you want to format it as a price (with the currency, decimals rounding, etc), you'll want to display it like that for example:
www.hikashop.com/support/documentation/6...umentation.html#code
First, you want to load HikaShop, in case it's not already loaded on the page by the time Joomla runs your module:
Code:
if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
Code:
$cartClass = hikashop_get('class.cart');
$cart = $cartClass->getFullCart();
Code:
echo $cart->total->prices[0]->price_value_with_tax; // with taxes
echo $cart->total->prices[0]->price_value; // without taxes
Code:
$currencyClass = hikashop_get('class.currency');
echo $currencyClass->format($cart->total->prices[0]->price_value_with_tax, $cart->total->prices[0]->price_currency_id);
www.hikashop.com/support/documentation/6...umentation.html#code
Please Log in or Create an account to join the conversation.
1 year 5 months ago #366500
by m.mihov
Replied by m.mihov on topic How can I get the checkout cart subtotal price?
Thanks a lot.
Can I call from the configuration how the price should be with or without tax?
Something like:
Can I call from the configuration how the price should be with or without tax?
Something like:
Code:
if(!empty($this->options['price_with_tax']))
Please Log in or Create an account to join the conversation.
1 year 5 months ago #366502
by nicolas
Replied by nicolas on topic How can I get the checkout cart subtotal price?
Hi,
If you want to base yourself on the "Show taxed prices" of the HikaShop configuration, you can get its value like this:
If you want to base yourself on the "Show taxed prices" of the HikaShop configuration, you can get its value like this:
Code:
$config = hikashop_config();
$price_with_tax = $config->get('price_with_tax');
Please Log in or Create an account to join the conversation.
1 year 5 months ago #366511
by m.mihov
Replied by m.mihov on topic How can I get the checkout cart subtotal price?
Thanks.
It worked.
It worked.
Please Log in or Create an account to join the conversation.
Time to create page: 0.256 seconds