Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

adding new buy now button


Silverado05

Recommended Posts

Posted

Hello, I have the featured products and specials contribution installed on my shop that replaces the what's new for the month box ect. What I am wanting to do is add a buy now button below the price. Now I have both part of the code just having problems putting them together. So if anyone could help me out that would be great.

 

Code for button:

<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');

 

 

Code from featured file:

   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' .
									   $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>');
} else {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])));
}	
$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
 }
 if($num) {

  new contentBox($info_box_contents);
 }
} else // If it's disabled, then include the original New Products box
{
  include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);
}
?>
<!-- featured_products_eof //-->

 

 

Now I didn't post the entire file as I know where the code needs to go, so I only post that part. Just not sure how to put it in. I tried and kept getting errors and my php isn't great right now. Any help would be greatly appreciated.

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

Ok I got the code inserted with no errors but, The buy now buttons don't work. Is there something I am missing?

 

Here is the code I am working with:

 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>' . '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
} else {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									  'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,  'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] .'</a><br>' . $featured_products_price. '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
}

 

 

 

Here is what it looks like:

 

feature1.gif

 

 

Any idea of why it's not working? Any help with this would be great.

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

Just that, it's not working. It doesn't add to cart it just refreshes the page.

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

make sure you discard the array

 

instead of this:

 

tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL')

 

try

 

tep_href_link(basename($PHP_SELF), , tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL')

Posted

ok that works for me, thanks for the help enigma

 

here is the full code if someone needs it

 

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License

 Featured Products V1.1
 Displays a list of featured products, selected from admin
 For use as an Infobox instead of the "New Products" Infobox  
*/
?>
<!-- featured_products //-->
<?php
if(FEATURED_PRODUCTS_DISPLAY == 'true')
{
 $featured_products_category_id = $new_products_category_id;
 $cat_name_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $featured_products_category_id . "' limit 1");
 $cat_name_fetch = tep_db_fetch_array($cat_name_query);
 $cat_name = $cat_name_fetch['categories_name'];
 $info_box_contents = array();

 if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) {
$info_box_contents[] = array('align' => 'left', 'text' => '<a class="headerNavigation" href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>');

 list($usec, $sec) = explode(' ', microtime());
 srand( (float) $sec + ((float) $usec * 100000) );
 $mtm= rand();

$featured_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
$info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
$featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 $row = 0;
 $col = 0; 
 $num = 0;
 while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); }
$featured_products['products_name'] = tep_get_products_name($featured_products['products_id']);
if($featured_products['specstat']) {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>' . '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
} else {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									  'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,  'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] .'</a><br>' . $featured_products_price. '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
}   
$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
 }
 if($num) {

  new contentBox($info_box_contents);
 }
} else // If it's disabled, then include the original New Products box
{
  include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);
}
?>
<!-- featured_products_eof //-->

Posted

Actully I lost the price... LoL. I noticed it after the fact though when I posted the code above. I installed Wolfen Feature Sets to do what I wanted, but I think I will implement this to my specials though. Once you figure how to add the price with the buy now button let me know...

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted
make sure you discard the array

 

instead of this:

 

tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL')

 

try

 

tep_href_link(basename($PHP_SELF), , tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL')

 

 

That above did not work for me. Did I insert it wrong?

 

  'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $product_specials['products_image'], $product_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . $product_specials['products_name'] . '</a><br>' . $products_price.  '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');

 

 

 

Like I said in my previous post I am doing this on the speicals now instead of feature but thier both the same. I got the price to display with the price now but just need to get the buy now button to actually work. So if anyone can help me with that then it should be good to go.

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

I cant get the price back yet, but when I use your bit of code above i lose the image also, maybe its because we are working on different files.

Posted

Yep, Yep. I got side tracked. I will start working on the other one again and let me see if I can get it to work on that file as well.

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

Try this, I have no way to test it since I have completely removed the the contribution since it conflicted with the Wolfenen. It may or may not work.

 

 

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License

 Featured Products V1.1
 Displays a list of featured products, selected from admin
 For use as an Infobox instead of the "New Products" Infobox
*/
?>
<!-- featured_products //-->
<?php
if(FEATURED_PRODUCTS_DISPLAY == 'true')
{
 $featured_products_category_id = $new_products_category_id;
 $cat_name_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $featured_products_category_id . "' limit 1");
 $cat_name_fetch = tep_db_fetch_array($cat_name_query);
 $cat_name = $cat_name_fetch['categories_name'];
 $info_box_contents = array();

 if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) {
$info_box_contents[] = array('align' => 'left', 'text' => '<a class="headerNavigation" href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>');

 list($usec, $sec) = explode(' ', microtime());
 srand( (float) $sec + ((float) $usec * 100000) );
 $mtm= rand();

$featured_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
$info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
$featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 $row = 0;
 $col = 0;
 $num = 0;
 while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); }
$featured_products['products_name'] = tep_get_products_name($featured_products['products_id']);
if($featured_products['specstat']) {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>' . '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>'. '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
} else {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									  'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,  'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] .'</a><br>' . $featured_products_price. '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>' . '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
}
$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
 }
 if($num) {

  new contentBox($info_box_contents);
 }
} else // If it's disabled, then include the original New Products box
{
  include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);
}
?>
<!-- featured_products_eof //-->

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

This should fix the two buttons, but what about the price?

 

 

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License

 Featured Products V1.1
 Displays a list of featured products, selected from admin
 For use as an Infobox instead of the "New Products" Infobox
*/
?>
<!-- featured_products //-->
<?php
if(FEATURED_PRODUCTS_DISPLAY == 'true')
{
 $featured_products_category_id = $new_products_category_id;
 $cat_name_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $featured_products_category_id . "' limit 1");
 $cat_name_fetch = tep_db_fetch_array($cat_name_query);
 $cat_name = $cat_name_fetch['categories_name'];
 $info_box_contents = array();

 if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) {
$info_box_contents[] = array('align' => 'left', 'text' => '<a class="headerNavigation" href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>');

 list($usec, $sec) = explode(' ', microtime());
 srand( (float) $sec + ((float) $usec * 100000) );
 $mtm= rand();

$featured_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
$info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
$featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 $row = 0;
 $col = 0;
 $num = 0;
 while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); }
$featured_products['products_name'] = tep_get_products_name($featured_products['products_id']);
if($featured_products['specstat']) {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>' . '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
} else {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									  'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,  'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] .'</a><br>' . $featured_products_price. '<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>' . '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
}
$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
 }
 if($num) {

  new contentBox($info_box_contents);
 }
} else // If it's disabled, then include the original New Products box
{
  include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);
}
?>
<!-- featured_products_eof //-->

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

no that still gives - image and 2 buy now buttons, no title or price.

 

Thanks for your help

 

Danny

Posted

for the price problem is the $featured_products_price variable that is not initialized anywhere. So replace it with

 

$featured_products['products_price']

 

and retry.

Posted

ok guys finaly got it done, thanks for all the help

 

Regards

Danny

 

} else {
  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									  'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,  'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] .'</a><br>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $featured_products['products_name'] . TEXT_NOW) .'</a>');
}

Posted

Yea after getting some sleep I see what I was doing. I was taking the code you had post previously an was adding another button to it forget it already had it on there....LoL.

 

 

Ok I am still having problems getting the buy now button to work. What I mean by work is adding to cart. It doesn't work even if a user is logged in or not. I have also noticed that buy now buttons on my feature set on my index page where I am using this code doesn't work etheir. Here is the code that is displaying properly on the index but not working...

 

  'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $product_specials['products_image'], $product_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . $product_specials['products_name'] . '</a><br>' . $products_price.  '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $product_specials['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>');

 

Any idea why or any suggestions?

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

where the $product_specials is instantiated. I see it being used but where in your code is initially set? I do not see just from the code fragment.

Posted

Sorry I can't elaborate on it, I have to go pick my daughter up, but here is the entire file:

 

<?php
/*
 $Id: product_specials.php,v 1.0 2005/11/11 00:00:00 holforty Exp $

 Designed for: osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2005 Todd Holforty - [email protected]

 Released under the GNU General Public License
*/
?>
<!-- product_specials //-->
<?php

// are we viewing a specific product? ($product_info['products_id'] is set if we are)
 if (tep_not_null($product_info['products_id'])) {
$the_products_catagory_query = tep_db_query("select products_id, categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $product_info['products_id'] . "'" . " order by products_id,categories_id");
$the_products_catagory = tep_db_fetch_array($the_products_catagory_query);

$product_category_id = $the_products_catagory['categories_id'];
 }

 if ( (LIMIT_PRODUCT_SPECIALS_SCOPE=='true') && !empty($new_products_category_id) ) { /// We are in category depth 
$product_specials_query = tep_db_query("select distinct p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, specials s where p.products_status='1' and p.products_id=s.products_id and p.products_id=pd.products_id and pd.language_id='".(int)$languages_id."' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and s.status='1' and c.parent_id = '" . (int)$new_products_category_id . "' order by rand() limit ".MAX_DISPLAY_PRODUCT_SPECIALS); 
 } else if ( (LIMIT_PRODUCT_SPECIALS_SCOPE=='true') && !empty($product_category_id) ) { // products info page
$product_specials_query = tep_db_query("select distinct p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, specials s where p.products_status='1' and p.products_id=s.products_id and p.products_id=pd.products_id and pd.language_id='".(int)$languages_id."' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and s.status='1' and c.categories_id = '" . (int)$product_category_id . "' order by rand() limit ".MAX_DISPLAY_PRODUCT_SPECIALS); 
 } else { // default
$product_specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, specials s where p.products_status='1' and p.products_id=s.products_id and p.products_id=pd.products_id and pd.language_id='".(int)$languages_id."' and s.status='1' order by rand() limit ".MAX_DISPLAY_PRODUCT_SPECIALS); 
 }

 if (tep_db_num_rows($product_specials_query)>0) {

$info_box_contents = array();
$info_box_contents[] = array('text' => '<a href="'.tep_href_link(FILENAME_SPECIALS).'">'.TABLE_HEADING_PRODUCT_SPECIALS.'</a>' );

new infoBoxHeading($info_box_contents,false,false, tep_href_link(FILENAME_SPECIALS));

$row = 0;
$col = 0;
$info_box_contents = array();
while ($product_specials = tep_db_fetch_array($product_specials_query)) {
  $products_price = (tep_not_null($product_specials['specials_new_products_price'])?'<s>'.$currencies->display_price($product_specials['products_price'], tep_get_tax_rate($product_specials['products_tax_class_id'])).'</s>  ':'').'<span class="productSpecialPrice">' . $currencies->display_price($product_specials['specials_new_products_price'], tep_get_tax_rate($product_specials['products_tax_class_id'])).'</span>'; 
  $info_box_contents[$row][$col] = array('align' => 'center',
										 'params' => 'class="smallText" width="33%" valign="top"',
										 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $product_specials['products_image'], $product_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . $product_specials['products_name'] . '</a><br>' . $products_price.  '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $product_specials['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>');

  $col ++;
  if ($col > PRODUCT_SPECIALS_DISPLAY_COLUMNS-1) {
	$col = 0;
	$row ++;
  }
}

new contentBox($info_box_contents);

 }
?>
<!-- product_specials_eof //-->

 

 

 

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

maybe the $PHP_SELF is not set like if your are looking in the root of the domain instead of specifying a script. Did you try instead of

 

basename($PHP_SELF)

 

this:

FILENAME_DEFAULT

 

 

at least it will stay on the index.php script just in case that causes the problem.

Posted

Could you give me an example so I can see if I did it right. I tried it but got errors. The way it is now all that happens when you click on the button is the page refreshes. Kinda weird that it happens on my feature set contribution which is a completely different from this file. Only thing that has me thinking because the two are happening on the same page. I don't know if that has anything to do with it or not. I am going to keep playing with it and dig around some more. If you know of anything else please let me know.

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

try it like

 

...........tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . ..............

Posted

I just don't know why this isn't working. I have even tried the button configuration that is on my product_info pages that work and can't get it to work on it. It will display but won't add to cart.

 

'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $product_specials['products_image'], $product_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . $product_specials['products_name'] . '</a><br>' . $products_price.  '<br>' . tep_draw_hidden_field('products_id' , $product_specials['products_id'])  . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART));

 

 

Then I tried it the way you suggest and still nothing.

 

 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $product_specials['products_image'], $product_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_specials['products_id']) . '">' . $product_specials['products_name'] . '</a><br>' . $products_price.  '<br><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $product_specials['products_id']) . '">' . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>');

 

 

I am starting to think it has something to do with it being on the index page. Don't know if that matters much or not but my feature set buttons don't work etheir You view the properties for the button the link is pointing to

 

http://www.mysite.com/index.php?products_i...;action=buy_now

 

I even copied the way they are used in my feaure set and they still don't add to cart.

 

<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products_array[$i]['id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>');

 

So I am out of ideas to try. On my product info pages the add to cart has no link like when you mouse over you can see the link in the bottom left. Those don't have any and these do. Not sure if it has something to do with the path or a setting somewhere for the default file path etc. Just grabbing straws now though. So I am open to suggestions or ideas.

 

 

-Thanks

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Posted

is there anything else in application_top.php that will block the index.php script?

Archived

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

×
×
  • Create New...