Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hi, I'm looking for a code snippet for the add to cart button


Guest

Recommended Posts

:lol:

 

Good morning m8's

 

I want to add an extra add to cart button on my product listing page.

 

Im having trouble selecting the right code. Once the button is clicked,

 

I'd like the product to show up in the shopping cart box.

 

Any knowledge on this subject would be greatly appreciated! :thumbsup:

 

 

Peace,

Azati

 

B)

Link to comment
Share on other sites

Ok here is the code that you want

 

<!-- Buy now Review -->
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table>
<!-- Buy now Review -->

at the end of the day the code will be good

Link to comment
Share on other sites

Ok now what do you have to do with this

 

1) this code is going to go in the product_info.php

2) I'm thinking that you want it just under the the product name and price so you are going to look for a part that looks like:

 

	<tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
		<td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>

<!-- this is added --> 
<!-- Buy now Review -->
<table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
		<td align="right" class="main"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
		</tr>
</table>
<!-- Buy now Review -->

 

and then you are going to add the code under this line

at the end of the day the code will be good

Link to comment
Share on other sites

Hi!

 

Thank you very much for ur time & reply.

 

I had to modify the 'code' some what to fit my product listing page here is the addie.

 

http://www.azatiracing.com/online-store/in.../cPath/21_24_69

 

The button shows up now which is great, :thumbsup:

however it not adding the products to the cart.

 

And now the 'code' is interfering with my Quantity in Basket 'code'

 

I'm posting my product_listing.php file N hopes a fresh set of eye's can spot the error..

 

 

The important code starts here -----------> echo'

 

Thanks in Advance I hope this helps others aswell :thumbsup:

 

<?php

// start of added code for category/subcategory names

function last() { $trail_size = sizeof($this->_trail); return

 

$this->_trail[$trail_size-1]['title']; }

// end of added code

 

/*

$Id: allprods.php,v4.3 2003/06/09 22:49:59 hpdl Exp $

All Products v3.0 MS 2.2 with Images http://www.oscommerce.com/community/contributions,1501

 

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>

 

<?php

}

?>

 

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

<tr>

<?php

$col = 0;

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

while ($listing = tep_db_fetch_array($listing_query)) {

$col++;

 

echo' <td align="left" width="3%" class="smallText"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '"></td><td align="left" valign="top" >' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br><br><br><br><hr width="100%"></td><td width="100%" valign="top" align="left"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">

<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part#: <strong>' . $listing['products_model'] .'</strong><br>Retail Price: <s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>

<br>Your Price: <strong><span class="productSpecialPrice">' . $currencies->display_price($listing['listing_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</strong></span><br><br><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Quantity in Basket: . $cart->count_contents();<br><br>

<table width="100%" height="20" border="0"><TD height="20"><div align="left"><a href="' . tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</div><TD width="50%" valign="middle"><div align="left"><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></div></TABLE><p><hr width="100%"><p>' . "\n";

 

if ((($row / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($row / MAX_DISPLAY_CATEGORIES_PER_ROW))) {

?>

 

</tr>

<tr><br>

<td><?php echo tep_draw_separator('pixel_trans.gif', '50%', '10'); ?></td>

</tr>

<tr>

<?php

}

}

?>

</tr>

</table>

 

<?php

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

?>

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

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<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...