If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / Show "Quantity in Cart" on listing and search results pages?

Show "Quantity in Cart" on listing and search results pages?

Started by chadderuski on 1 May 2013, 8:39 PM · Views: 724

Results 1 to 5 of 5
1 May 2013, 8:39 PM
#1
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Show "Quantity in Cart" on listing and search results pages?

Currently, when you get to a product page of an item that you've previously added to your cart, you get the "Quantity in Cart".

What I'd like to do is also show this on the listing and search results pages, if possible.

Any ideas?

Thanks!

6 May 2013, 8:23 PM
#2
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Show "Quantity in Cart" on listing and search results pages?

Well, I found what I believe the relevant code in tpl_product_info_display.php:

<?php $display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
...

$display_qty will have the number of items in the cart for the products_id...

So now I need to find where to put that. I'm looking for the regular product listings and search results listings... anyone?

6 May 2013, 10:13 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show "Quantity in Cart" on listing and search results pages?

You could add this to the code in the:
/includes/modules/products_listing.php

using your templates and overrides and it will work with Products that do not have Attributes, around line 142 or so add the code in RED:

        $the_button = $lc_button[B] . '<br>' . ($_SESSION['cart']->get_quantity($listing->fields['products_id']) > 0 ? 'In Cart: ' . $_SESSION['cart']->get_quantity($listing->fields['products_id']) : '')[/B];
        $products_link = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
        $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
        $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 May 2013, 8:34 PM
#4
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Show "Quantity in Cart" on listing and search results pages?

Thank you Ajeh! That works as expected!

I was totally digging in the wrong place (includes/templates) so no wonder I wasn't having any luck!

Very much appreciated!

-chadd

7 May 2013, 9:49 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show "Quantity in Cart" on listing and search results pages?

You are most welcome ... thanks for the update that this is working for you ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!