Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    17
    Plugin Contributions
    0

    Default Changing Add to Cart Function

    I'm trying to change the function of the add to cart button so that rather than literally adding the number in the quantity box on the product page to the number of that product already in the cart, it overwrites this quantity. to understand why i want to do this you can check out the way i reworked my products page here:

    http://www.sphotos.biz/store/index.p...th=1_2_3_59_60

    Basically i had a bunch of pictures to sell with a bunch of different sizes available so i made the image name the category and added all the sizes as products under that category. Anyways, I want make it so when a user returns to the "product" page (usually from clicking the image in the shopping cart) the quantity boxes are filled with the number of items already in the cart and hitting the add to cart button overwrites the values in the cart.

    Thanks!

  2. #2
    Join Date
    Jun 2006
    Posts
    17
    Plugin Contributions
    0

    Default Re: Changing Add to Cart Function

    I finally had a chance to take a look at this myself. I'm looking specifically at the function that controlls adding multiple products to cart (since i altered my category listing page). To do this open shopping_cart.php in the includes\classes folder, then look for:

    Code:
    function actionMultipleAddProduct($goto, $parameters) {
    Change the function so it reads as follows:

    Code:
      function actionMultipleAddProduct($goto, $parameters) {
        global $messageStack;
        while ( list( $key, $val ) = each($_POST['products_id']) ) {
          if ($val > 0) {
            $prodId = $key;
            $qty = $val;
            $add_max = zen_get_products_quantity_order_max($prodId);
            //$cart_qty = $this->in_cart_mixed($prodId);
            $new_qty = $qty;
            if (($add_max == 1 and $cart_qty == 1)) {
              // do not add
              $adjust_max= 'true';
            } else {
              // adjust quantity if needed
              if (($new_qty > $add_max) and $add_max != 0) {
                $adjust_max= 'true';
                $new_qty = $add_max;
              }
              $this->add_cart($prodId, ($new_qty));
            }
            if ($adjust_max == 'true') {
              $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' - ' . zen_get_products_name($prodId), 'caution');
            }
          }
        }
        zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
      }
    I'm now working on making the input boxes display the current cart quantity but that shouldn't be as difficult to track down.

 

 

Similar Threads

  1. Add to Cart function changed to contact us
    By pippa_oz in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 11 Nov 2010, 01:36 AM
  2. Product Price/Add to cart function
    By rwslippey in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 25 Feb 2010, 01:17 AM
  3. disable add to cart function
    By mizz_s in forum General Questions
    Replies: 5
    Last Post: 2 Jun 2007, 03:26 AM
  4. no add to cart function
    By bean_2k1 in forum Basic Configuration
    Replies: 6
    Last Post: 13 Apr 2007, 09:28 AM
  5. Add to Cart function
    By devdude51 in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 23 Jan 2007, 06:45 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