Hi,

I would like to have separate carts for separate domains for registered users, because when one domain does not sell an item, but it still shows in the shopping cart because the user put it there on another domain, the user will get an access denied error if she tries to click on the item. And my purpose of having multiple domains is to avoid mixing products.
If I have to make users register on each domain, then so be it, but I would like to avoid that.

It seems to work fine for unregistered users, but registered users will load the same cart across all domains.

Is there a way to remove items that the user has put in the cart at another domain?
What is the best way to achieve this? Do I have to prefix the cart table, or the user table? Or does anyone know of a smarter way?

Comments

longwave’s picture

Prefixing the uc_cart_products table might work, try that and see how you get on.

#498940: Multiple carts for multiple domains? is a duplicate feature request, but I have no free time to work on this module.

MortenP’s picture

Thank you for your reply

Yes, prefixing uc_cart_products does work. My question was not a feature request, since I did see from other posts that you don't have time, I was just wondering whether other users have found another way. I feel table prefixing is a last resort solution, but I'll use it since it works.

Thanks again for the work you have done on this module

longwave’s picture

Status: Active » Fixed

I think table prefixing is by far the easiest way to solve this, and any code-based solution would be much more complicated, if indeed it is possible at all; I'm not sure it's possible to hook into everywhere that Ubercart deals with cart items to check domain access on each node.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

khaled.zaidan’s picture

I use table prefixing for this issue, and it works! But it has one minor bug:

If an anonymous user, has items in the both carts on both domains. And finishes the checkout for one of them, the cart on the other domain is automatically emptied.

What really happens is, although the 2 carts are in different tables (separate tables for each domain), but the cart_id is the same (which i guess is stored in the session), so after the checkout, the code will see items that belong to a cart_id that was already checked out, so it will ignore them.

Anyone knows a fix for this?

Note: I think that an anonymous user has the same session across domains, i think having separate sessions would fix the problem.

longwave’s picture

Status: Closed (fixed) » Active

Perhaps prefixing the "sessions" table as well will help avoid this?

When checkout is complete, the cart id is deleted from the session (and a new id is randomly generated when the user next adds a product to their cart), which causes the behaviour you describe.

tjb74’s picture

I have done the prefix method which works, however I struggling to give users an idea of how many items they have in carts over the sub domains they have not checked out on. I thought I might be able to do this with a view, but the only option seems to be filter by products in the current cart, not any cart.
I was wanting to give the purchaser a way of linking back to carts they had not checked out on... It could be simple, just a link to domains that have carts with an item in...

longwave’s picture

If you are prefixing the tables, I don't think Views will have any way to access tables with prefixes other than the current site, and for anonymous users, you won't have access to their session (which is needed to know their cart ID).

tjb74’s picture

No anonymous users on this site.
Trying using a view for orders that are in checkout, not just items in the cart as I'd like, but if users have reviewed the order it is saved to the orders table and a view can filter on items in checkout.
Gives a reminder and links back for users that they have not checked out.

As you move between subdomains the items do remain in the carts, so I was thinking a view would be able to pick up them, and there is a view that seems to give an overall view of customers carts contents for admin, but there is no way to add the logged on uid as an argument.

ruchira_shree’s picture

Can you please tell me in details how you used table prefixing and got the solution of seperate shopping cart for seperate domains....thanks in advance
Please reply
Its urgent
Thanks once again