Results 1 to 10 of 12

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    121
    Plugin Contributions
    0

    Default Which file contains the code for "Add to cart"?

    Just a quick one.

    I have a main attribute which chooses which sub-attribute to display via JQuery. But since both sub-attributes are drop downs, they still get submitted on their default option.

    I am struggling to find the file which processes the "Add to cart" information to ignore one or the other attribute based on the main attribute.

    Thanks.

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,877
    Plugin Contributions
    96

    Default Re: Which file contains the code for "Add to cart"?

    Based on your description, it sounds like you'll want to add a file to the /extra_cart_actions folder, taking "action" when $_GET['action'] is set to 'add_product'.

    You can then interrogate the $_POST['id'] array (that contains the attributes) and take action based on your attribute hierarchy, removing any extraneous attribute values.

  3. #3
    Join Date
    Aug 2011
    Posts
    121
    Plugin Contributions
    0

    Default Re: Which file contains the code for "Add to cart"?

    So this will run before any other code is ran? And I'll remove the attrubite information, then the usual "add to cart" option deals with the rest? (with attribute removed). Is this right?

  4. #4
    Join Date
    Aug 2011
    Posts
    121
    Plugin Contributions
    0

    Default Re: Which file contains the code for "Add to cart"?

    Ok, so I have tested this, but can't seem to get any data about the attributes.

    Code:
    <?php
    if (($_GET['action'] == 'add_product')) {
    echo("<table>");
     foreach ($_POST as $key => $value) {
            echo "<tr>";
            echo "<td>";
            echo $key;
            echo "</td>";
            echo "<td>";
            echo $value;
            echo "</td>";
            echo "</tr>";
        }
    	echo("</table>");
    	die("");
    	}
    ?>
    displays:

    securityToken f5b7fcaa0fa568ffc53f504d7233f123
    id Array
    cart_quantity 1
    products_id 44

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,877
    Plugin Contributions
    96

    Default Re: Which file contains the code for "Add to cart"?

    What you said in post#3 is correct; this code will run before the "other" add-to-cart processing.

    The $_POST['id'] value is (as printed out) an array; you'll need to cycle through them. One hint, you can initially simply dump the contents of the $_POST variables so you can see what you're dealing with:
    Code:
    error_log (__FILE__ . ': POST variables: ' . print_r ($_POST, true));
    That will create a myDEBUG*.log file (in your /logs directory) that has the variable dump.

  6. #6
    Join Date
    Aug 2011
    Posts
    121
    Plugin Contributions
    0

    Default Re: Which file contains the code for "Add to cart"?

    Yep managed to do the same with var_dump($_POST['id']); so now I can see the values.

    I can then pull the value. but unsure how to modify the value? Although thats more PHP related and I'm sure google has the answer.

    Many thanks for your help.

 

 

Similar Threads

  1. v151 Display "add to cart" and "Call for price together"
    By Tadj Hemingway in forum General Questions
    Replies: 2
    Last Post: 6 Mar 2015, 07:53 PM
  2. Replies: 0
    Last Post: 17 Mar 2010, 05:24 PM
  3. Which file to reupload for "I am able to write to..." error
    By jwebster in forum General Questions
    Replies: 2
    Last Post: 6 Mar 2010, 06:12 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