Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / New Field In Product Listing Page

New Field In Product Listing Page

Locked

Views: 1,044

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
3 Dec 2010, 9:22 PM
#1
jill8026 avatar

jill8026

Totally Zenned

Join Date:
May 2007
Posts:
461
Plugin Contributions:
0

New Field In Product Listing Page

In an effort to try and automate my site a bit more with inventory I added a new field called products_stock that encases my manufacturers api code for product inventory.

I have it working on the products just fine, but I would also like to offer the stock amount on the product listing page......since I do allow people to purchase out of stock items I want to let them see before they go to the product page whether it is on stock or not so they do not waste their time!

You can see it in action here right above the cart icon:

http://outdoorplaytoys.com/big-wheels-12v-go-kart

But I would also like to add it to this page for all the products right above the details box:

http://outdoorplaytoys.com/injusa

I just used php on the product info page - but am lost on the product listing page on how to add this in?!?!?!

Any help would be GREATLY appreciated......

3 Dec 2010, 10:07 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: New Field In Product Listing Page

I just used php on the product info page - but am lost on the product listing page on how to add this in
In the file and the additional required files tpl_modules_product_listing.php
Somewhere in those files an array is built
Sorry I don't know php well enough to tutor on the array but this may assist you

4 Dec 2010, 12:38 PM
#3
jill8026 avatar

jill8026

Totally Zenned

Join Date:
May 2007
Posts:
461
Plugin Contributions:
0

Re: New Field In Product Listing Page

Ok after a BUNCH of tweaking I think I got this!

In your product_listing.php file (in your CUSTOM folder of course)

Add you new field to this code by going from this:

$lc_text = '<h3 class="itemTitle"><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']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>'

to this:

$lc_text = '<h3 class="itemTitle"><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']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' . $listing->fields['products_stock'];

You can see I added . $listing->fields['products_stock']; at the end.

Then you need to go to your includes/index_filters/default_filter.php and add in your new query just by following along with what is already there....

Easier than I thought it would be!

You can see what was done by visiting here:

http://outdoorplaytoys.com/feber-toys

below the product name is a field for the inventory which is an API to my manufacturers website.....