Closed claudiulodro closed 3 years ago
Nice one @claudiulodro. I was working on something similar a few weeks back but never got the chance to submit.
$frontend = (
( ! is_admin() || defined( 'DOING_AJAX' ) ) &&
( is_product() || is_checkout() || ( is_cart() && ! WC()->cart->is_empty() ) ) &&
! ( defined( 'DOING_CRON' ) && defined( 'REST_REQUEST' ) )
);
Create WC Session Cookie if:
It seems your solution is a lot cleaner 👍
Thanks!
I think the Cart/Checkout checks aren't necessary:
So the only situation this needs to handle is single product pages.
Hi @claudiulodro!
This looks good. I've rebased the changes on the latest trunk and also pushed a commit to account for #845, which was something we added after you submitted this PR. Once Travis gives me the green light, I'll merge the PR.
Tests I ran on this branch:
Issue: #777
Description
This PR improves the session handling to prevent caching issues. It does this by only initializing the session (if needed) on single product pages. Since a session without adding anything to the cart is only required when checking out from single product pages, this should dramatically reduce the number of sessions that are created.
Steps to test:
Documentation
Closes #777 .