Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with product listing and javascript


krampak

Recommended Posts

Posted

Hello guys. I'm having 2 problems right now.

 

First, I would like to add an image on product listing to show the stock/stat of every product, like most computer shops does. This is already done:

 

image16nk.jpg

 

But I've created a page called "disponibilitat.php" to show users what those icons mean. This page should be popup when you click the image but I can't make it to popup. The code is (i've edited the quantity column to show stock):

 

 

case 'PRODUCT_LIST_QUANTITY':

$lc_align = 'center';

if ($listing['products_quantity'] == 1) {

$lc_text = '<a href="java script:popupWindow(\'' . tep_href_link(FILENAME_DISPONIBILITAT) . '\')"><img src="images/icons/taronja.gif" '.MISSATGE_STOCK_LIMITAT.' border="0"></a>';

break;

}

elseif ($product_info['products_date_available'] > date('Y-m-d H:i:s')){

$lc_text = '<a href="java script:popupWindow(\'' . tep_href_link(FILENAME_DISPONIBILITAT) . '\')"><img src="images/icons/blau.gif" '.MISSATGE_PENDENT_DE_REBRE.' border="0"></a>';

break;

}

elseif ($listing['products_quantity'] > 0){

$lc_text = '<a href="java script:popupWindow(\'' . tep_href_link(FILENAME_DISPONIBILITAT) . '\')"><img src="images/icons/verd.gif" '.MISSATGE_PLAS_ENTREGA_INMEDIAT.' border="0"></a>';

break;

}

elseif ($listing['products_quantity'] < 1) {

$lc_text = '<a href="java script:popupWindow(\'' . tep_href_link(FILENAME_DISPONIBILITAT) . '\')"><img src="images/icons/vermell.gif" '.MISSATGE_PLAS_ENTREGA_DESCONEGUT.' border="0"></a>';

break;

}

 

When I put the cursor on the image the bar says:

 

java script:popupWindow('http://www.la-tartana.com/disponibilitat.php')

 

What seems ok for me, but it does nothing. (the php file exists of course).

 

Another problem is that I can't show and image description when cursor is over image.

 

And the last problem is that $product_info['products_date_available'] > date('Y-m-d H:i:s')) don't work, I would like to show a blue icon when a product isn't in stock but is going to arrive. I think i can't use $product_info on product_listing.php ?? How could I do it then.

 

 

Wow... so many questions :P Thanks in advanced.

Posted

Second problem solved (show and image description when the cursor is over the image). I was using "alt" to show it and it was wrong, it's "title".

 

Popup and "to arrive icon" still unsolved.

Posted

Uop... first problem solved :P I forgot to add the popupWindow(url) function :P

 

Now there is just one problem, how to check on product_listing.php if a product is going to arrive.

Posted
Can you explain what you mean by that?

 

If you enter on product page (product_info.php) and a product is listed to arrive in some days (you can do it when you add a product in admin panel):

 

12cq1.jpg

 

Product_info page shows you a message saying "This product will be available on XX day of X month".

 

Well, I would like to check the same but not to show that message in product_info, just to show a blue icon in product_listing.php, like the others that you can see on first post.

 

Do you understand me ? :P

 

 

PD: You can't see product_listing.php in your explorer bar, but it's the php file that index.php?cPath=XX uses to show you all products in a category.

 

You can check it http://www.la-tartana.com/index.php?cPath=33

 

"Reloj Estacion" has a red icon when it should be blue, red means it has no stock and blue means it has no stock but will be available soon. I need to check the "will be available soon".

Posted

I think I understand now.

 

You want to show a blue icon for items that are available in the future?

 

In index.php you would need to add p.products_date_available to the queries that start around line 171. Those start where it says:

 

// We are asked to show only a specific category

 

Then, I'm not sure what the code is like that calls your colored stock icons, but basically, in product_listing.php use an if statement like we see in product_info.php

 

if ($listing['products_date_available'] > date('Y-m-d H:i:s')) {

//insert code that shows the blue icon

}else{
//insert code that shows the other icons
}

Posted

Ohh thank you very much !!! I've added p.products_date_available to the $listing_sql query and now is working ! I would never got it without your help, again thank you very much.

Posted

Oh no... it doesn't work at all. Browsing throw categories works ok, but when I use the search or for exemple "show all products from XX manufacturer, it shows the red icon again instead of blue icon. Should I change another query ?

Posted

Ok, i got it. I changed the $select_str query in advanced_search_results.php, now it shows the blue icon.

 

But I don't know why is it showing "Quantity" in column name, I edited the constant PRODUCT_LIST_QUANTITY to "Stock" and not "Quantity". It works good when browsing product categories but not on searches, why ??

Posted

Arrgggggg why can't I edit my posts ???

 

I'll writte it again:

 

Ok, i got it. I changed the $select_str query in advanced_search_results.php, now it shows the blue icon using search but I don't know how to do it if I click on a manufacturer image that shows all products from that manufacturer, it doesn't seem to use the "advanced_search" file (and i can't see which uses cause i've installed the CEO URL contribution).

 

And I don't know why is it showing "Quantity" in column name, I edited the constant PRODUCT_LIST_QUANTITY to "Stock" and not "Quantity". It works good when browsing product categories but not on searches, why ??

Posted

Now I see that manufacturers filter uses Index.php as well. If the modified query that you told me doesn't work I supose that I should modify on of this:

 

// optional Product List Filter

if (PRODUCT_LIST_FILTER > 0) {

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";

} else {

$filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";

}

 

I've tried to add p.products_date_available in both queries but when using manufacturers filters still show red icon instead of blue icon.

 

Any ideas ?

Posted

I forgot to say that the column name problem using search is resolved. I didn't see that there is a TABLE_HEADING_QUANTITY in advanced_search.php translation file, I was only changing the index.php

 

Now I only need to solve the "blue icon problem" when using manufacturers filter on index.php

Posted

Common guys, help me find which query should I edit and how to change it to make blue icon run when using a manufacturer filter in index page.

 

I thought changing:

 

 $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";

 

To

 

 

 $filterlist_sql = "select distinct p.products_date_available, c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";

 

Would be enough (like I did in advanced_search.php) but it doesn't.

Posted

Sorry for leaving you on this.

 

Are you talking about the grey box at the bottom of index.php...with the manufacturer logos in it?

 

I'm not too familiar w/those templates. Is that manufacturer part set up as an infobox? It will be something in index.php ...or where-ever your main page content comes from. What is called for in the code, right after the upcoming products module?

 

If you just find something there, probably called with an "include" ...then go to that file and modify the query. ...but I don't know exactly what you are looking for. :huh: I mean I just don't know where to find it. It probably comes from a separate file.

Posted

Well, is not an infobox, is a box made by me. It's called after upcoming products but the code is:

 

<tr><td><img src=images/m37.gif width=14 height=28><a href=<?=tep_href_link('index.php', 'manufacturers_id=10')?>><img src=images/m38.gif width=96 height=28 border=0></a><a href=<?=tep_href_link('index.php', 'manufacturers_id=13')?>><img src=images/m39.gif width=107 height=28 border=0></a><a href=<?=tep_href_link('index.php', 'manufacturers_id=12')?>><img src=images/m40.gif width=109 height=28 border=0></a><a href=<?=tep_href_link('index.php', 'manufacturers_id=11')?>><img src=images/m41.gif width=91 height=28 border=0></a><img src=images/m42.gif width=19 height=28></td></tr>

 

I just put an image that links to index/manufacturer_id

 

The Upcoming products it's on an Include but this isn't. That's why I think that the query to modify should be the one in "// optional Product List Filter", in the index.php file, like I said on post #14.

 

p.products_date_available is taken from TABLE_PRODUCTS I supose, isn't it ?

Posted

Yes, the date_available comes from table 'products'.

 

I haven't used the manufacturer functions much, so I could be wrong. But it seems to me that the 'optional product list filter' that you see in index.php is for the manufacturer's dropdown that shows at the top right of some category pages, like this one

 

http://demo.oscommerce.com/index.php?cPath=3_10

 

There are 4 occurences of $listing_sql starting at line 171 of index.php. I think the first 2 are the key to your manufacturer pages. Did you add p.products_date_available to all four of those..or at least the first 2?

 

// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
  if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
  } else {
// We show them all
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
  }
} else {
// show the products in a given categorie
  if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
  } else {
// We show them all
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
  }
}

Posted

I may be stupid... I didn't see the first 2 queries... I modified the last 2 queries as you said me some posts before to add p.products_date_available when browsing products categories but I didn't see the 2 queries before that ones....

 

It's running ok now. Thanks for your patient... :blush:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...