Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2013
    Posts
    5
    Plugin Contributions
    0

    Default edit shopping cart class

    Hi guys, i'm new here..

    i'm doing some mods to a zencart site and i need some help..

    i'm trying to let user add a product in the cart in a new row when that product is also in the cart..
    normally zencart updates the quantity (if the product is the same and the attributes too) but i need to show a different row in the cart for every time user click on the "add to cart" button..

    in includes/classes/shopping_cart.php there is a function "add_cart" that checks if the product is also in the cart:

    if ($this->in_cart($products_id)) {
    $this->update_quantity($products_id, $qty, $attributes);
    } else {
    //add the product
    }

    i tryed editing the code like that but nothing:

    //alway execute the code to add product (no qty update)
    if (false /*$this->in_cart($products_id)*/) {
    $this->update_quantity($products_id, $qty, $attributes);
    } else {
    //add the product
    }

    do you know how to do what i need?

    p.s. sorry if this isn't the right place for this thread
    Last edited by lilfo; 6 Mar 2013 at 09:02 PM.

  2. #2
    Join Date
    Mar 2013
    Posts
    5
    Plugin Contributions
    0

    Default Re: edit shopping cart class

    ok i found this code in the actionaddproduct function (shopping cart class):

    $this->add_cart($_POST['products_id'], $this->get_quantity(zen_get_uprid($_POST['products_id'], $real_ids))+($new_qty), $real_ids);

    edited as

    $this->add_cart($_POST['products_id'], $new_qty, $real_ids);

    so now, every time i press on add to cart i add the product with the quantity i typed in the qty box..

    now the problem is in $_SESSSION['cart']:

    shoppingCart Object ( [contents] => Array ( [12] => Array ( [qty] => 1 ) ) [total] => 49 [weight] => 10 [cartID] => 04541 [content_type] => [free_shipping_item] => 0 [free_shipping_weight] => 0 [free_shipping_price] => 0 )

    i can't have two rows in an array with the same key, so with my edited code i can't insert the new product in the cart..

    if i add some letters in the key (so changing the product id) i think i can have problem.. i will not only if zencart uses intval function when read the product id (but i don't think so..)

    any idea on how to solve it?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: edit shopping cart class

    Quote Originally Posted by lilfo View Post
    i'm trying to let user add a product in the cart in a new row when that product is also in the cart..
    Can you please explain the business problem you're trying to solve here?
    If you explain why you're trying to do that, perhaps the solution might be simpler than you think. But without knowing the bigger picture it's hard to give the right answer.
    .

    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.

  4. #4
    Join Date
    Mar 2013
    Posts
    5
    Plugin Contributions
    0

    Default Re: edit shopping cart class

    Quote Originally Posted by DrByte View Post
    Can you please explain the business problem you're trying to solve here?
    If you explain why you're trying to do that, perhaps the solution might be simpler than you think. But without knowing the bigger picture it's hard to give the right answer.
    thank you anyway drbyte, i just solved adding an hidden text option to all products filled with an increasing number :)

 

 

Similar Threads

  1. Replies: 1
    Last Post: 22 Dec 2014, 08:55 PM
  2. Need help with Shopping Cart Class
    By foreverdita in forum General Questions
    Replies: 0
    Last Post: 26 Nov 2010, 04:52 PM
  3. Edit shopping cart attributes on the cart page
    By acorncom in forum General Questions
    Replies: 0
    Last Post: 13 May 2009, 10:12 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