Zen Cart Logo
Forums / Basic Configuration / Changing the Add to cart button

Changing the Add to cart button

Views: 25,809

Results 21 to 39 of 39
14 Apr 2010, 8:30 AM
#21
supra avatar

supra

New Zenner

Join Date:
Jun 2009
Posts:
5
Plugin Contributions:
0

Changing the Add to cart button

Found it.

Open
/public_html/YOURSTORE/includes/templates/YOUR TEMPLATE OVERIDES/templates/tpl_product_info_display.php

Changing text in RED to the path to your template file.

I copied the whole section of add to cart code from

<!--bof Add to Cart Box -->

to

<!--eof Add to Cart Box-->

and pasted it between

<!--eof Category Icon -->

Paste here (as shown in RED below)

<br clear="all" /> <!--bof Main Product Image -->

And I now have two Add to Cart buttons, with this mod there will be one at the top of the page. If you only wanted one, the original code could be removed.


<!--bof Category Icon --> <?php if ($module_show_categories != 0) {?> <?php /** * display the category icons */ require($template->get_template_dir('/tpl_modules_category_icon_display.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_icon_display.php'); ?> <?php } ?> <!--eof Category Icon -->

<!--bof Add to Cart Box -->

<?php if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') { // do nothing } else { ?>
        <?php
$display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
        if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
          // hide the quantity box and default to 1
          $the_button = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
        } else {
          // show the quantity box
$the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
        }
$display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);

?>

<?php if ($display_qty != '' or $display_button != '') { ?>
<div id="cartAdd">
<?php
  echo $display_qty;
  echo $display_button;
        ?>
      </div>
<?php } // display qty and button ?> <?php } // CUSTOMERS_APPROVAL == 3 ?> <!--eof Add to Cart Box--> <br clear="all" /> <!--bof Main Product Image --> <?php if (zen_not_null($products_image)) { ?> <?php /** * display the main product image */ require($template->get_template_dir('/tpl_modules_main_product_jquery_image.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_main_product_jquery_image.php'); ?> <?php } ?> <!--eof Main Product Image-->

Hope this helps :smile:

16 Jun 2010, 6:23 AM
#22
dimsumgurl avatar

dimsumgurl

Zen Follower

Join Date:
Dec 2009
Location:
Canada
Posts:
160
Plugin Contributions:
0

Re: Changing the Add to cart button

This REALLY helped me! THANK YOU! :)

20 Jun 2010, 6:18 PM
#23
sharni avatar

sharni

New Zenner

Join Date:
Aug 2008
Posts:
38
Plugin Contributions:
0

Re: Changing the Add to cart button

I have made it so that I have 2 Add to Cart buttons, which I want in most instances on my site. Alot of the time my products have alot of attributes and I wanted the customer to be able to add to cart at the top of them and below them.

ie:

See here.
http://www.nappyshoppe.com/store/happy-heiny-one-size-pocket-diaper-p-187.html

However, there are some situations where I only want one add to cart button. When there are no attributes. I am not sure how to write the code to check for if there are attributes, only show the top add to cart box and hide the bottom one.

Like here.
http://www.nappyshoppe.com/store/flip-reusable-stay-dry-inserts-p-645.html

Thanks in advance for any help.

Sharni

20 Jun 2010, 9:14 PM
#24
ajeh avatar

ajeh

Oba-san

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

Re: Changing the Add to cart button

You could check to see if the product has attributes with a function in the functions_lookups.php for:

/*
 *  Check if product has attributes values
 */
  function zen_has_product_attributes_values($products_id) {
26 Aug 2010, 12:24 AM
#25
sunshinepro avatar

sunshinepro

New Zenner

Join Date:
Aug 2010
Posts:
32
Plugin Contributions:
0

Re: Changing the Add to cart button

Ok So I'm Having some trouble with this. I'm trying to make it where my pictures are on top of the description along with the add button and product details no matter what I do it is not working. I'm using a pure green template. I have set the <br> codes to remove and it is still not working? Some one please help. Thank You.

25 Mar 2011, 10:03 PM
#26
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: Changing the Add to cart button

Ajeh:

You could check to see if the product has attributes with a function in the functions_lookups.php for:

/*

  • Check if product has attributes values
    */
    function zen_has_product_attributes_values($products_id) {



How would you implement using this code.  

Do you use the line you quoted, or all of the function as follows:

/*
 *  Check if product has attributes values
 */
  function zen_has_product_attributes_values($products_id) {
    global $db;
    $attributes_query = "select sum(options_values_price) as total
                         from " . TABLE_PRODUCTS_ATTRIBUTES . "
                         where products_id = '" . (int)$products_id . "'";

    $attributes = $db->Execute($attributes_query);

    if ($attributes->fields['total'] != 0) {
      return true;
    } else {
      return false;
    }
  }


I have my add to cart button located in tpl_modules_attributes.php in order to get the look I wanted.  I now have some products that do not have any attributes so tpl_modules_attributes.php is not being called and therefore neither is my add to cart.  

Therefore if I could check for attributes and then call the add to cart only when attributes are not present (in the file tpl_shopping_cart_default.php) it would be very helpful.

All attempts of inserting your code breaks the cart, could you provide some advice?
Thank You
25 Mar 2011, 10:40 PM
#27
ajeh avatar

ajeh

Oba-san

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

Re: Changing the Add to cart button

Sorry, my bad ...

You could use:

if (zen_has_product_attributes($_GET['products_id'])) {
// show second button code
}
25 Mar 2011, 11:34 PM
#28
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: Changing the Add to cart button

I do not understand where to use this in the code, it renders the text exactly as you stated on the product page unless I wrap it with

<?php ?>

I tried this:

<php
if (zen_has_product_attributes($_GET['products_id'])) {
// show second button code
}

<!--bof Add to Cart Box --> <?php if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') { // do nothing } else { ?>
        <?php
$display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
        if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
          // hide the quantity box and default to 1
          $the_button = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
        } else {
          // show the quantity box
$the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
        }
$display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);

?>

<?php if ($display_qty != '' or $display_button != '') { ?>
<div id="cartAdd">
<?php
  echo $display_qty;
  echo $display_button;
        ?>
      </div>
<?php } // display qty and button ?> <?php } // CUSTOMERS_APPROVAL == 3 ?> <!--eof Add to Cart Box-->

?>

Then it shows the add to cart and ?>

Then it still shows on products that have attributes and products that do not have attributes. Could you clue me in on where I am going wrong?

Thanks

26 Mar 2011, 12:19 AM
#29
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: Changing the Add to cart button

oops, I added the question mark and moved the bracket to the bottom, but then I got a blank page?

26 Mar 2011, 12:29 AM
#30
ajeh avatar

ajeh

Oba-san

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

Re: Changing the Add to cart button

To make the Add to Cart code not show when there are attributes, take out that code and change the one line:

if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {

to read:

if (zen_has_product_attributes($_GET['products_id']) || CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {

and the Add to Cart button will not show ...

26 Mar 2011, 1:33 AM
#31
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: Changing the Add to cart button

I will have to install a fresh cart and try. If I use the one line you gave I get words on the page, If I use the entire add to cart code and replace the line I get the cart button with or without attributes.
I must have changed it somehow while customizing the cart, it has lots of modifications. I can't switch to default because it wants files for PWAS that are not installed on template default.
I appreciate your trying to help.

Thanks

26 Mar 2011, 7:58 PM
#32
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: Changing the Add to cart button

Ajeh:

To make the Add to Cart code not show when there are attributes, take out that code and change the one line:

if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {

> 
> to read:
> ```
if (zen_has_product_attributes($_GET['products_id']) || CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {

and the Add to Cart button will not show ...

Thanks for steering me in the right direction. I actually had to change your replacement code to ```
if ((zen_has_product_attributes($_GET['products_id'])) || (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '')) {

26 Mar 2011, 11:20 PM
#33
ajeh avatar

ajeh

Oba-san

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

Re: Changing the Add to cart button

Good catch ... thanks for the update that you have this working now ... :smile:

26 Apr 2011, 6:09 AM
#34
rtyfugkj avatar

rtyfugkj

New Zenner

Join Date:
Apr 2011
Posts:
3
Plugin Contributions:
0

Re: Changing the Add to cart button

misty:

For any other members looking to move add to cart button, details
can be found at
http://www.zen-cart.com/forum/showthread.php?t=34132&highlight=move+cart+button
:thumbsup:

YES, thats very usefull there is no message there
im getting this message:
rtyfugkj, you do not have permission to access this page. This could be due to one of several reasons:

  1. Your user account may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  2. If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Log Out Home

26 Apr 2011, 6:12 AM
#35
rtyfugkj avatar

rtyfugkj

New Zenner

Join Date:
Apr 2011
Posts:
3
Plugin Contributions:
0

Re: Changing the Add to cart button

misty:

For any other members looking to move add to cart button, details
can be found at
http://www.zen-cart.com/forum/showthread.php?t=34132&highlight=move+cart+button
:thumbsup:
Yes its true, other people would like to know how to move the ad to cart button. so why not post the info here? To help people? Im getting this stupid message:
vBulletin Message
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  1. You are not logged in. Fill in the form at the bottom of this page and try again.
  2. You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  3. If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Log in
User Name:
Password:
Forgotten Your Password? Remember Me?
The administrator may have required you to register before you can view this page.

24 Jul 2011, 12:45 PM
#36
ultrageoff avatar

ultrageoff

New Zenner

Join Date:
Dec 2010
Location:
Harrogate, North Yorkshire
Posts:
2
Plugin Contributions:
0

Re: Changing the Add to cart button

I get the same as rtyfugkj, and have done on some other occasions, despite seeming to have a User Name (which is auto entered, my familiar and usual username) and a Password. I'll try re-registering, but my impression is that there is some problem with the discussion boards' access. Still love the whole Zen cart thing though :smile:

8 Sep 2011, 8:40 PM
#37
stamper avatar

stamper

New Zenner

Join Date:
Mar 2008
Posts:
38
Plugin Contributions:
0

Re: Changing the Add to cart button

member:

Thanks for steering me in the right direction. I actually had to change your replacement code to ```
if ((zen_has_product_attributes($_GET['products_id'])) || (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '')) {


Hmm.  I tried this on a nifty zen template and it actually produced the opposite result.  i.e. I get 2 add to cart boxes with no attributes and the lower one disappears with attributes.
8 Sep 2011, 9:27 PM
#38
stamper avatar

stamper

New Zenner

Join Date:
Mar 2008
Posts:
38
Plugin Contributions:
0

Re: Changing the Add to cart button

Ajeh:

To make the Add to Cart code not show when there are attributes, take out that code and change the one line:

if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {

> 
> to read:
> ```
if (zen_has_product_attributes($_GET['products_id']) || CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {

and the Add to Cart button will not show ...

I re-quoted the originally posted code and message for clarity. In order to NOT display one of the two buttons in the absence of attributes (which I think was the gist of the original request) I believe the NOT operator is required like so:

if (!(zen_has_product_attributes($_GET['products_id'])) || CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {
13 Apr 2013, 12:33 AM
#39
dontblink7 avatar

dontblink7

New Zenner

Join Date:
Jan 2011
Posts:
53
Plugin Contributions:
0

Re: Changing the Add to cart button

im not sure if this is the right place to post but i couldn t find anything to help..
on my site the add to cart button is a icon and i want it to be a button, like a css button .. how do i change it ?