Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Adding a second 'add to cart' button nonly on bottom of product page

    I am trying to add a second 'add to cart' button at the bottom of my product page which is a button only without a quantity box and preceding text.
    I have found the file to edit; includes/template/MY_TEMPLATE/template/tpl_product_music_info_display.php (music product in this case). I can move or duplicate the button and text box, together, but have had no success at separating them.
    How can I add a second button to the bottom with the same function as the first? Thank you.

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,106
    Plugin Contributions
    11

    Default Re: Adding a second 'add to cart' button nonly on bottom of product page

    You might find a quick answer in the similar threads. Just scroll down till you get there. I find google search ending in Zen Cart is far better than trying to search through the forum.

  3. #3
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Re: Adding a second 'add to cart' button nonly on bottom of product page

    Thank you. I've searched the forum for similar problems/solutions, via this site and Google with no luck.
    Whenever I attempt to remove the qty box from the 'Add to Cart' code I throw an error.
    I currently have the qty box and button at the top and bottom of my product pages.
    Is there a way to remove the qty box out of the code only for the button at the bottom of the page?
    And use both buttons to submit the same quantity form at the top of the page?

    This is the 'Add to Cart' code which I have placed at the top and bottom of the product page in my tpl_product_music_info_display.php override:

    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-->
    There are settings in the admin that allow for the removal of the qty box (default 1), but that removes it from the entire page. I want to retain one qty form at the top which is submitted with either of the two buttons at the top or bottom (similar to the way multiple products/qty selection works in categories or subcategories).

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,622
    Plugin Contributions
    123

    Default Re: Adding a second 'add to cart' button nonly on bottom of product page

    For the second add to cart button, do NOT include a quantity box (or if you really want to, you'll need to write code to give it a different id and have javascript update the quantity in the real quantity box at the top of the page).

    Note that you'll also want to get rid of/change markup like this in the second button:

    Code:
        <div id="cartAdd">
    (You want each id to be unique.)
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  5. #5
    Join Date
    Dec 2007
    Location
    Payson, AZ
    Posts
    1,076
    Plugin Contributions
    15

    Default Re: Adding a second 'add to cart' button nonly on bottom of product page

    Quote Originally Posted by Joseph M View Post
    And use both buttons to submit the same quantity form at the top of the page?
    The one line that solves the riddle... Why posting tips really help..

    The button has to get generated on the fly, after all, you wouldn't want one button saying out of stock and the other add to cart.. Ether way, you will most likely confuse your customers with two buttons..

    But the following would need to stay within the product form.. If you place this below the closing form tag, it well fail!

    Code:
    <?php $the_button_two = zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
    
    $display_button_two = zen_get_buy_now_button($_GET['products_id'], $the_button_two);
    
     if ($display_button_two != '')   echo '<div id="cartAdd-two">' . $display_button_two . '</div>'; ?>
    This was not tested with every possible situation so test before going live.
    Dave
    Always forward thinking... Lost my mind!

  6. #6
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Re: Adding a second 'add to cart' button nonly on bottom of product page

    swguy,
    For the second add to cart button, do NOT include a quantity box
    That was the problem, I didn't know how to get rid of the second quantity box.


    Dave,

    Thank you. That was brilliant. The button works great. It submits the quantity from the form on the top, adds to the cart correctly, and displays 'out of stock' when the item is sold out. Adding one item with the top button places one in the cart. Adding two more by filling in the form and submitting with the bottom button adds two more and updates the cart total correctly. It works exactly as it should. Almost anywhere in tpl_product_info_display.php (or tpl_product_music_info_display.php in this case) will work since the </form> tag is at the end of the page. After that it was just a simple adjustment in the stylesheet.

 

 

Similar Threads

  1. v151 Need Help in adding a add to cart button on product info page
    By rmu065 in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 9 Apr 2013, 01:50 AM
  2. Adding a second buy button to the bottom of product pages.
    By towerhealth in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 11 Apr 2011, 03:14 PM
  3. Add extra "add to cart" button at bottom of product page
    By ct9a in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 12 Oct 2010, 09:19 PM
  4. Add to cart button multiple displays (top and bottom of page)
    By somedood in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 4 Oct 2009, 08:44 AM
  5. Put Add to Cart button at top and bottom of Prod. Page
    By kabbink in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 May 2008, 10:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR