Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Items staying in cart between stores
- This topic has 4 replies, 3 voices, and was last updated 14 years, 3 months ago by amin007.
-
AuthorPosts
-
August 20, 2010 at 9:14 pm #1720wrichMember
Hello,
I am using a WordPress 3.0.1 build so that I can have multiple sites with WP-carts under one domain. But when ever I add an item from one store and travel to another store, my shopping cart keeps the product from the previous store. So if I were to buy two products from two different stores, when I checked out, I go to the paypal account of the store I am on. Am I setting thing up incorrectly somewhere?
Thanks,
Chase
August 21, 2010 at 2:32 am #23550wpCommerceModeratorAre you running multiple sites from one domain? Can you please give examples of your sites?
August 21, 2010 at 3:34 am #23551amin007Participantwhen say multiple sites do you mean actual multiple sites like the following:
example1.com
example2.com
or do you mean multiple wordpress installs within the same site?
example1.com
example1.com/site2
August 21, 2010 at 1:20 pm #23552wrichMemberexample1.com
example1.com/site2
Just like that, we had a temporary solution by terminating the session if a user switched sites, so there no cart items will travel from site to site. We added this to our index.php
$locationArray = explode('/', $_SERVER['REQUEST_URI']);
$store_id = $locationArray[1];
if ($store_id == 'favicon.ico') {
$store_id = 'other';
}
if (!(isset($_COOKIE['store_id']))) {
if ($store_id != 'other') {
setcookie('store_id', $store_id, mktime(0,0,0,date("n")+1,date("j"),date("Y")), '/', $_SERVER['SERVER_NAME'], false, true);
}
} else {
if (($_COOKIE['store_id'] != $store_id) && ($store_id != 'other')) {
session_destroy();
$params = session_get_cookie_params();
setcookie('PHPSESSID', '', time()-42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
setcookie('cart_in_use', '', time()-3600);
setcookie('store_id', $store_id, mktime(0,0,0,date("n")+1,date("j"),date("Y")), '/', $_SERVER['SERVER_NAME'], false, true);
}
}Any better ideas?
Chase
August 22, 2010 at 4:20 am #23553amin007ParticipantOkay so thats not two different sites. It’s the same site. Remember just because you have installed multiple WordPress in your one site doesn’t make it two different sites in PHP and Apache.
What you have there will do but I would recommend resetting the shopping cart using something like the following rather than destroying the session (in case you have other session variables that you might need):
unset($_SESSION['eStore_cart']);
-
AuthorPosts
- You must be logged in to reply to this topic.