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

#   Get total value of cart from independed php file

##

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

Less More

- Posts: 217
- Thank you received: 4
-
-

7 years 2 weeks ago -  7 years 2 weeks ago [\#311909](#311909) by [FilipHradil](/forum/user/36153-filiphradil "View FilipHradil's Profile")  *[Get total value of cart from independed php file](/forum/27-checkout/898459-get-total-value-of-cart-from-independed-php-file#311909 "-- HikaShop version -- : 4.2.2  Hello,  I am trying to obtain total value of cart (with tax) in separated php file. Please, what is the simples method to get this value? I am trying this, without success:  In another words, if user has in cart 3 products, each for 30 $, I need value with 90 $.  Please, could you give me an advise? I am completely lost when it comes to hikashop classes, structures, etc.. :-)  I need this to create custom js code that will load via ajax value for micro cart as to as I can use page cache.  Q2: This php function will be called via ajax from custom html module in Joomla. How can I assign value to correct user that called that ajax? Will it be done automatically or I need to pass some parameter?  Thank you very much, Filip")* was created by *[FilipHradil](/forum/user/36153-filiphradil "View FilipHradil's Profile")*

-- HikaShop version -- : 4.2.2

Hello,

I am trying to obtain total value of cart (with tax) in separated php file. Please, what is the simples method to get this value?
I am trying this, without success:
Code:

$hikashopHelper = 'https://elodyprsteny.cz/backup/administrator/components/com_hikashop/helpers/helper.php'; if(!file_exists($hikashopHelper) &#124;&#124; !include_once($hikashopHelper)) return; $cartClass = hikashop_get('class.cart'); $cart = $cartClass-&gt;get(0); echo $cart-&gt;full_total;

In another words, if user has in cart 3 products, each for 30 $, I need value with 90 $.

Please, could you give me an advise? I am completely lost when it comes to hikashop classes, structures, etc.. ![:-)](/media/kunena/emoticons/9.png ":-)")

I need this to create custom js code that will load via ajax value for micro cart as to as I can use page cache.

Q2: This php function will be called via ajax from custom html module in Joomla. How can I assign value to correct user that called that ajax? Will it be done automatically or I need to pass some parameter?

Thank you very much,
Filip

Last edit: 7 years 2 weeks ago by [FilipHradil](/forum/user/36153-filiphradil "View FilipHradil's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5ODQ1OS1nZXQtdG90YWwtdmFsdWUtb2YtY2FydC1mcm9tLWluZGVwZW5kZWQtcGhwLWZpbGU/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

7 years 2 weeks ago [\#311922](#311922) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Get total value of cart from independed php file](/forum/27-checkout/898459-get-total-value-of-cart-from-independed-php-file#311922 "-- HikaShop version -- : 4.2.2  Hello,  I am trying to obtain total value of cart (with tax) in separated php file. Please, what is the simples method to get this value? I am trying this, without success:  In another words, if user has in cart 3 products, each for 30 $, I need value with 90 $.  Please, could you give me an advise? I am completely lost when it comes to hikashop classes, structures, etc.. :-)  I need this to create custom js code that will load via ajax value for micro cart as to as I can use page cache.  Q2: This php function will be called via ajax from custom html module in Joomla. How can I assign value to correct user that called that ajax? Will it be done automatically or I need to pass some parameter?  Thank you very much, Filip")*

Hi,

1.
You had a good start: Code:

$hikashopHelper = 'https://elodyprsteny.cz/backup/administrator/components/com_hikashop/helpers/helper.php'; if(!file_exists($hikashopHelper) &#124;&#124; !include_once($hikashopHelper)) return; $cartClass = hikashop_get('class.cart'); $cart = $cartClass-&gt;getFullCart(); echo $cart-&gt;full_total-&gt;prices[0]-&gt;price_value_with_tax;

2. Even in Ajax, the user session cookies are passed by the browser, so your PHP script will know which user account is asking for the information and thus it will automatically pick the correct cart with the correct prices.

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

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

Less More

- Posts: 217
- Thank you received: 4
-
-

7 years 1 week ago [\#312044](#312044) by [FilipHradil](/forum/user/36153-filiphradil "View FilipHradil's Profile")  Replied by *[FilipHradil](/forum/user/36153-filiphradil "View FilipHradil's Profile")* on topic *[Get total value of cart from independed php file](/forum/27-checkout/898459-get-total-value-of-cart-from-independed-php-file#312044 "-- HikaShop version -- : 4.2.2  Hello,  I am trying to obtain total value of cart (with tax) in separated php file. Please, what is the simples method to get this value? I am trying this, without success:  In another words, if user has in cart 3 products, each for 30 $, I need value with 90 $.  Please, could you give me an advise? I am completely lost when it comes to hikashop classes, structures, etc.. :-)  I need this to create custom js code that will load via ajax value for micro cart as to as I can use page cache.  Q2: This php function will be called via ajax from custom html module in Joomla. How can I assign value to correct user that called that ajax? Will it be done automatically or I need to pass some parameter?  Thank you very much, Filip")*

Hello,

Thank you! Sorry for late reply. Unfortunately, it says "Restricted access" when I paste your code into separated php file.

What I missed, please?

Thanks!
Filip

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5ODQ1OS1nZXQtdG90YWwtdmFsdWUtb2YtY2FydC1mcm9tLWluZGVwZW5kZWQtcGhwLWZpbGU/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

7 years 1 week ago [\#312046](#312046) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Get total value of cart from independed php file](/forum/27-checkout/898459-get-total-value-of-cart-from-independed-php-file#312046 "-- HikaShop version -- : 4.2.2  Hello,  I am trying to obtain total value of cart (with tax) in separated php file. Please, what is the simples method to get this value? I am trying this, without success:  In another words, if user has in cart 3 products, each for 30 $, I need value with 90 $.  Please, could you give me an advise? I am completely lost when it comes to hikashop classes, structures, etc.. :-)  I need this to create custom js code that will load via ajax value for micro cart as to as I can use page cache.  Q2: This php function will be called via ajax from custom html module in Joomla. How can I assign value to correct user that called that ajax? Will it be done automatically or I need to pass some parameter?  Thank you very much, Filip")*

Hi,

HikaShop requires Joomla to be loaded. Otherwise, you'll get such error.
Did you also load Joomla before loading the HikaShop helper ?
[ stackoverflow.com/questions/23937651/loa...al-php-file/23937818](https://stackoverflow.com/questions/23937651/load-joomla-3-x-framework-and-modules-in-external-php-file/23937818)

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

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

Less More

- Posts: 217
- Thank you received: 4
-
-

7 years 1 week ago [\#312071](#312071) by [FilipHradil](/forum/user/36153-filiphradil "View FilipHradil's Profile")  Replied by *[FilipHradil](/forum/user/36153-filiphradil "View FilipHradil's Profile")* on topic *[Get total value of cart from independed php file](/forum/27-checkout/898459-get-total-value-of-cart-from-independed-php-file#312071 "-- HikaShop version -- : 4.2.2  Hello,  I am trying to obtain total value of cart (with tax) in separated php file. Please, what is the simples method to get this value? I am trying this, without success:  In another words, if user has in cart 3 products, each for 30 $, I need value with 90 $.  Please, could you give me an advise? I am completely lost when it comes to hikashop classes, structures, etc.. :-)  I need this to create custom js code that will load via ajax value for micro cart as to as I can use page cache.  Q2: This php function will be called via ajax from custom html module in Joomla. How can I assign value to correct user that called that ajax? Will it be done automatically or I need to pass some parameter?  Thank you very much, Filip")*

Hello,

I just did that.

But still getting empty cart when I call ajax from joomla module and php code is in separated .php file in root folder of website.

Any suggestions, please?
Filip

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5ODQ1OS1nZXQtdG90YWwtdmFsdWUtb2YtY2FydC1mcm9tLWluZGVwZW5kZWQtcGhwLWZpbGU/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

7 years 1 week ago [\#312073](#312073) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Get total value of cart from independed php file](/forum/27-checkout/898459-get-total-value-of-cart-from-independed-php-file#312073 "-- HikaShop version -- : 4.2.2  Hello,  I am trying to obtain total value of cart (with tax) in separated php file. Please, what is the simples method to get this value? I am trying this, without success:  In another words, if user has in cart 3 products, each for 30 $, I need value with 90 $.  Please, could you give me an advise? I am completely lost when it comes to hikashop classes, structures, etc.. :-)  I need this to create custom js code that will load via ajax value for micro cart as to as I can use page cache.  Q2: This php function will be called via ajax from custom html module in Joomla. How can I assign value to correct user that called that ajax? Will it be done automatically or I need to pass some parameter?  Thank you very much, Filip")*

Hi,

This means that the user session is not kept and thus HikaShop doesn't have the cart_id reference in the user session.
So maybe you need to do something in your code to load the user session yourself.
[ docs.joomla.org/How\_to\_access\_session\_va...n\_external\_script/en](https://docs.joomla.org/How_to_access_session_variables_set_by_an_external_script/en)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5ODQ1OS1nZXQtdG90YWwtdmFsdWUtb2YtY2FydC1mcm9tLWluZGVwZW5kZWQtcGhwLWZpbGU/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.204 seconds

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

[](#top)
