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)
-   -   Items in Cart - Doesn't count quantities (https://forum.x-cart.com/showthread.php?t=34818)

creativearc 10-22-2007 02:48 PM

Items in Cart - Doesn't count quantities
 
Currently - our "items in cart" is not counting the quantity of items. It only counts how many unique items there are in the cart.

Is there an easy way to modify this to count the total amount of items - including their quantities (so if there were 2 different items, each with quantity of 10 - it would show 20)

balinor 10-22-2007 02:53 PM

Re: Items in Cart - Doesn't count quantities
 
http://forum.x-cart.com/showthread.php?t=29370

creativearc 10-23-2007 08:47 AM

Re: Items in Cart - Doesn't count quantities
 
Well - that shows the not-so-goodness of xcart forums search function...

That thread helped - thank you.

balinor 10-23-2007 08:49 AM

Re: Items in Cart - Doesn't count quantities
 
All depends on what you search for. The new forum search is fine, just need the keywords is all. Thread came right up for me.

cflsystems 10-24-2007 04:11 AM

Re: Items in Cart - Doesn't count quantities
 
I actually took this code and changed it a little bit. Instead of replacing the code in minicart.php I added it.
Here is what I did:
1. Open minicart.php and add
Code:

$MINICART["total_products"] = 0;
right after
Code:

$MINICART["total_items"] = 0;
2. In
Code:

$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);
replace
Code:

$MINICART["total_items"]
with
Code:

$MINICART["total_products"]
3. Then add this
Code:

if (!empty($cart["products"]) and is_array($cart["products"])) {
                foreach ($cart["products"] as $_tmp)
                        $MINICART["total_items"] += $_tmp["amount"];
        }

        if (!empty($cart["giftcerts"]) and is_array($cart["giftcerts"])) $MINICART["total_items"] += $cart["giftcerts"];

4. Just before the closing tag "?>" add
Code:

$smarty->assign("minicart_total_products", $MINICART["total_products"]);
5. Add a new language lable "lbl_minicart_products"
6. Then open customer/main/minicart.tpl and add the new variable "minicart_total_products" where you want it to appear. Something like this
Code:

<tr>
        <td colspan="2" class="VertMenuItems"><b>{$lng.lbl_minicart_products}: </b></td>
        <td class="VertMenuItems"><font color="#a10000">{$minicart_total_products}</font></td>
</tr>

That's it. It looks to work fine so far. This is done on 4.1.7 original files. Note sure if it will work on other version. Attached is a snapshot of the cart with the above changes.
Attachment 597

carpeperdiem 10-24-2007 06:52 AM

Re: Items in Cart - Doesn't count quantities
 
moving to completed mods...


All times are GMT -8. The time now is 10:08 PM.

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