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?

Members fund testing for the Drupal project. Drupal Association Learn more


rszrama’s picture

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?

aharvie’s picture

15.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:


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.

PedroMiguel’s picture

167.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.

PedroMiguel’s picture

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.

rszrama’s picture

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.

PedroMiguel’s picture

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 :

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

I change to :

'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?

pcambra’s picture

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

rszrama’s picture

Status: Postponed » Fixed

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

drupalerocant’s picture

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

rszrama’s picture

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.

drupalerocant’s picture

Thanks Ryan!

Status: Fixed » Closed (fixed)

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

Marko B’s picture

Issue summary: View changes

For me, this is nothing helping at all. Commerce cart block keeps redirecting to front page. Unless I use solution from here
https://www.drupal.org/node/525592#comment-5906780 and use $view->override_path.

peter panes’s picture

Use override_url instead of override_path in custom module as above.

Rather than setting the redirect URL for the view now you are setting the Default URL for the view so it will link to that instead of redirecting to homepage:

The following code works perfectly for me with this use case:

$view->override_url = base_path() . $_GET['q'];

maxplus’s picture

Thanks @peter panes from #14

For me the way to go is indeed using:
$view->override_url = base_path() . $_GET['q'];

When using:
$view->override_path = $_GET['q'];
=> I was getting unwanted URL's that are no clean URL's anymore and always get longer and longer, like described in https://www.drupal.org/node/525592#comment-9351087

Arne Slabbinck’s picture

Thanks to #13 and improvement on path in #14, works like a charm!