Get the cart quantity

  • Posts: 58
  • Thank you received: 2
10 years 8 months ago #148082

Hi,

We need to implement a small button that links to the checkout area. The button is a simple cart with the current cart total items next to it. How can this be achieved in a module?

Thanks
M

Hika Business

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

  • Posts: 12953
  • Thank you received: 1778
10 years 8 months ago #148103

Hi,
Regarding the button, a simple Custom HTML module with the link to your checkout process will do the job but can you give me more information about that part :

The button is a simple cart with the current cart total items next to it.

The following user(s) said Thank You: mcruip

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

  • Posts: 58
  • Thank you received: 2
10 years 8 months ago #148215

Yes, a custom html like module is what we thought, but we need to add the user current car total next to it. Example:
Your cart: 5
In which 5 is the current total items currently in the cart.
The question is where do we get the cart object or cart quantity value.

Thanks!
M

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

  • Posts: 13201
  • Thank you received: 2322
10 years 8 months ago #148221

Hi,

To get the cart data, you can see how we get it in the file "components/com_hikashop/views/product/view.html.php" in the "cart()" function:

		$class = hikashop_get('class.cart');
		$cart_type = 'cart';
		$cart_id =$app->getUserState( HIKASHOP_COMPONENT.'.'.$cart_type.'_id', 0, 'int' );
		$class->get($cart_id,true,$cart_type);
		$full = $class->loadFullCart(true,true,true);
		$rows = $full->products;
Thanks to this code you will have the cart object in $full and the products in $rows.

The following user(s) said Thank You: mcruip

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

  • Posts: 58
  • Thank you received: 2
10 years 8 months ago #148344

Thanks Xavier for the very useful guidance. That's the object we need to get the data and not break any other functionality.
Thank you
M

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

Time to create page: 0.077 seconds
Powered by Kunena Forum