Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add products_url to new_products.php


afshin2740

Recommended Posts

Posted

Hi . I want to add products_url to new_products.php

new_products.php includes this code :

<?php

/*

$Id: new_products.php,v 2.0 2006/11/13 10:42:00 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

?>

 

<!-- new_products //-->

<?php

$info_box_contents = array();

$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

new contentBoxHeading($info_box_contents);

// new noborderBox($info_box_contents);

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {

$sql = "select distinct p.products_id, p.products_image, p.products_model, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price, mnf.manufacturers_name, rvw.reviews_rating from " . TABLE_PRODUCTS . " p left join ".TABLE_SPECIALS." s on p.products_id = s.products_id left join ".TABLE_MANUFACTURERS." mnf on p.manufacturers_id = mnf.manufacturers_id left join ".TABLE_REVIEWS." rvw on p.products_id = rvw.products_id where p.products_status = '1' order by p.products_date_added desc limit ".MAX_DISPLAY_NEW_PRODUCTS;

$new_products_query = tep_db_query($sql);

 

 

} else {

 

$sql = "select distinct p.products_id, p.products_image, p.products_model, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price, mnf.manufacturers_name, rvw.reviews_rating from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on (p.products_id = s.products_id) left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on (p.products_id = p2c.products_id) left join " . TABLE_CATEGORIES . " c on (p2c.categories_id = c.categories_id) left join ".TABLE_MANUFACTURERS." mnf on (p.manufacturers_id = mnf.manufacturers_id) left join ".TABLE_REVIEWS." rvw on (p.products_id = rvw.products_id) where c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS;

$new_products_query = tep_db_query($sql);

}

 

// custom controls for this box

IND_PRODUCT_LIST_COL_NUM;

$prod_name_length = 26;

$prod_name_cont = '...';

// custom controls

 

// if more than 2 products per row, cut off title to fit box

if (IND_PRODUCT_LIST_COL_NUM > 2) {

$cut_prod_name = 'true';

} else {

$cut_prod_name = 'false';

}

 

$row = 0;

$col = 0;

$info_box_contents = array();

 

while ($new_products = tep_db_fetch_array($new_products_query)) {

 

// get full name, then cut it to fit length of the boxes..

if ( $cut_prod_name == 'true' ) {

$new_products['products_name_full'] = tep_get_products_name($new_products['products_id']);

$new_products['products_name'] = substr($new_products['products_name_full'], 0, $prod_name_length);

// if product name has been cut short, add ... to the end

if ( strlen($new_products['products_name_full']) > $prod_name_length ) {

$new_products['products_name'] .= $prod_name_cont;

}

} else {

// if only one column, display the full product title

$new_products['products_name'] = tep_get_products_name($new_products['products_id']);

}

// get full name, then cut it to fit length of the boxes..

 

// setup names and variables to be used if no matching results are found

$reviews_rating = $new_products['reviews_rating'];

$manufacturers_name = $new_products['manufacturers_name'];

$products_model = $new_products['products_model'];

 

if(!$manufacturers_name==null) {

$manufacturers_name = '<b>' . TABLE_HEADING_MANUFACTURER . '</b><br>' . $manufacturers_name;

} else {

$manufacturers_name = '<b>' . TABLE_HEADING_MANUFACTURER . ' </b><br>None';

}

 

if(!$products_model==null) {

$products_model = '<b>' . TABLE_HEADING_MODEL . ':</b><br>' . $products_model;

} else {

$products_model = '<b>' . TABLE_HEADING_MODEL . ': </b><br>None';

}

 

if(!$reviews_rating==null){

$reviews_rating = '<img src="images/stars_'. $new_products['reviews_rating'].'.gif" alt="'.$new_products['reviews_rating'] . TABLE_HEADING_TEXT_OF_5_STARS . ' ('.$new_products['products_name'].')" border="0" align="absmiddle">';

} else {

$reviews_rating = '<span class="smallText"><a href="product_reviews_write.php?products_id='.$new_products['products_id'].'" alt="' . TABLE_HEADING_FIRST_TO_RATE . '"><img src="images/stars_0.gif" alt="' . TABLE_HEADING_FIRST_TO_RATE . '" border="0" align="absmiddle"></a></span>';

}

// setup names and variables to be used if no matching results are found

 

// only display what is set in 'product listing'

if (IND_PRODUCT_LIST_IMAGE == "Yes") {

$show['image'] = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .

$new_products['products_id']) . '">' .

tep_image(DIR_WS_IMAGES . $new_products['products_image'],

$new_products['products_name_full'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

}

if (IND_PRODUCT_LIST_MANUFACTURER == "Yes") {

$show['manufacturer'] = '

<tr>

<td height="17" class="smallText"><br>' . $manufacturers_name . '</td>

</tr>';

}

if (IND_PRODUCT_LIST_MODEL == "Yes") {

$show['model'] = '

<tr>

<td height="17" class="smallText"><br>' . $products_model . '</td>

</tr>';

}

if (IND_PRODUCT_LIST_QUANTITY == "Yes") {

$show['quantity'] = '

<tr>

<td height="17" class="smallText">

<b><br>' . TABLE_HEADING_QUANTITY . ':<br></b>' .

$new_products['products_quantity'] .

'</td>

</tr> ';

}

if (IND_PRODUCT_LIST_WEIGHT == "Yes") {

$show['weight'] = '

<tr>

<td height="17" class="smallText">

<b><br>' . TABLE_HEADING_WEIGHT . ':<br></b>' .

$new_products['products_weight'] . ' Kg

</td>

</tr> ';

}

if (IND_PRODUCT_LIST_PRICE == "Yes") {

$show['price'] = '

<tr>

<td height="17" class="smallText">

<b><br>' . TABLE_HEADING_PRICE . ':<br><font color="#FF5C02">' .

$currencies->display_price($new_products['products_price'],

tep_get_tax_rate($new_products['products_tax_class_id'])) .

'</font></b>

</td>

</tr> ';

}

if (IND_PRODUCT_LIST_RATING == "Yes") {

$show['rating'] = '

<tr>

<td height="17" class="smallText">

<b><br>' . TABLE_HEADING_RATING . ':</b><br>'.$reviews_rating .

'</td>

</tr>';

}

if (IND_PRODUCT_LIST_DESCRIPTION == "Yes") {

// GET PROD DESC

$sql = 'SELECT `products_description` FROM `products_description` WHERE products_id ='.$new_products['products_id'].' && language_id='.(int)$languages_id;

$description_query = tep_db_query($sql);

$description = mysql_fetch_array($description_query, MYSQL_ASSOC);

$description['products_description'] = substr($description['products_description'], 0, 250);

$desc_len = strlen($description['products_description']);

$description['products_description'][$desc_len-1] = '.';

$description['products_description'][$desc_len-2] = '.';

$description['products_description'][$desc_len-3] = '.';

$show['desc'] = '

<tr>

<td><span class="smallText">' .

$description['products_description'] . '</span>

</td>

</tr>';

}

if (IND_PRODUCT_LIST_BUY_NOW == "Yes") {

$show['buy_now'] = '

<td>

<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_BUY_NOW) . '</a>

</td>';

}

if (IND_PRODUCT_LIST_DETAILS == "Yes") {

$show['details'] = '

<td>

<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .

$new_products['products_id']) . '" class="infoBoxContents">

<img src="images/more.gif" width="60" height="17" /></a>

</td>';

}

if (IND_PRODUCT_LIST_NAME == "Yes") {

$show['name'] = '

<tr>

<td bgcolor="#eeeeee" class="infoBoxHeading" height="" style="padding:2px;">

 <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .

$new_products['products_id']) . '" alt="' . $new_products['products_name_full'] .

'" class="centralBox">' . $new_products['products_name'] . '</a>

</td>

</tr>';

}

// only display what is set in 'product listing'

 

// start the indivdual box

$tbl_product = '

<div id="mahsool">

<table id="tbl-main" cellpadding="0" cellspacing="0">

<tr>

<td colspan="2" id="tbl-top"> </td>

</tr>

<tr>

<td colspan="2" id="tbl-title"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a>

</td>

</tr>

 

<tr>

<td width="192" height="127" id="tbl-content">' .

$description['products_description'] . '</td><td width="100" id="tbl-img">' . $show['image'] . '</td></tr>

<tr><td height="32" colspan="2" id="tbl-buy">

<div id="div-price">'.$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])).'</div>

 

<div id="div-buy" align="center"><a href="' . tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($new_products['products_url']), 'NONSSL', true, false) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_BUY_NOW) . '</a></div>

 

<div id="div-more" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .

$new_products['products_id']) . '" class="infoBoxContents">

<img src="images/more.gif" width="60" height="17" /></a></div>

 

</td>

</tr>

</table>

</div>';

// end the indivdual box

 

$info_box_contents[$row][$col] = array('align' => 'center',

'params' => 'class="smallText" width="33%" valign="top"',

'text' => $tbl_product);

 

$col ++;

if ($col >= IND_PRODUCT_LIST_COL_NUM) {

$col = 0;

$row ++;

}

}

 

new centralBox($info_box_contents);

//echo $info_box_contents[0][0]['text'];

?>

 

<!-- new_products_eof //-->

 

 

This database request is in the products_new.php . but I couldn't include it .

The Code in products_new.php is :

<?php

$products_new_array = array();

 

$products_new_query_raw = "select p.products_id, pd.products_name, pd.short_desc, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";

$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 

Anybody can help me on adding products_url to new_products.php ?

Posted

Thats a fair bit of code your asking someone to write for you, have you tried anything yourself?

 

There may be a contribution with this in, have you searched there?

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted

So if its a fair bit of code, why you dont help me ? I have killed my self to do it . I searched for it everywhere . I couldn't find anything for it . If I could do it, why should I wait for other's help ?

Archived

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

×
×
  • Create New...