Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22
  1. #11
    Join Date
    Oct 2007
    Location
    Cornwall/Amsterdam
    Posts
    61
    Plugin Contributions
    0

    Default Re: Duplicate products added to shopping cart

    Hi Dr Byte.

    I'm troubleshooting a live 1.5.6c store, so I've done what you said with 1.5.6c

    Fresh install, fresh database.

    Bare minimum adjustments. In admin, I set currency to GBP default & I also edited admin>config>Product Listing> Display Product Add to Cart Button (0=off; 1=on; 2=on with Qty Box per Product) to 1 to show the buy now buttons.

    Added two test products and replicted the behaviour I described. If I add using the Buy Now button on the product listing page (category view) it adds to the cart with a straightforward product ID. If I click through to the products page and add it to cart from there, it will add it to my cart but with id:hash - duplicating the products in my basket

    See screenshot :-

    Click image for larger version. 

Name:	Screenshot 2020-10-13 at 15.50.44.jpg 
Views:	32 
Size:	43.4 KB 
ID:	19244
    Click image for larger version. 

Name:	Screenshot 2020-10-13 at 15.51.05.jpg 
Views:	44 
Size:	56.9 KB 
ID:	19245

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

    Default Re: Duplicate products added to shopping cart

    Most bizarre.

    I can't replicate the problem.

    I've tried the currency switch. Makes no difference. (Shouldn't anyway)

    I've tried switching among all the settings for "Display Product Add to Cart Button (0=off; 1=on; 2=on with Qty Box per Product)"
    and also for "Display Multiple Products Qty Box Status and Set Button Location".
    This means I've been able to test each of the following scenarios:
    - Buy Now button from product listing
    - Add To Cart button from product listing after entering "1" for quantity
    - Add To Cart button from product page after entering "1" for quantity
    - Multiple-Add-To-Cart-Buttons (top/bottom) from product listing after entering "1" for quantity
    - click to product (already in cart) from shopping-cart page and click Add To Cart with "1" in the quantity box, which now adds one more to cart, making it show "2" for quantity and still just a single row in the shopping cart page.

    For reference, to create the product I tested with I used the same settings found on the "Sample of Product General Type" product in the demo products.

    I also tried testing with the actual demo product suite. Trying all these actions with products having no attributes worked normally. For those with attributes assigned to them I got the id:hash pattern as discussed, as expected.
    .

    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.

  3. #13
    Join Date
    Oct 2007
    Location
    Cornwall/Amsterdam
    Posts
    61
    Plugin Contributions
    0

    Default Re: Duplicate products added to shopping cart

    The products I added where straightforward products. No attributes, I haven't added any attributes to this database in attributes controller. I didn't add in any demo products during install as I wanted to keep the database clear of everything.

    Trying to think what specific thing is causing it.

    I'm using UTF8 encoding and not the newer UTF8-MB4
    I'm running on php 7.2 on litespeed
    I've got SQL query cache set to database

    They are the only options I specifically chose during install, to match my own legacy store.

    Any ideas? I can give you access to the store on my dev server. It isn't technically online, but I can give you the ip and url to add to your hosts file on your computer allowing you to see the test website. I can also give you login credentials as its a completley empty store with non of my customer info or anything in.
    Last edited by johnjlarge; 13 Oct 2020 at 09:17 PM. Reason: typo

  4. #14
    Join Date
    Oct 2007
    Location
    Cornwall/Amsterdam
    Posts
    61
    Plugin Contributions
    0

    Default Re: Duplicate products added to shopping cart

    I'm not sure what is causing this, but it's definitely one of the changes to /includes/classes/shopping_cart.php

    The store I'm running which has the bug is v1.5.6c

    If I take the /includes/classes/shopping_cart.php from the previous v1.5.6b and drop it in my 1.5.6c the problem is resolved.

    Both /includes/classes/shopping_cart.php from v1.5.6c and 1.5.7 cause this bug, so its a change made between the file dated @version $Id: DrByte 2019 Apr 07 Modified in v1.5.6b and @version $Id: DrByte 2019 Jul 16 Modified in v1.5.6c

    This bug is completely random, I have another store (different business) running 1.5.7. Same upgrade path, same server & doesn't exhibit this issue.

  5. #15
    Join Date
    Oct 2007
    Location
    Cornwall/Amsterdam
    Posts
    61
    Plugin Contributions
    0

    Default Re: Duplicate products added to shopping cart

    I've narrowed it down to a single line of code.

    In /includes/classes/shopping_cart.php version from 1.5.6c we have the following line at line number 1962

    Code:
    $real_ids = isset($_POST['id']) ? $_POST['id'] : array();
    If I replace this line of code with the equivalent line from version 1.5.6b the shopping cart duplication issue is solved

    Code:
    $real_ids = isset($_POST['id']) ? $_POST['id'] : "";
    Not being familiar with all the changes made to this code & seeing as you guys authored it, maybe that will shed some light onto this bug?
    Last edited by johnjlarge; 14 Oct 2020 at 08:08 AM.

  6. #16
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Duplicate products added to shopping cart

    Quote Originally Posted by johnjlarge View Post
    I've narrowed it down to a single line of code.

    In /includes/classes/shopping_cart.php version from 1.5.6c we have the following line at line number 1962

    Code:
    $real_ids = isset($_POST['id']) ? $_POST['id'] : array();
    If I replace this line of code with the equivalent line from version 1.5.6b the shopping cart duplication issue is solved

    Code:
    $real_ids = isset($_POST['id']) ? $_POST['id'] : "";
    Not being familiar with all the changes made to this code & seeing as you guys authored it, maybe that will shed some light onto this bug?
    What do you have for line 564 of includes/functions/functions_general.php and then also separately provide the code that includes 5 lines before to 5 lines after that line number.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #17
    Join Date
    Oct 2007
    Location
    Cornwall/Amsterdam
    Posts
    61
    Plugin Contributions
    0

    Default Re: Duplicate products added to shopping cart

    Hi.

    It's the standard functions_general.php file from the 1.5.6c zip.

    Around that line I have the following. Line 564 in bold :-


    * @param array|string $params
    * @return string
    */
    function zen_get_uprid($prid, $params) {
    $uprid = $prid;
    if ( !is_array($params) || strstr($prid, ':')) return $prid;

    foreach($params as $option => $value) {
    if (is_array($value)) {
    foreach($value as $opt => $val) {
    $uprid = $uprid . '{' . $option . '}' . trim($opt);

  8. #18
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,501
    Plugin Contributions
    88

    Default Re: Duplicate products added to shopping cart

    Are the problematic products, by chance, using radio-button attributes? If so, have you made sure that one of those attribute-values is identified as being the 'default'?

  9. #19
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Duplicate products added to shopping cart

    Unfortunately, that is the contents of that line for ZC 1.5.6c. At some point after that release, a condition such as this was identified and a change was pushed to apply to the next sub-release and also captured in the next full release. The line has become:
    Code:
        if ( !is_array($params) || empty($params) || strstr($prid, ':')) return $prid;
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #20
    Join Date
    Oct 2007
    Location
    Cornwall/Amsterdam
    Posts
    61
    Plugin Contributions
    0

    Default Re: Duplicate products added to shopping cart

    Quote Originally Posted by mc12345678 View Post
    Unfortunately, that is the contents of that line for ZC 1.5.6c. At some point after that release, a condition such as this was identified and a change was pushed to apply to the next sub-release and also captured in the next full release. The line has become:
    Code:
        if ( !is_array($params) || empty($params) || strstr($prid, ':')) return $prid;
    Hi mc12345678

    I'm troubleshooting a 1.5.6c store. If I change line 564 of functions.php to the code you supplied, will this be the only fix required? is there a list of any other fixes that came up from that release that I should keep in mind?

    lat9, I'm only using text input attributes and one page uses a file upload attribute. No radio buttons.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v150 Products not getting added to shopping cart?
    By EPWink in forum Setting Up Categories, Products, Attributes
    Replies: 8
    Last Post: 23 Apr 2012, 05:10 PM
  2. wrong product added to shopping cart
    By maxus in forum General Questions
    Replies: 0
    Last Post: 12 Oct 2011, 05:13 PM
  3. Items not added to shopping cart and cannot edit products
    By scorwine in forum General Questions
    Replies: 1
    Last Post: 19 Jul 2010, 04:11 AM
  4. Products not being added to shopping cart
    By kashyyyk in forum General Questions
    Replies: 2
    Last Post: 14 Aug 2009, 02:51 AM
  5. No Shopping Cart - Products Not Added?
    By starmakersandy in forum General Questions
    Replies: 1
    Last Post: 5 Oct 2008, 09:50 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