Forums / Basic Configuration / Adding "add to cart" button to featured products

Adding "add to cart" button to featured products

Started by sheehan on 15 Aug 2007, 1:50 AM · Views: 8,167

Results 1 to 13 of 13
15 Aug 2007, 1:50 AM
#1
sheehan avatar

sheehan

New Zenner

Join Date:
Jun 2007
Posts:
34
Plugin Contributions:
0

Adding "add to cart" button to featured products

I am currently working on a client website (http://www.volumewireless.com/) and I attempted add an "add to cart" button to the featured products on the home page to no avail. The featured products on home page are driven by the featured products module.

You can see that I have modified it slightly already but i cannot seem to get the add to cart code from the product page to work, have any of you attempted this before?

15 Aug 2007, 3:56 PM
#2
sheehan avatar

sheehan

New Zenner

Join Date:
Jun 2007
Posts:
34
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

nm I found a work around.

15 Aug 2007, 4:19 PM
#4
sheehan avatar

sheehan

New Zenner

Join Date:
Jun 2007
Posts:
34
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

In the "includes/modules/featured_products.php" file around line 55 there is an array called 'text' within it I added:

. '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . '<img src="my image link" />' . '</a>'

15 Aug 2007, 4:23 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding "add to cart" button to featured products

Thanks for sharing! That will undoubtedly make some people's lives a lot easier. Tweaking the code above for a particular installation is peanuts compared to figuring out where and what to change...

4 Dec 2008, 3:21 PM
#6
eljay avatar

eljay

New Zenner

Join Date:
Nov 2008
Posts:
9
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

Sheehan:

In the "includes/modules/featured_products.php" file around line 55 there is an array called 'text' within it I added:

. '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . '<img src="my image link" />' . '</a>'

Thanks. This tipped help me as well!

28 Dec 2008, 6:40 PM
#7
mlguenther avatar

mlguenther

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

Any chance you can be a little more specific on the location that this code should be entered.

I found the array, but my limited PHP knowledge is keeping me from finding the spot to place it.

Thanks for your help!

28 Dec 2008, 7:01 PM
#8
mlguenther avatar

mlguenther

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

Got it,

My array was on line 65 "text"

I put it at the very end of the array before the final > ) ;

Also, remember to change the image source in the code.

Thanks!

28 Dec 2008, 7:08 PM
#9
mlguenther avatar

mlguenther

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

If anyone knows how to do it.

I would like to put a quantity box and an "add to cart" button there instead of "buy now" to make that completely seemless.

Anyone?

www.studioanello.com

28 Dec 2008, 7:47 PM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding "add to cart" button to featured products

That is a considerable chunk of code, and could not just be dropped into the line as shown above. Look in /includes/templates/template_default/templates/tpl_product_info_display.php to find the section that builds the price/add. It incrementally puts together bits of code; you can probably transfer the section to a point above the "text" line, accumulating the output in a variable like
$add_code .= ...
and then insert
. $add_code
in the text output.

A caution: the code in tpl_product_info_display.php may depend on some variables being loaded with current database query info, and may not work properly in another file. If that is the case, you will have to get that info from the database, which is a whole other subject.

24 May 2011, 12:31 PM
#11
kristian avatar

kristian

New Zenner

Join Date:
Nov 2007
Posts:
24
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

Does anyone know how to make the Buy it Now button show up in the Featured products sidebox? The trick above works fine, but I want the button visible on the front page as well as on the featured products page. Here is my link: http://xn--godpbunn-d0a.no/

Thanks,

Kristian

24 May 2011, 7:34 PM
#12
kristian avatar

kristian

New Zenner

Join Date:
Nov 2007
Posts:
24
Plugin Contributions:
0

Re: Adding "add to cart" button to featured products

Oh, and it doesn´t necessarily have to be the Featured products, like this: http://livedemo00.template-help.com/zencart_33586/index.php It could be the specials, like this one (which also has it on the featured products): http://www.templatemonster.com/demo/33534.html
I just want one or two products in a sidebox with the Buy it Now button and to choose which ones...

Any help appreciated :smile:

Kristian