Results 1 to 3 of 3
  1. #1

    Default Easy PHP Question (for someone :( )

    Hello

    I am trying to insert an extra action on the add to cart button on a product page. I have the javascript i need but i cannot for the life of me add the "onclick" statement to the "input" fuction in tpl_product_info_display.php.

    This is the Current HTML output into the browser
    Code:
    <div id="cartAdd">
        <p>Quantity in Cart: 1</p>Add to Cart: <input type="text" name="cart_quantity" value="1" maxlength="6" size="4" /><br /><br /><input type="hidden" name="products_id" value="383" /><input type="image" src="includes/templates/toyshop/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " />          </div>
      <!--eof Add to Cart Box-->
    I would like it to be the following (onclick="javascript:toggleLayer('errorCaution'); return upload_progress();) in bold as shown below.
    Code:
    <div id="cartAdd">
        <p>Quantity in Cart: 1</p>Add to Cart: <input type="text" name="cart_quantity" value="1" maxlength="6" size="4" /><br /><br /><input type="hidden" name="products_id" value="383" /><input type="image" src="includes/templates/toyshop/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " onclick="javascript:toggleLayer('errorCaution'); return upload_progress();" />          </div>
      <!--eof Add to Cart Box-->
    This is the current snippet of PHP code in tpl_product_info_display.php:
    Code:
               <?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>
    I know i need to add the "onclick" statement after (BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) but i've been trying all day and im bashing my head against the wall now!.

    Please can someone have a look, i'm sure this is straightforward for someone!

    Regards

    Tracey

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Easy PHP Question (for someone :( )

    You might try it in both places, like this:
    Code:
               <?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, 'onclick="javascript:toggleLayer(\'errorCaution\'); return upload_progress();"');
                } 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, 'onclick="javascript:toggleLayer(\'errorCaution\'); return upload_progress();"');
    			}
        $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>
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3

    Default Re: Easy PHP Question (for someone :( )

    Thankyou very much,that works a treat!!

    All the Best!

 

 

Similar Threads

  1. Easy Question for someone good at PHP
    By timhersh in forum General Questions
    Replies: 4
    Last Post: 27 Apr 2011, 06:14 PM
  2. Advice needed for daily product import (Easy Populate, PHP + MySQL or ??)
    By yourguide in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 19 Aug 2010, 01:22 AM
  3. How to include define_page_2.php content in header for easy editing
    By vandiermen in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 30 May 2009, 07:56 PM
  4. Easy question, someone must know
    By ebaobao in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 9 Aug 2008, 02:51 AM
  5. Easy PHP syntax question -- help please?
    By magicpants in forum General Questions
    Replies: 2
    Last Post: 17 Jan 2007, 02:31 PM

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