Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / add to cart not working when not logged in

add to cart not working when not logged in

Locked

Started by delia on 10 Jun 2016, 12:09 PM · Views: 1,860

Results 1 to 18 of 18
This thread is locked. New replies are disabled.
10 Jun 2016, 12:09 PM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #1 by delia

I made a number of small changes to a site that has resulted in a weird problem. If I log in, adding products is not a problem. When not logged in, you can't add products from either the product info page or the product list page. It will go to the shopping cart but says there are no products in the cart.

I've checked the mods and other changes and am pretty sure they aren't the cause of this.

I also applied the recommended patches and I suspect there lies the problem. I've tried to back those changes out - in admin it fixed one problem I was having there. I've had other problems with these patch files but this is the updated set with all patches so far for 1.5.4.

Those files are:
ajax.php
includes/functions/html_output.php - rolled back to 1.5.3 level as 1.5.4 did not change that file
includes/extra_configures/security_patch_v154_and_older.php - removed
includes/modules/pages/checkout_confirmation/header_php.php - not touched since I can't get that far

admin/admin_account.php
admin/includes/auto_loaders/config.adminSanitize.php - removed
admin/includes/classes/AdminRequestSanitizer.php - removed - I think this was the one that screwed up admin
admin/includes/init_includes/init_sanitize.php - returned to 1.5.3

So the first question is there any way the patch files could cause this aberrant behavior of not adding to cart?

Second question - can anyone think of any alternate scenario that would cause this behavior? Never had it happen before.

It has to be template caused: no admin settings have changed. I will set up a test scenario and gradually add the template back in but I am hoping for a clue first so that I don't have to spend a lot more time on this.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

10 Jun 2016, 12:14 PM
#2
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #2 by delia

maybe this will help. Print session returns this:

[1] => Array
                        (
                            [page] => product_info
                            [mode] => NONSSL
                            [get] => Array
                                (
                                    [products_id] => 11152
                                    [cPath] => 2683_2684
                                    [action] => add_product
                                )

                            [post] => Array
                                (
                                )

                        )
```Looks like it does retain tje product but won't post it to the cart?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

10 Jun 2016, 1:23 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #3 by mc12345678

Does the product page contain the securityToken that is typically added to within the form tags by use of the zen function for generating a post related form?

Also, what files are in the includes/extra_cart_actions directory?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

13 Jun 2016, 6:52 PM
#4
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #4 by delia

happening on both product info and product list pages
nothing in the extra cart actions

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

14 Jun 2016, 5:53 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #5 by mc12345678

How does includes/modules/pages/shopping_cart and related files in that directory differ from a ZC vanilla install?

What includes/classes/observers are installed and to what do they listen?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

16 Jun 2016, 4:41 PM
#6
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #6 by delia

So I finally just set up the cart in another directory but with the same database and no custom template. It's doing the same thing so it must not be template based. The files are the default files for 1.5.4. What in the heck could be going on?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

20 Jun 2016, 12:24 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #7 by drbyte

I'm a bit baffled too. Normally symptoms like this also affect login.

Has the shopping_cart class been altered?

The add-to-cart process works like this:
a) user clicks link/button to request the add ... this fires a GET/POST depending on where they're at
b) init system fires, to confirm session is started, and link to visitor's current session
c) main_cart_actions and extra_cart_actions fire to trigger the actual add
d) the shopping_cart class (fired by cart actions above) stuffs the added product into the visitor's basket:

  • if logged in, the basket data is stored in both the session and in the database
  • if not logged in, the basket data is stored only in the session, until they login (which causes a merge of the data)

So, given that both the logged-in and not-logged-in visitor are treated the same until the last step where the actual add happens, it's odd to see a disparity like this.

delia:

So I finally just set up the cart in another directory but with the same database and no custom template. It's doing the same thing so it must not be template based. The files are the default files for 1.5.4. What in the heck could be going on?
I'd be very interested in seeing if v155 does the same, on the same server and hosting account.

Are there any custom php.ini files on this site? How about any PHP directives in any .htaccess files?
(I'm thinking mainly of things that would affect how sessions are configured on this server, where temporary session data is stored on this server, whether that's out-of-disk/quota-space, and so on)

.
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.

20 Jun 2016, 1:07 PM
#8
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #8 by delia

Server shouldn't be an issue. It is my server - leased from, setup and supported by geekhost.ca. There are no custom php.ini files on the hosting account. Running three other zen cart installations on the same account with no issues (all 1.5.4)

I don't have any live 1.5.5 sites running on this server but there is a test site that works perfectly.

I did a print session from my now upgraded 1.5.5 default template where this is happening - this is when product is added and I see the product id in the session.

[cart] => shoppingCart Object ( [contents] => Array ( ) [total] => 0 [weight] => 0 [cartID] => [content_type] => [free_shipping_item] => 0 [free_shipping_weight] => 0 [free_shipping_price] => 0 [download_count] => 0 [total_before_discounts] => 0 [display_debug_messages] => [flag_duplicate_msgs_set] => ) [check_valid] => true [navigation] => navigationHistory Object ( [path] => Array ( [0] => Array ( [page] => product_info [mode] => NONSSL [get] => Array ( [cPath] => 14_86_316 [products_id] => 902 [action] => add_product ) [post] => Array ( ) ) [1] => Array ( [page] => shopping_cart [mode] => NONSSL [get] => [post] => Array ( ) ) ) [snapshot] => Array ( [page] => product_info [mode] => NONSSL [get] => Array ( [cPath] => 14_86_316 [products_id] => 902 ) [post] => Array ( ) ) ) [language] => english [languages_id] => 1 [languages_code] => en [currency] => GBP [today_is] => 2016-06-20 [updateExpirations] => 1 [session_counter] => 1 [customers_ip_address] => 7xxxxx [valid_to_checkout] => 1 [cart_errors] => )

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

20 Jun 2016, 1:28 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,154
Plugin Contributions:
56

Post #9 by lat9

If that's the full dump of the site's $_SESSION variable, then you're missing the **securityToken **value which is the root cause of the issue you're having (add-to-cart not working).

You need to determine why that value isn't being set (some session-related issue), correct that and your cart-handling will follow suit.

20 Jun 2016, 1:35 PM
#10
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #10 by delia

nope, I just left it off - first part is
Array ( [securityToken] => 1cd17a7148ad85dda2d179ee89aa7931 [customers_host_address] => xxxxxx [cartID] =>

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

20 Jun 2016, 1:54 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #11 by drbyte

Well, next would be to start testing for the existence of expected data at different stages in the process.
Since there are several ways to add-to-cart (ie: submit button, vs buy-now-text-link, vs multiple-products-in-cat submit, etc), pick just one to test first.
Then go into main_cart_actions, and dump the $_POST inside that action and see what you get.
Then work your way through the corresponding function/s in the shopping_cart class.

Oh, and for future, when you're dumping a nested set of arrays, it's nearly impossible to read without providing the indentation too, so either copy the output from raw HTML source, or echo a <pre> tag first. Then post inside ```
[CODE]

.
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.

20 Jun 2016, 2:04 PM
#12
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #12 by delia

What you just said is not greek to me, thank heavens, but I don't know how to implement it. nap time

Sorry about the arrays - didn't think.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

20 Jun 2016, 2:15 PM
#13
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Heerenveen, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Post #13 by design75

delia:

What you just said is not greek to me, thank heavens, but I don't know how to implement it. nap time

Sorry about the arrays - didn't think.

A very usefull tool is the superglobals module. This will dump the arrays like $_POST and $_SESSION (and much more if wanted) for you on-screen.

20 Jun 2016, 4:09 PM
#14
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #14 by mc12345678

Design75:

A very usefull tool is the superglobals module. This will dump the arrays like $_POST and $_SESSION (and much more if wanted) for you on-screen.

Though the $_POST gets moved into other areas while transitioning to the shopping cart page. It's possible though to take advantage of the $_SESSION aspect and add an includes/extra_cart_actions file something like: 1_capture_post.php

with content of:

<?php $_SESSION['posted_data'] = $_POST;

And then with superglobals active for you, the SESSION variable of posted_data will have all of that $_POST information with expectation it would be the first extra_cart_actions file to be loaded if there are others present (alphabetically loaded). :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

21 Jun 2016, 8:55 PM
#15
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #15 by delia

So no posted array.

But I think the database is the problem. I took that test site and reinstalled with the default database and it was fine. The database is the only difference.

I optimized it, made a few changes and tested a few more things and still have not found the glitch.

Any other suggestions?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

21 Jun 2016, 8:57 PM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #16 by drbyte

delia:

So no posted array.

But I think the database is the problem. I took that test site and reinstalled with the default database and it was fine. The database is the only difference.

I optimized it, made a few changes and tested a few more things and still have not found the glitch.

Any other suggestions?
You could try swapping the contents of the configuration_groups and configuration tables, to see if it's a settings thing. Or just compare all the settings.

.
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.

21 Jun 2016, 9:03 PM
#17
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #17 by delia

I was thinking configuration was the place to start. Will work on that.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

23 Jun 2016, 1:10 PM
#18
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #18 by delia

In the end I rebuilt the site in a separate directory. It was a file issue but I was never able to determine what file or what could have happened as the changes I had made were so minor. I hate not knowing exactly what it was but at least the site is fixed.

Thanks everyone for their assistance!!!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo