Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Getting but now button to show up and function in sidebox

Getting but now button to show up and function in sidebox

Locked

Views: 1,168

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
29 Aug 2008, 10:38 PM
#1
ctcentralinfo avatar

ctcentralinfo

Totally Zenned

Join Date:
Apr 2005
Posts:
853
Plugin Contributions:
0

Getting but now button to show up and function in sidebox

Greetings folks,
I created a add to cart button in my specials sidebox on the the right right under best sellers sidebox.

My site: https://www.cooltechcentral.com

I can't get it to function, I was wondering if someone could help with getting the button to work better yet getting the buy it now button to show up and work instead.

Rich People scream, Wealthy people whisper

https://www.cooltechcentral.com

30 Aug 2008, 6:39 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Getting but now button to show up and function in sidebox

This is some code that was for Featured Products to get buttons or add to cart with quantity box ... and had the built in safety to attributes to be more info ...

    if (zen_has_product_attributes($featured_products->fields['products_id'])) {
      // show a more link for attributes
      $lc_button = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
      $lc_button2 = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
    } else {
      // show an add to cart choose one or the other
      $lc_button = '<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']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
      $lc_button2= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($featured_products->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $featured_products->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($featured_products->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $featured_products->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
    }

echo $lc_button or echo $lc_button2 will show the results once you have the variables and such set for the specials ...

See if any of that helps get you on the right track ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Aug 2008, 7:19 PM
#3
ctcentralinfo avatar

ctcentralinfo

Totally Zenned

Join Date:
Apr 2005
Posts:
853
Plugin Contributions:
0

Re: Getting but now button to show up and function in sidebox

Rich People scream, Wealthy people whisper

https://www.cooltechcentral.com

30 Aug 2008, 7:59 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Getting but now button to show up and function in sidebox

You need to look in the immediate code that you are in and see how the variables/arrays are referenced ...

If the products_id is often $products_id ... you might need:
$featured_products->fields['products_id']

as in the example I gave ...

But, you are in specials ... so it probably will be different ...

Code examples just need a little bit of adapting for use in other places or other files ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Aug 2008, 11:08 PM
#5
ctcentralinfo avatar

ctcentralinfo

Totally Zenned

Join Date:
Apr 2005
Posts:
853
Plugin Contributions:
0

Re: Getting but now button to show up and function in sidebox

I am not sure what you mean, This is what I did:

$content .= '<div>' . $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</div>';

I am not sure what you mean.

Rich People scream, Wealthy people whisper

https://www.cooltechcentral.com

30 Aug 2008, 11:20 PM
#6
gjh42 avatar

gjh42

Black Belt

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

Re: Getting but now button to show up and function in sidebox

$content .= '<div>' . $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</div>';

For starters, pasting the whole $lc_button = ... statement into the middle of the $content assembly won't work.
You need to let $lc_button be built and then add it to the $content.

$lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"')
$content .= '<div>' . $lc_button . '</div>';

Actually, you probably want the whole snippet posted by Ajeh above, followed by

$content .= '<div>' . $lc_button . '</div>';

and you might need to alter some of the code as she described.

31 Aug 2008, 12:54 AM
#7
ctcentralinfo avatar

ctcentralinfo

Totally Zenned

Join Date:
Apr 2005
Posts:
853
Plugin Contributions:
0

Re: Getting but now button to show up and function in sidebox

I tried using both lines of code:

$content .= '<div>' . $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</div>';

$content .= '<div>' . $lc_button2= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($specials_products->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $specials_products->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($specials_products->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $specials_products->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</div>';

but I get the same error message

Rich People scream, Wealthy people whisper

https://www.cooltechcentral.com

31 Aug 2008, 3:57 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Getting but now button to show up and function in sidebox

Try this and stick $lc_button where you want the buy now button to appear:

    if (zen_has_product_attributes($random_specials_sidebox_product->fields['products_id'])) {
      // show a more link for attributes
      $lc_button = '<a href="' . zen_href_link(zen_get_info_page($random_specials_sidebox_product->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($random_specials_sidebox_product->fields['master_categories_id']) . '&products_id=' . $random_specials_sidebox_product->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
    } else {
      // show an add to cart choose one or the other
      $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $random_specials_sidebox_product->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
    }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

31 Aug 2008, 5:08 AM
#9
ctcentralinfo avatar

ctcentralinfo

Totally Zenned

Join Date:
Apr 2005
Posts:
853
Plugin Contributions:
0

Re: Getting but now button to show up and function in sidebox

That did the trick, thanks.

Rich People scream, Wealthy people whisper

https://www.cooltechcentral.com

31 Aug 2008, 3:32 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Getting but now button to show up and function in sidebox

Thanks for the update ...

I thought the original code I posted could help you peice together the parts you needed, but it can get a little confusing at first ...

Glad that you have it working now ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!