Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / How do I replace the Buy Now button with an Add to Cart button?

How do I replace the Buy Now button with an Add to Cart button?

Locked

Views: 2,844

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
17 Feb 2010, 7:19 AM
#1
orcasoul avatar

orcasoul

Zen Follower

Join Date:
Jan 2010
Posts:
133
Plugin Contributions:
0

How do I replace the Buy Now button with an Add to Cart button?

In the page created by the product entries I made in the Admin/Catalog/Categories / Products section, I see all of the entries, price & info.

I also see a "Buy Now" button - I want an "Add to my Cart" button.

After some searching, I found the following code in the "product_listing.php" file:
(line 180 - 185)

// qty box with add to cart button
            if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
              $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
            } else {
              $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
            }

If I comment out the '$lc_button = '<a href="' line (184), the button disappears.

This appears to depend on the value of PRODUCT_LIST_PRICE_BUY_NOW - but I can find no code or panel in Admin where that switch is set...

Of course, I could simply replace the "buy now" code with the "Add to my cart" code in line 182...but I'd really like a cleaner solution.

Any suggestions?

18 Feb 2010, 3:21 AM
#2
pdxdoug avatar

pdxdoug

Zen Follower

Join Date:
Jan 2008
Location:
Portland, Oregon USA
Posts:
356
Plugin Contributions:
0

Re: How do I replace the Buy Now button with an Add to Cart button?

Are you just trying to replace the graphic button with one that reads Add to my cart?

If so, look under includes/templates/templates_default/buttons/english for the file button_buy_now.gif and replace that file with a graphic of your choosing, naming it button_buy_now.gif and leave all the code intact.

18 Feb 2010, 3:35 AM
#3
orcasoul avatar

orcasoul

Zen Follower

Join Date:
Jan 2010
Posts:
133
Plugin Contributions:
0

Re: How do I replace the Buy Now button with an Add to Cart button?

pdxdoug:

Are you just trying to replace the graphic button with one that reads Add to my cart?

If so, look under includes/templates/templates_default/buttons/english for the file button_buy_now.gif and replace that file with a graphic of your choosing, naming it button_buy_now.gif and leave all the code intact.

OK, thanks for the response. I'm assuming that's a typo (you suggested replacing 'button_buy_now.gif' with 'button_buy_now.gif') and you probably meant 'button_add_to_cart'...but won't the code still lead the user to the Buy Now cart? From the code I looked at, which has an if/else to set the image, there should be somewhere to make the condition be TRUE - which will engage the add to cart code. That's what I can't seem to find, the attribute I need to switch somewhere to make it TRUE. I can switch the code and it works...but I'd prefer a less brute-force method.

18 Feb 2010, 2:43 PM
#4
tshooters avatar

tshooters

Totally Zenned

Join Date:
Dec 2005
Posts:
1,037
Plugin Contributions:
2

Re: How do I replace the Buy Now button with an Add to Cart button?

Look in Admin/Configuration/All Listing. What setting do you have for Display Product Buy Now Button? 0 = off

18 Feb 2010, 7:29 PM
#5
orcasoul avatar

orcasoul

Zen Follower

Join Date:
Jan 2010
Posts:
133
Plugin Contributions:
0

Re: How do I replace the Buy Now button with an Add to Cart button?

TShooters:

Look in Admin/Configuration/All Listing. What setting do you have for Display Product Buy Now Button? 0 = off

That's correct, it is set to zero.

19 Feb 2010, 4:00 AM
#6
pdxdoug avatar

pdxdoug

Zen Follower

Join Date:
Jan 2008
Location:
Portland, Oregon USA
Posts:
356
Plugin Contributions:
0

Re: How do I replace the Buy Now button with an Add to Cart button?

Looking in the EZ Start Zen Cart Book, changes are made in the admin/configuration/product listing.

There are several references to button settings in that section. Have you tried various settings to see if any of them have an effect?

There is a setting:
Display Product Add to Cart Button (0=off; 1=on;2=on with Qty Box per Product)

What is it set for?

19 Feb 2010, 4:08 AM
#7
orcasoul avatar

orcasoul

Zen Follower

Join Date:
Jan 2010
Posts:
133
Plugin Contributions:
0

Re: How do I replace the Buy Now button with an Add to Cart button?

pdxdoug:

Looking in the EZ Start Zen Cart Book, changes are made in the admin/configuration/product listing.

There are several references to button settings in that section. Have you tried various settings to see if any of them have an effect?

There is a setting:
Display Product Add to Cart Button (0=off; 1=on;2=on with Qty Box per Product)

What is it set for?

Display Product Add to Cart Button is set to 1.

I've checked every item in the Admin settings that I thought might have some influence, none seemed to change anything - I still get the Buy Now button.

19 Feb 2010, 4:21 AM
#8
kim avatar

kim

Obaa-san

Join Date:
Jun 2003
Posts:
26,591
Plugin Contributions:
0

Re: How do I replace the Buy Now button with an Add to Cart button?

OK, thanks for the response. I'm assuming that's a typo (you suggested replacing 'button_buy_now.gif' with 'button_buy_now.gif') and you probably meant 'button_add_to_cart'...but won't the code still lead the user to the Buy Now cart?

There is no difference in the buy now and add to cart processes - if you want the button to say add to cart - just replace the image.

19 Feb 2010, 4:32 AM
#9
orcasoul avatar

orcasoul

Zen Follower

Join Date:
Jan 2010
Posts:
133
Plugin Contributions:
0

Re: How do I replace the Buy Now button with an Add to Cart button?

Kim:

There is no difference in the buy now and add to cart processes - if you want the button to say add to cart - just replace the image.

Hmmm...OK, I swapped the two lines of core out, and that is what happened...interesting.

Thanks, I'll just use the line of code that gives me the "add to cart". I'd still like to figure out what settings control that if...else block - but this will work just fine.

19 Feb 2010, 4:36 AM
#10
gjh42 avatar

gjh42

Black Belt

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

Re: How do I replace the Buy Now button with an Add to Cart button?

"I'm assuming that's a typo (you suggested replacing 'button_buy_now.gif' with 'button_buy_now.gif') and you probably meant 'button_add_to_cart'"

No typo - as Kim and pdxdoug said, replace the button image, but keep it the same filename so the code will still find it without having to edit the PHP file.