Using Line Item Summary to display the # of items, total, and cart links in a views block. It's listing the totals of different users. I have 2 items in my admin's cart, however in another browser I'm an anonymous user. Both browsers show 2 items & the total price, however if I enter the actual Cart page, it shows correctly.

I logged onto another computer and access the test site from there, and get the same result. I added an item to the cart of a 2nd user, and now in all 3 browsers the block summary shows 3 items and the total cost. It is not isolating the current order of the current user - not sure why. I tried playing with various views settings to force it to no avail. I cloned the cart block so I believe that is set up right.

I'm not actually listing any items, I hid them. I just want the summary to show.

Ideas?

Comments

tyromind’s picture

Issue tags: +summary
rszrama’s picture

Do you have page caching turned on?

tyromind’s picture

Negative.

rszrama’s picture

Hmm... Views caching? It sounds like some sort of caching problem... the question is where is it happening. : P

Could it be general block caching?

braindeadave’s picture

http://drupal.org/node/1049444

This might be of help.

*Edit*

Page above links to: http://drupal.org/node/914382 which is more relevant.

khiminrm’s picture

Hi! I have the same problem. I add a product to the cart under anonymous user, do not delete it from cart or submit an order, exit from site and then when I open my site on this or another another computer, the cart block shows summary with that product, but when I open shopping cart - It's empty.

khiminrm’s picture

I have found my problem - I used my own view's block in shopping cart which couldn't get the argument "order id" and couldn't show correct summary.

khiminrm’s picture

@tyromind - Maybe you have the same problem I had. Don't creat your own block for shopping cart in views. It will not recieve argument order id. In your theme use the block shipped with commerce and configure it with view Shopping cart (Default display).

tyromind’s picture

Yep, I cloned the Shopping Cart Block view and realized yes - with no Order ID argument, it's set to show all values. Does the built-in commerce view that's titled "Shopping Cart Block" work properly as a block on any other page?

Or better yet - is there a way to provide a default Order ID argument to the view I created?

khiminrm’s picture

Yes, default "Shopping Cart Block" works fine for me. I don't see any bugs yet. As I understand Order ID - It's an unique value for site visitor (anonymous or registered). As I know blocks in Drupal can not recieve arguments. I don't sure but you can try Mini Panels. Panels can recieve argument and provide it to the View.

tyromind’s picture

Entered Order:Owner as a Contextual Filter, fed with the logged-in user default argument. That's gotten me closer - so now a logged-in user only sees the number of items in his own basket - and the correct total.
Still have one last item to nail down. An anonymous user (not-yet logged in or registered) will see the total number of items any anonymous users have added to their carts. This doesn't actually affect the "My Cart" page, or checkout, etc. It's just a block I've built into the header of the site only showing how many items are in your cart, and the total.

I could enforce logging-in once a user tries to add an item to their cart, though I'd rather not have to do that. Ideas?

khiminrm’s picture

Better use commerce Shopping Cart Block. In a Shopping Cart Block view: fields display a list of products in the cart, footer of the view displays summery(quantity of products and total price). In the footer you can also define what links and what data to display or hide. If you want to show quantity of products and total price only, you can hide the all list of the products with css (for example #block-commerce-cart-cart .view-content: display:none;) and only footer of the view will be shown for a visitor.
For anonymous users test your cart in different browsers.

mikejoconnor’s picture

Category: bug » support
Status: Active » Closed (works as designed)

From reading this, it looks like this is not a bug in commerce, but more of a support / customization issue.

I've marked as support request / works as designed. Feel free to change that if this is actually a commerce bug.

ghussong’s picture

Assigned: Unassigned » ghussong
Status: Closed (works as designed) » Active

Hi everyone,

I have the same problem:
When I add a product to my cart, Shopping cart block's clone show the same result on any computers and browsers.
I tried a lot of thing but didn't find solutions.

versions:
Drupal Commerce 7.x-1.0-beta3
Views 7.x-3.0-beta3

Thanks for your help and sorry about my english !

n9352527’s picture

The original commerce_cart_block is defined using implementation of hook_block_info() function and it gets the $order->order_id argument when it is build in implementation of hook_block_view() function. Both functions are defined in commerce_cart.module.

So, the clone of commerce_cart_block will not work because it won't be build with the correct order_id argument.

I get around this by providing the correct order_id to a cloned cart block view using the views' default value feature. Edit the views' order_id contextual filter and select the provide the default value option and select the php code option. Then enter the following code:

global $user;
$order = commerce_cart_order_load($user->uid);
if ($order && !empty($order->commerce_line_items)) {
  return $order->order_id;
}
rszrama’s picture

Status: Active » Closed (works as designed)

Additionally, you shouldn't be using Views 3.0-beta3. You should be using the latest dev version of Views, and if you're building a new site, you may as well install with the beta4 instead of the beta3.

plazik’s picture

Issue summary: View changes

Code from comment #15 works for me.
DC 7.x-1.9.

tj99ay’s picture

#15 works a treat!

I created a mini cart block and was totally confused with what was going on until I read this. Thanks heaps!

tj99ay’s picture

Unfortunately, the PHP appears to be creating a permission problem, as anonymous users can no longer see the block. I've tried the "Disable SQL rewriting" trick a few have mentioned in other posts and tried changing various permission settings, but no luck? Any ideas?

tj99ay’s picture

Actually it does work for anonymous users, but only if there is something in the cart. Prior to adding the php code I was successfully displaying a "No Results Behavior", but this now appears to be bypassed since the change to the "Contextual Filter". So half works at least :-)