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

    red flag Duplicate products added to shopping cart

    I've been working on migrating over to php 7.3 and have been busy modding 1.5.6c to fit my needs. I know 1.5.7 has since been released but I want to get this working correctly before that next increment.

    Over on my website, if I browse through the categories and click to add any product to my basket, it adds the product. if I then click through to the product information page for the same product and click add to basket again, it adds it to my basket, but as a seperate product as opposed to incrementing the number in cart. It's like products added from the category page & products added from the products actual page are different.

    I've noticed in the database that the products id is getting some sort of weird hash on the end so I'm assuming one page is adding the product id with the hash and another is not.

    For example for product id 7512 I have duplicate entries in my basket, one for 7512 and another for 7512:b78cdfee2f7da7e6896abf4bfc9cece9

    This means that in my basket on the front end I have the same product listed as two seperate products with the same name.

    Has anyone come across this? Do I need to modify something in my template files for adding to basket?

    Click image for larger version. 

Name:	Screenshot 2020-10-11 at 16.42.00.jpg 
Views:	80 
Size:	92.2 KB 
ID:	19240

    See screenshot for duplicate items in the basket.

    Thanks

    John
    https://www.koolbadges.co.uk

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

    Default Re: Duplicate products added to shopping cart

    in my basket on the front end I have the same product listed as two seperate products with the same name

    This is normal behavior when products have attributes assigned to them.

    the products id is getting some sort of weird hash on the end

    That "hashed" set of letters after the product id is an identifier for the set of attributes assigned.


    How to "change" it?
    Due to some of the internal workings of this, there's no built-in way to change this behavior. At least not up to and including v157.
    .

    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. #3
    Join Date
    Oct 2007
    Location
    Cornwall/Amsterdam
    Posts
    61
    Plugin Contributions
    0

    Default Re: Duplicate products added to shopping cart

    Thanks, Dr Byte.

    The strange thing is, the products in question don't have any attributes assigned to them. This happens with any product from our catalogue. I can understand the logic behind say, adding text to customise a product & the hash giving it a unique identifier to differentiate within the basket, but this is happening for any given product.

    Thanks

  4. #4
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Duplicate products added to shopping cart

    I can't reproduce the problem here.

    So ...

    If we start with a fresh brand new install of Zen Cart. What would one have to do to that install to make it behave the way yours is?

    Building up a new site step by step and testing the scenario to try to reproduce it should expose a set of steps that can also point to the root cause of the problem. And then armed with that reliable set of reproducible steps we can determine a fix.

    What are those steps?

    including server software like php versions, apache versions, zen cart version, plugins and versions, customizations you've made to the code, templates installed, etc.
    ... including testing whether it is actually still a "problem" without certain templates/plugins/customizations installed at all (not just "removed afterward", but never installed in the first place)
    .

    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.

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

    Default Re: Duplicate products added to shopping cart

    Thanks Dr Byte.

    I've just setup a development server to test this out.

    Last time all the files where fresh 1.5.6c as I've been running this store since 2006 and it started out at v1.3.0.1 so I wanted to get rid of any legacy files. The only thing carried over was my database which seems to have gone through all the update steps with each itteration I've upgraded over the years.

    I then added in all of the plugins & template I used, but I kept them all in a folder for reference/debugging. What I will do is start a fresh 1.5.6c with my database and see if it works as expected. I'll then add back my template and test each thing one by one until I can figure out the culprit. I'll keep you posted.

    Attachment 19241

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

    Idea or Suggestion Re: Duplicate products added to shopping cart

    OK.

    Completely virgin installation of 1.5.6c but using my legacy database and without adding any templates or plugins the error is occurring. So I assume it's either an error in 1.5.6c or within my database.

    Does anyone have any idea what could be causing this? Missing our corrupted data in the configuration table perhaps?

    Click image for larger version. 

Name:	Screenshot 2020-10-12 at 11.26.58.jpg 
Views:	38 
Size:	45.3 KB 
ID:	19242

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

    Default Re: Duplicate products added to shopping cart

    Just upgraded 1.5.6c with 1.5.7 on the test server and the problem went away, so must be an issue in 1.5.6c specifically.

    I'll start the task of migrating my site to 1.5.7

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

    Default Re: Duplicate products added to shopping cart

    Hi folks.

    After a lot of troubleshooting I've narrowed down my search to changes made in /includes/classes/shopping_cart.php and the way it interacts with my template. My upgrade is from 1.5.1 and my template is coming along with me.

    For debugging I dropped the shopping)cart.php class from 1.5.1 into my 1.5.6c classes folder and the issue went away. Can anyone explain the template changes that where made to incorporate the changes within this class? I can see that the class itself is around 500 lines of code longer, so would like to adapt this final peice of my template to work with this new class.

    Thanks
    John

  9. #9
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Duplicate products added to shopping cart

    The changes to the shopping_cart class between 151 and 156 include syntax rewrites for PHP 7 requirements, enforcement of product min/max quantities, better handling of products priced-by-attributes, and much more.

    But I'm not convinced that's the issue, particularly because you said that using the 157 version of the class made the problem go away.

    If there's actually a bug, I'm more inclined to suspect that it's isolated to a tiny set of combined configuration settings both generally and to specific products.
    Configuration settings are mostly in your database.

    You said a fresh 1.5.7 install did not have the problem when used without your database, but when you added your database to 156 the problem appeared.

    So, back to reproducing the steps:
    - fresh 1.5.7 install, without old database
    - create one product to match one of the products you've seen the problem on. Please list all the settings you selected so it can be recreated by someone else.
    - does the problem occur?
    - if yes then maybe the issue is in one of those settings. Comparing those settings with a demo product that doesn't show the problem could be helpful.
    - if no then maybe it's one of the overall configuration settings. Perhaps start with Admin->Configuration->Minimum Values, Maximum Values, Attribute Settings, Product Info, etc. Perhaps mapping out the differences between your old store and the uncustomized one will reveal areas to narrow research into.
    .

    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.

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

    Default Re: Duplicate products added to shopping cart

    Hi Dr Byte.

    I used the old shopping_cart.php class from 1.5.1 on my 1.5.6c store and that fixed the problem. As soon as I set it back to the 1.5.6c version the problem came right back. It's a weird issue to chase & I thought it might be to do with my template file, but if I select the responsive classic template, which I haven't modified in any way, I get the same problem, which adds to the confusion.

    It's more of an annoyance than anything else, customers are unlikely to add a product twice, once from the product page and once from the buy now buttons on the category page, but the fact that it can happen & duplicates the same product, one with just the product id and one with the product id & hash (even though the product has no attributes) seems to suggest a difference between how my tpl_product_info_display.php from my template is sending info to the shopping_cart.php class. On my categories page it uses the buy_now hook & displays more info if attributes are required (as expected) bu when adding from tpl_product_info_display.php with the add_product hook its always adding the id:hash value as if it has attributes, even when not the case.

    I'll keep trouble shooting on the development server, I'll do a fresh install and create a product to see if it happens on a test store.

    Any further thoughts while I troubleshoot would be much appreciated & thanks for all the help so far.

 

 
Page 1 of 3 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