X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Adding "More Colors" to products_t.tpl listing (https://forum.x-cart.com/showthread.php?t=62325)

Ana 01-13-2012 08:17 AM

Adding "More Colors" to products_t.tpl listing
 
I've checked through this forum back to 1/2011 and I haven't seen anything addressing this (or I've missed it).

I'd like to add "More Colors" to the products_t.tpl listing if there is more than one color option for any given product so customers know while browsing that there are more colors available.

Has anybody done this or does anybody know of a module that will?

I've tried to code it myself but... epic fail.

Thanks in advance!

Ana

JWait 01-14-2012 08:47 AM

Re: Adding "More Colors" to products_t.tpl listing
 
What you are talking about are referred to as "product options" and the way x-cart handles these are if the customer clicks the "add to cart" button in either "featured products" or the "category" page they will be re-directed to the "product" page where they can choose the option.

In order to allow the customer to choose the option(s) on the "featured products" or the "category" page the code from product_details.tpl would need to be added to featured.tpl, and products.tpl or products_t.tpl.

Ana 01-14-2012 02:19 PM

Re: Adding "More Colors" to products_t.tpl listing
 
No, I want the words "More Colors" to appear on the product listing page so the customer knows the product is available in more colors while browsing the product list. So if the product has the product option of "Color" and there is more than one choice for that option, the words "More colors" appear on the products_t list with the product "as info".

I'm all too familiar with the options and variants of x-cart after working with it for 7 years. I think they are the reason for some of my silver hair. LOL

Ana

JWait 01-17-2012 06:40 AM

Re: Adding "More Colors" to products_t.tpl listing
 
If "more colors" is the only product option you have (i.e. no "size", "length", etc.) then it should be a simple matter of checking if the product has options in your products_tpl and displaying a "more colors" text or text variable.

Something like adding..
{if $active_modules.Product_Options ne ""}"More Colors"{/if} to your products_t.tpl might work.

Otherwise, just follow how product options are displayed on the product.tpl and product_details.tpl to find where it is determined where a product has options or not and add that to your products_t.tpl in the appropriate place with the appropriate text.

Ana 01-17-2012 09:05 AM

Re: Adding "More Colors" to products_t.tpl listing
 
Actually, we do have sizes as well but I see what you are getting at. All of our products have at least one color option so it would have to be any product who's color option values are greater than 1.

Basically if the product $v.class = color and it's classid.optionid value > 1 then display "more colors".

My problem is getting the coding correct. I'm not a wizbang at it ;)

Ana

cherie 01-17-2012 01:20 PM

Re: Adding "More Colors" to products_t.tpl listing
 
I don't think detailed option data is available on product listings pages. You need to customize the php to go get all of the option data for the products on that page. I believe there are other threads that have code to help get that data.

Ana 01-18-2012 05:56 AM

Re: Adding "More Colors" to products_t.tpl listing
 
I'm not looking for detailed options on the product listing page. I just want the words "more colors" to appear on the product listing page beneath the image if the product has more than one color option available.

Ana

cflsystems 01-18-2012 06:48 AM

Re: Adding "More Colors" to products_t.tpl listing
 
You still need to query the db, products options is not available on products list page. Try this

In include/search.php find
PHP Code:

// foreach ($products as $k => $v)
unset($thumb_dims); 


and just before add (replace 'Color' with your option class name exactly as you have it)

PHP Code:

// added by CFL Systems for 'more colors' note
$products[$k]['more_colors'] = func_query_first_cell("select count(*) from $sql_tbl[classes] where productid = $v[productid] and avail = 'Y' and class = 'Color'") > 'Y' 'N'


then in the products list template where you want it to show

Code:

{if $product.more_colors eq 'Y'}
MORE COLORS NOTE
{/if}


Ana 01-18-2012 08:35 AM

Re: Adding "More Colors" to products_t.tpl listing
 
Quote:

Originally Posted by cflsystems
You still need to query the db, products options is not available on products list page. Try this

In include/search.php find
PHP Code:

// foreach ($products as $k => $v)
unset($thumb_dims); 


and just before add (replace 'Color' with your option class name exactly as you have it)

PHP Code:

// added by CFL Systems for 'more colors' note
$products[$k]['more_colors'] = func_query_first_cell("select count(*) from $sql_tbl[classes] where productid = $v[productid] and avail = 'Y' and class = 'Color'") > 'Y' 'N'


then in the products list template where you want it to show

Code:

{if $product.more_colors eq 'Y'}
MORE COLORS NOTE
{/if}



You always seem to understand what I'm getting at, Steve! LOL! Thanks so much.

I had to do a little modification on it as all our products have at least one color so they will all have the class "Color", however, if there is more than one color the classtext is "Select Color" instead of "Color". Changed it to the classtext version and voila.

Steve, YOU ROCK!

Ana

cflsystems 01-18-2012 09:37 AM

Re: Adding "More Colors" to products_t.tpl listing
 
No problem, glad you got it working


All times are GMT -8. The time now is 06:34 PM.

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