Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

DOCS: Display 'More Info' or 'Buy Now' button


TerryK

Recommended Posts

ISSUE

=====

 

Customer expects the 'Buy Now' button to add an item to the shopping cart. However, if a product has attributes, the customer will instead be directed to the product_info.php page where options can be selected. This may confuse the customer.

 

 

SOLUTION

========

 

Where a product has attributes, have a 'More Info' button displayed instead of the 'Buy Now' button on both the category listings and New Products pages.

 

To do so, the following steps are required:

 

1. CREATE THE NEW BUTTON

 

Create a 'More Info' button and save it as /catalog/images/more_info.gif (or more_info.jpg, etc., depending on your button's image format).

 

NOTE: If your button is saved in JPG or other image format, you will need to change the image name in the instructions at Steps 3 and 4 below.

 

 

2. DEFINE BUTTON IN LANGUAGE FILE

 

Around line 252 of /catalog/includes/languages/english.php file, add the button definition. Look for:

 

define('IMAGE_BUTTON_BUY_NOW', 'Buy Now');

 

Replace with:

 

define('IMAGE_BUTTON_BUY_NOW', 'Buy Now');
define('IMAGE_BUTTON_MORE_INFO', 'More Info');

 

 

3. MODIFY PRODUCT LISTING PAGE

 

Around line 131 of /catalog/includes/modules/product_listing.php, look for:

 

          case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;
       }

 

Replace with:

 

    case 'PRODUCT_LIST_BUY_NOW':
         $lc_params = 'class="product" valign="top"';
         $lc_align = 'right';

$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_more_info.gif', IMAGE_BUTTON_MORE_INFO) . '</a> ';
           } else {
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
}
break;
}

 

 

4. MODIFY THE NEW PRODUCTS PAGE

 

Around line 90 of /catalog/products_new.php, look for:

 

            <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

 

Replace with:

 

            <td align="right" valign="middle" class="main"><?php
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $products_new['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
 $products_attributes = tep_db_fetch_array($products_attributes_query);

 if ($products_attributes['total'] > 0) {
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_more_info.gif', IMAGE_BUTTON_MORE_INFO) . '</a>';
         } else {
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
}
?></td>

 

Upload the image and modified pages to your server and the appropriate buttons should now be displayed.

 

HTH,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Terry,

 

I could not get your code to work on my test site.

 

Please setup an example of this on a test store and send the url.

 

Thanks.

Link to comment
Share on other sites

Correction: image should be called button_more_info.gif and uploaded to:

 

/catalog/includes/languages/english/images/buttons/

 

(Sorry 'bout that!)

 

 

With that change, the code for /catalog/products_new.php works. I just tested it with a stock version of the file and it displayed as it should. My version is available for viewing at:

 

http://www.kididdles.com/catalog/products_new.php

 

( I've only got one product with attributes, and it's about half way down the page where you'll see the 'More Info' button instead of 'Buy Now.' )

 

Since I'd made so many modifications to my product_listing.php page, I'm still testing the stock version of it. Will report back shortly...

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Terry,

 

Yes, this is a good idea also. I usually turn the "buy now" button off in the admin forcing the customer to click on the product link to get more information.

Link to comment
Share on other sites

Hi Melinda,

 

With the correction to the image name, I got the function working correctly on the product_listing.php page. Can you try it on your end once more and see if that fixed it?

 

My modified product_listing page where this is working can be found here:

 

http://www.kididdles.com/catalog/index.php?cPath=79

 

(Only one product in the category, but it's the only one I have so far that has attributes...)

 

Thanks,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 months later...
Hi Melinda,

 

With the correction to the image name, I got the function working correctly on the product_listing.php page. Can you try it on your end once more and see if that fixed it?

 

My modified product_listing page where this is working can be found here:

 

http://www.kididdles.com/catalog/index.php?cPath=79

 

(Only one product in the category, but it's the only one I have so far that has attributes...)

 

Thanks,

 

Terry

 

 

I tried making this change on my site, but I get a parse error after replacing the code as described. My product_listing.php and products_new.php do not look exactly as you describe.I don't think I know enough about PHP to know why it doesn't work. Can you help? Here is my product_listing.php:

 

<?php

/*

$Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 

if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>

<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>

</tr>

</table>

<br>

<?php

}

?>

 

 

 

<?php

 

////////////////////////////////////////////////////////////////////////////////

 

if ($listing_split->number_of_rows > 0)

{

 

/*$sort .= '<table border="0" width="100%" cellspacing="0" cellpadding="2">';

$sort .= ' <tr>';

$sort .= ' <td align="right" class="smallText">Sort By: ' . tep_create_sort_heading($HTTP_GET_VARS['sort'], '3', 'PRICE') . ' | ' . tep_create_sort_heading($HTTP_GET_VARS['sort'], '2', 'NAME') . '</td>';

$sort .= ' </tr>';

$sort .= '</table>';

$sort .= '<table border="0" cellpadding="0" cellspacing="0" width="100%">';

$sort .= ' <tr>';

$sort .= ' <td width=100% class="main" height="2" background="images/new/dot_horizontal.gif"></td>';

$sort .= ' </tr>';

$sort .= ' <tr>';

$sort .= ' <td><br></td>';

$sort .= ' </tr>';

$sort .= '</table>';

 

$list_box_contents[] = array('params' => 'class=""',

'text' => $sort); */

 

$rows = 0;

$listing_query = tep_db_query($listing_split->sql_query);

 

while ($listing = tep_db_fetch_array($listing_query))

{

$product = '';

$rows++;

 

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

$image_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

} else {

$image_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';

}

 

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

$name_text = '<a class="productHeading" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';

} else {

$name_text = '<a class="productHeading" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';

}

 

$description = substr($listing['products_description'], 0, 120) . '...';

 

if (tep_not_null($listing['specials_new_products_price'])) {

$price_text = '<span class="productPrice"><s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s></span>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';

} else {

$price_text = '<span class="productPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';

}

 

//$buy_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

$buy_text = tep_draw_hidden_field('products_id', $listing['products_id']) . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART);

 

$values = array('1','2','3','4','5','6','7','8','9');

 

$product .= tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'));

$product .= '<table border="0" cellpadding="0" cellspacing="0" width="100%">';

$product .= ' <tr>';

$product .= ' <td width="25%" align="center" valign="center"><table border="0" cellpadding="4" cellspacing="0" ><tr><td align="center" valign="center">' . $image_text . '</td></tr></table></td>';

$product .= ' <td>' . tep_draw_separator('pixel_trans.gif', '20', '20') . '</td>';

//$product .= ' <td width="2" height="100%" background="images/new/dot_vertical.gif">' . tep_draw_separator('pixel_trans.gif', '2', '2') . '</td>';

//$product .= ' <td>' . tep_draw_separator('pixel_trans.gif', '20', '20') . '</td>';

$product .= ' <td width="100%" valign="top">';

$product .= ' <table width="100%">';

$product .= ' <tr><td class="roundBoxContents" width="100%"><b>' . $name_text . '</b></td></tr>';

//$product .= ' <tr><td class="" height="2" background="images/new/dot_horizontal.gif"></td></tr>';

$product .= ' <tr><td class="roundBoxContents" width="100%"><b>Price: </b>' . $price_text . '</td></tr>';

$product .= ' <tr><td class="" height="2" background="images/new/dot_horizontal.gif"></td></tr>';

$product .= ' <tr><td class="roundBoxContents" width="100%">' . $description . '</td></tr>';

$product .= ' <tr><td class="" height="2" background="images/new/dot_horizontal.gif"></td></tr>';

$product .= ' <tr><td class="roundBoxContents" width="100%"><b>Quantity: ' . tep_draw_pull_down_menu("qty", $values) . '</b></td></tr>';

$product .= ' <tr><td class="" height="2" background="images/new/dot_horizontal.gif"></td></tr>';

$product .= ' <tr><td class="">' . tep_draw_separator('pixel_trans.gif', '100%', '1') . '</td></tr>';

$product .= ' <tr><td class="roundBoxContents" width="100%">' . $buy_text . '</td></tr>';

//$product .= ' <tr><td class="" height="2" background="images/new/dot_horizontal.gif"></td></tr>';

$product .= ' </table>';

$product .= ' </td>';

$product .= ' </tr>';

$product .= '</table>';

$product .= '</form>';

$product .= '<table border="0" cellpadding="0" cellspacing="0" width="100%">';

$product .= ' <tr>';

$product .= ' <td><br></td>';

$product .= ' </tr>';

//$product .= ' <tr>';

//$product .= ' <td width=100% class="main" height="2" background="images/new/dot_horizontal.gif"></td>';

//$product .= ' </tr>';

//$product .= ' <tr>';

//$product .= ' <td><br></td>';

//$product .= ' </tr>';

$product .= '</table>';

 

$list_box_contents[] = array('params' => 'class=""',

'text' => $product);

 

}

 

new roundBoxHeading();

new roundBox($list_box_contents);

new roundBoxFooter();

}

else

{

$list_box_contents = array();

$list_box_contents[] = array('text' => TEXT_NO_PRODUCTS);

new roundBoxHeading();

new roundBox($list_box_contents);

new roundBoxFooter();

}

 

if (($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')))

{

 

?>

 

<br>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>

<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>

</tr>

</table>

 

<?php

 

}

?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...