Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2013
    Location
    California
    Posts
    22
    Plugin Contributions
    0

    help question force add items to create new item in shopping cart and not update the current qty.

    Can any one point me in the correct direction?
    The default way the shopping cart works is when you add an item to your shopping cart it just adds it. If you go back into the store and select the same item again it just updates the quantity in the shopping cart. This behavior is undesirable in my store as I have custom code that allows users to customize their items.

    When a user customizes their items it counts as a "new" item as far as pricing goes. But because this is the same item in the shopping cart - zen cart just updates the quantity. Therefor giving them a discount that the customer no longers should receive.

    I have tried editing the following.
    in includes/classes/shopping_cart.php
    changing
    Code:
    if ($this->in_cart($products_id)) {
    to
    Code:
    if (1 === 2) {
    This was an attempt to force this if statement to be false - theoretically forcing a new item in the cart. However, this just failed to add a new item and failed to update the quantity.
    I have also tried changing the line below it from
    Code:
      	$this->update_quantity($products_id, $qty, $attributes);
    to
    Code:
     add_cart($products_id, $qty, $attributes, $notify);
    But, this just fails as it causes a weird loop and wasn't very smart of me.

    I tried adding
    Code:
      	$this->contents[] = array($products_id);
    	      $this->contents[$products_id] = array('qty' => (float)$qty);
    	      // insert into database
    	      if (isset($_SESSION['customer_id'])) {
    	        $sql = "insert into " . TABLE_CUSTOMERS_BASKET . "
    	                              (customers_id, products_id, customers_basket_quantity,
    	                              customers_basket_date_added)
    	                              values ('" . (int)$_SESSION['customer_id'] . "', '" . zen_db_input($products_id) . "', '" .
    	        $qty . "', '" . date('Ymd') . "')";
    	
    	        $db->Execute($sql);
    in the "true" side of
    Code:
    if ($this->in_cart($products_id)) {
    But it just caused a white screen.

    Not really sure where to go =[

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: force add items to create new item in shopping cart and not update the current qt

    custom code that allows users to customize their items.
    Does this mean that you are not using attributes to do the customization? If you add a product with one set of attribute selection to the cart and then add it with a different set of attributes (even different text in one attribute), you will get two items in the cart. If you add the product again with the same attributes, you will get qty 2 of that item.

    Apparently your custom code does not tie into the attribute system.

    Seeing your setup and understanding how it operates will probably be necessary before we can help you.

  3. #3
    Join Date
    Aug 2013
    Location
    California
    Posts
    22
    Plugin Contributions
    0

    Default Re: force add items to create new item in shopping cart and not update the current qt

    Correct, it does not tie into the attributes system.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: force add items to create new item in shopping cart and not update the current qt

    So we can't help you without a lot more information on exactly what you are doing.

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: force add items to create new item in shopping cart and not update the current qt

    You refer to quantity discounts in a way that suggests that it is possible to have multiples of one item (and be treated specially), so it could not work to just force all items added to cart to create new entries. You have to distinguish between duplicates and customized versions of a product, the same way as attributes do. So how does your code do that?

 

 

Similar Threads

  1. v151 "Update Qty" button not working in shopping cart
    By inlayout in forum General Questions
    Replies: 4
    Last Post: 8 Jan 2013, 02:03 PM
  2. v150 Multiple Product and qty add in Shopping cart
    By jalpesh in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 30 Aug 2012, 12:07 PM
  3. Replies: 2
    Last Post: 22 May 2011, 05:13 PM
  4. Items in Shopping cart do not update
    By Karm4 in forum General Questions
    Replies: 4
    Last Post: 8 Mar 2010, 06:33 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