X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   3.5.4 Mini Cart gives wrong number of items (https://forum.x-cart.com/showthread.php?t=6589)

DanUK 03-05-2004 01:00 AM

3.5.4 Mini Cart gives wrong number of items
 
I saw this mentioned before with regards to earlier versions. Mini cart is showing groups of items as one item e.g. added 3 x product to cart and mini cart says 1 item. Is this by design?

Thanks

Dan

shan 03-05-2004 01:49 AM

yeh, maybe it should say '3 products'

DanUK 03-05-2004 07:48 AM

Well it doesn't look right. If I have a total quantity of 6 items in my cart I expect to see "6" in the mini cart -what's the point in having the mini cart if it doesn't match up to the main cart? I've mailed X-Cart about this.

Thanks

Dan

Cameron 03-05-2004 02:16 PM

Please let us know what x-cart tells you for a fix on this. I've never noticed it in all the stores I've done, but it's been there as far back as 3.3.x

Thanks,
Cameron

adpboss 03-05-2004 03:40 PM

It's the total number of different products not the total quantity of individual items in the cart.

3 x Red Balloons is only 1 item.
3 x Red Balloons and 2 x Blue Balloons is 2 items.

B00MER 03-05-2004 04:37 PM

This was done with 3.5.4, customer/minicart.php:

Code:

x_session_register ("cart");

$MINICART["total_cost"] = price_format(0);
$MINICART["total_items"] = 0;

if (!empty($cart)) {

        if (!empty($cart["total_cost"]))
                $MINICART["total_cost"] = $cart["total_cost"];
       
        #$MINICART["total_items"] = ((!empty($cart["products"]) and is_array($cart["products"]))?count($cart["products"]):0) + ((!empty($cart["giftcerts"]) and is_array($cart["giftcerts"]))?count($cart["giftcerts"]):0);

        if(!empty($cart["products"])) {
                foreach($cart["products"] as $key => $value) {
                        $MINICART["total_items"] += $value["amount"];
                }
        }

}

$smarty->assign("minicart_total_cost", $MINICART["total_cost"]);
$smarty->assign("minicart_total_items", $MINICART["total_items"]);


This code actually loops over the cart array products index, and finds the amount and adds them up to return a true number of items.

Donations: paypal@molotovbliss.com if you find this useful. ;)

;)

DanUK 03-08-2004 12:35 AM

Thanks Boomer, I'll give that a shot. I still think the mini cart should show the total quantity of items by default. I'll see what X-Cart say. I think they must be busy at the moment as they've not replied to my mails for a while.

Thanks again

Dan

bluesunomi 06-18-2004 03:12 PM

Hi,

This doesn't include gift vouchers in the total no products though, so you need an additional line after the loop ....

after ...

Code:

  if(!empty($cart["products"])) {
      foreach($cart["products"] as $key => $value) {
        $MINICART["total_items"] += $value["amount"];
      }
  }



Put in this line to fix this ....

Code:

        $MINICART["total_items"] += ((!empty($cart["giftcerts"]) and is_array($cart["giftcerts"]))?count($cart["giftcerts"]):0);

mffowler 10-02-2004 08:16 AM

I used this in 4.0.4 (Thanks Boomer), but my "Total" still says $0.00 no matter how many items are in the cart.

This changes when you "View Cart" or "Checkout", but I don't want to redirect to cart for the customer as our average order has 8-10 items.

Does anyone know how to get the total (sub-total) to show in the minicart?

Thanks,

Mike

dankind 03-27-2006 01:53 PM

This mod was exactly what I was looking foor. Thanks a bunch BOOMER!!!

sundance 04-20-2006 08:33 AM

However belated my thanks are

THANKS!

A great little mod that continues to function in my 4.0.17 iteration.

Excellent stuff as usual, Boom.

tqualizerman 07-23-2008 04:43 PM

Re: 3.5.4 Mini Cart gives wrong number of items
 
Just a note, this helpful mod still works in version 4.1.10

c.vogels 09-05-2008 05:14 AM

Re: 3.5.4 Mini Cart gives wrong number of items
 
I've added this mod to x-cart gold 4.1.10. When i add 1 item to my cart, the minicart show's 2 items. When i add another (different) product, it will count +2 in the minicart. When i add the same product again it counts normal (+1).

Does someone know how to fix this. For example: http://www.kledingmetzorg.nl

whsu716 11-19-2008 09:21 PM

Re: 3.5.4 Mini Cart gives wrong number of items
 
Got it:

Quote:

<?php
if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }

x_session_register ("cart");

$MINICART["total_cost"] = price_format(0);
$MINICART["total_items"] = 0;

if (!empty($cart)) {

if (!empty($cart["total_cost"])) {
if (!empty($active_modules["Fast_Lane_Checkout"]))
$MINICART["total_cost"] = $cart["display_subtotal"];
else
$MINICART["total_cost"] = $cart["total_cost"];
}

$MINICART["total_items"] = ((!empty($cart["products"]) and is_array($cart["products"]))?count($cart["products"]):0) + ((!empty($cart["giftcerts"]) and is_array($cart["giftcerts"]))?count($cart["giftcerts"]):0);

if(!empty($cart["products"])) {
foreach($cart["products"] as $key => $value) {
$MINICART["total_items"] += $value["amount"] - 1;
}
}


}

$smarty->assign("minicart_total_cost", $MINICART["total_cost"]);
$smarty->assign("minicart_total_items", $MINICART["total_items"]);
?>


Just needed to add the "-1"

Doctored Locks 01-16-2009 10:41 AM

Re: 3.5.4 Mini Cart gives wrong number of items
 
I just added it to ours (we also have anon carts and buy together). Works like a charm. :)

maximillian 03-23-2009 02:27 AM

Re: 3.5.4 Mini Cart gives wrong number of items
 
Quote:

Originally Posted by whsu716
Got it:



Just needed to add the "-1"


I have the same problem and your post didn't help: when "add to cart" button is clicked, it adds twice more qty of products than it is choosed from the drop down qty list.

Can anyone suggest a fix for this?

maximillian 03-23-2009 12:02 PM

Re: 3.5.4 Mini Cart gives wrong number of items
 
This is turning into nightmare!
I even returned to original version of minicart.php and I still get the same wrong result: I choose to add 2 pcs of one product and the cart shows 4 pcs. So it can't be this modification that is causing it. :(

Victor D 03-24-2009 12:15 AM

Re: 3.5.4 Mini Cart gives wrong number of items
 
Quote:

This is turning into nightmare!
I even returned to original version of minicart.php and I still get the same wrong result: I choose to add 2 pcs of one product and the cart shows 4 pcs. So it can't be this modification that is causing it. :sad:

Are the quantity of products is correct on the cart page?

maximillian 03-24-2009 12:40 AM

Re: 3.5.4 Mini Cart gives wrong number of items
 
I don't know what to say. This morning everyhting works fine?!

Victor D, all qtys shown in minicart and cart are correct, the problem was when I wanted to add a product to cart. Instead of adding 1, 2 or more, when I clicked "add to cart" button once, it would add 2, 4 or twice more than it was choosed.

And now it's working correctly. I really don't know what was/is/again will be wrong???


All times are GMT -8. The time now is 06:36 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.