Hi there,

I'm using a shopping cart block on my order page, and it is redirecting to the front page when clicking the 'delete' button on a line item. The item is removed from the cart, including a message to the effect when the home page loads. Looking at the page source, the action for the form is set as the base URL, rather than the order page's path.

I'm using the default shopping cart block view provided by the cart module, with one change: the contextual filter for Order ID is set to custom PHP code to extract the order ID (since the default behaviour displayed all previous cart items). I've tried changing it back to the default behaviour, but no change.

Any idea why this might be occurring?

Files: 
CommentFileSizeAuthor
#3 Form array167.59 KBPedroMiguel
#2 commerce_cart_block_view.txt15.89 KBaharvie

Comments

Status:Active» Postponed

I'm pretty sure this is a known issue in Views 3, but I can't find the pertinent issue. Mind digging there a bit?

StatusFileSize
new15.89 KB

Hmm, I did some searching in the Views issues, but I can't find anything relevant either. The only issues I could find that described a similar problem were these:

http://drupal.org/node/1051668
http://drupal.org/node/1123196

The first one describes AJAX = yes, which is not the case here. The second describes exposed filters, but also a committed fix. I'm trying the latest dev versions of Commerce and Views, but still seeing the problem.

I've attached an export of the view if it helps.

StatusFileSize
new167.59 KB

Got the same error, the form array have a redirect, but the redirect is not used (maybe the array is not well build?)

Not sure if is on views or on commerce itself.

I attach a screenshot, where I think something is wrong.

Category:support» bug
Priority:Normal» Major
Status:Postponed» Active

Chaging this from support request to Bug report, because that what this is.

The delete button on cart dont respect the redirect.

So on a store with thousands products, if a costumer are on a deep path and made a mistake (IE: added a red cap instead a black one) and delete the line item return to front page.

Priority:Major» Normal
Status:Active» Postponed (maintainer needs more info)

As I mentioned, I'm pretty sure there's an issue with the form in Views / Drupal itself. This form isn't managed through Commerce itself, so really we need research to be done to find the root of the problem inside the other systems.

Status:Postponed (maintainer needs more info)» Active

Found IT!!

Is with commerce itself

Based on this: http://drupal.org/node/525592#comment-1833824

Views assumes that exposed filters might appear on a page other than where they intend to appear. Therefore they lead back to the 'link display'. If there isn't a page display on the view, then they link to the home page.

When embedding the view, you need to set $view->override_path in order to get these filters to go somewhere else. Which means you can't use views_embed_view(), but instead need to do a $view = views_get_view(), $view->override_path = $_GET['q'] and $output = $view->preview().

As commerce use a own function to embed view (function commerce_embed_view) on commerce.module I just change line on commerce_cart.module line 491:
Was :

<?php
'contents_view' => commerce_embed_view('commerce_cart_block', 'defaults', array($order->order_id)),
?>

I change to :

<?php
'contents_view' => commerce_embed_view('commerce_cart_block', 'defaults', array($order->order_id), $_GET['q'] ),
?>

I dont know how to create a patch, so if this is ok, someone could please create one?

Status:Active» Postponed

Actually we're going to remove that embed of the cart block to use the view itself shortly, see #1030128: Convert shopping cart block and form Views to use Views block / page displays

Status:Postponed» Fixed

Revisiting this, since the effort to convert these entirely to Views got postponed, I'm committing PedroMiguel's fix.

Please, can you tell us when you have it fixed?
thanks!

November 16, per the comment above. It's just in the latest -dev version but will be in the 1.5 when it's released.

Thanks Ryan!

Status:Fixed» Closed (fixed)

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