Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Edit 'Add to Cart' Button HTML

    Hi All,

    I would like to add the following onClick event to the add to cart button:

    [FONT=Courier New]onclick="return confirm('Alert message goes here')"

    [FONT=Arial]However I cannot seem to locate the file where the actual <a> tag is written. I believe the HTML is contained in this variable:[/FONT]

    [/FONT]$display_button;

    But using the Developers Tool Kit I was only able to locate instances where $display_button is printed, not where the variable is assigned. Can anyone point me in the right direction?

  2. #2
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Re: Edit 'Add to Cart' Button HTML

    Just to clarify the issue, what I REALLY would like to do is add a little PHP/JS to the <form> that handles adding a product to the cart. Something such as:

    [FONT=Verdana]
    PHP Code:
    print '<form ';
    $sql mysql_query("SELECT id,flag FROM products WHERE id='$id' && flag=1");
    if (
    mysql_num_rows($sql) == 1) print 'onsubmit="return confirm('Alert message goes here')">';
    else print 
    '>'
    Basically, if the flag field is set to 1, then I want the JS notice to be implemented, otherwise do nothing. The problem is, I don't know where to add this code! I can't seem to find where the form is created for the product page - can anyone assist?!?


    [/FONT]

  3. #3
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Re: Edit 'Add to Cart' Button HTML

    OK - I may have found it:

    includes/functions/html_output.php

    Now I've just got to customize it so that the onSubmit action ONLY occurs on the product page...

  4. #4
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Re: Edit 'Add to Cart' Button HTML

    Sorry if this is getting annoying, but I figured I would update you all as I go (kind of thinking out loud via the forum) - I added the following code to target only the product info page around line 359 of 'includes/functions/html_output.php':

    PHP Code:
        if (isset($_GET['main_page']) && $_GET['main_page'] == 'product_info')
        {
            
    $form .=  ' onSubmit="return confirm(\'Alert message goes here\')"';
        } 
    Now all I should need to do is add my additional IF to determine whether or not the message should be printed and Voila!

  5. #5
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Re: Edit 'Add to Cart' Button HTML

    In the words of Borat - SUCCESS!

    Here's the final code I added to 'includes\functions\html_output.php' to get the notice working for the products I want. I also modified the 'products' table to add a 'legalnotice' field which is a TINYINT:

    PHP Code:
        // Mod to add an 18+ notice to products when field 'legalnotice'=1
        
    if (isset($_GET['main_page']) && $_GET['main_page'] == 'product_info')
        {
            
    $pid $_GET['products_id'];
            
    $sql mysql_query("SELECT products_id,legalnotice FROM products WHERE products_id='$pid' && legalnotice=1") or die(mysql_error());
            if (
    mysql_num_rows($sql) == 1)
            {
                
    $form .=  ' onSubmit="return confirm(\'You MUST be over the age of 18 to purchase this product. By clicking the 'OK' button you are effectively verifying that meet or exceed the stated age requirement.\')"';
            }
        } 
    The last hurdle - adding the 'legalnotice' as an option on the 'Add Product' page so that my client can flag these products via the admin area! Expect another out-loud brainstorm in another thread... LOL

  6. #6
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Re: Edit 'Add to Cart' Button HTML

    Also - I do realize this code can probably be optimized and/or implemented in a more seamless manner, so if any of the mods/developers have tips on how to improve this functionality please feel free to critique my methods!

 

 

Similar Threads

  1. i want to edit action when click add to cart button
    By vetri in forum General Questions
    Replies: 2
    Last Post: 14 May 2015, 03:07 PM
  2. HTML for Add to cart button
    By Horrific_ending in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 13 Apr 2012, 12:44 AM
  3. Can I add a new button for Edit Cart.
    By glamourdolleyes in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 4 Apr 2012, 01:39 AM
  4. Edit Cart Mod - Update Cart Button Not Showing
    By ScriptJunkie in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 13 May 2011, 11:44 PM
  5. add button to launch html page
    By bettsaj in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 24 May 2009, 10:04 AM

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