Hi,

I would love to get a continuos shopping button in the shopping cart, which brings the user back to the last product page he has been.

Kirk

CommentFileSizeAuthor
#22 cart.png16.86 KBbhans@zoominternet.net
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Title: continuos shopping button in cart » Continue shopping button in cart
Component: User experience » Contributed modules
Status: Active » Postponed

Hmm, it's a fine idea for a feature, but given the way Drupal Commerce approaches products / product displays in core, I don't think we'll be adding any core functionality for this. A contrib could be made that provides this feature for sites that do use the product display node paradigm, though. And I suppose alternate sub-modules of the same project could provide other ways of setting the link.

In the meantime, the easiest thing to do is just alter the link onto the form or even figure out a way to add it directly in Views.

zorroposada’s picture

I wanted to add a "Continue Shopping" button to the cart form.

I have seen this button in most of the e-commerce sites. Visitors are used to see it in the cart form.

The default behaviour for this button is to take you to the product page or to the product list page depending on how you arrived to the cart form page.

I have seen this button in apple.com and criterion.com

<?php
/**
 * Implements hook_form_FORM_ID_alter(&$form, &$form_state, $form_id)
 */
function MYMODULE_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state, $form_id) {
  $form['actions']['continue_shopping'] = array(
    '#type' => 'button',
    '#value' => t('Continue Shopping'),
    '#weight' => -999,
  );
  if (isset($_SERVER['HTTP_REFERER']) && strlen($_SERVER['HTTP_REFERER'])) {
    // if user comes from product detail page, redirect user to previous page
    $form['actions']['continue_shopping']['#attributes'] = array('ONCLICK' => "history.go(-1); return false;");
  } else {
    // redirect user to product list page 'store' by default
    $form['actions']['continue_shopping']['#attributes'] = array('ONCLICK' => "window.location.href='" . url('store') . "'; return false;");
  }
}
?>
mediapal’s picture

Thank you for this one.

Works perfect.

andyh69uk’s picture

I apologise in advance for my question but I rarely change views and can't for the life of me remember where I should put that code, I have spent ages looking on the internet with no success, please help. Where do I put that code?

mediapal’s picture

The code doesn't go some where like this. You take the code and build your own custom module with it.

In MYMODULE_form_views_form_commerce_cart_form_default_alter you replace "MYMODULE" with your module name.

A module folder contains at least a my_module.info and a my_module.module file.

andyh69uk’s picture

Thank you, working perfectly

deggertsen’s picture

Component: Contributed modules » User experience
Status: Postponed » Needs review

Yes, thank you. This really should be an option by default in drupal commerce. In fact it would be best if it was committed because if somebody didn't want it for some weird reason, they could simply use css to hide it.

Marking as needs review. Maybe it needs work since #2 technically isn't a patch, but I don't think a patch is necessary. If it is then I'm pretty sure I could make one.

Also, I don't think it is necessary that this would be a contributed module, so I'm marking it back to user experience. Correct me if I'm wrong.

vasike’s picture

seems we have a duplicate #1308582: Customize Checkout Pages: Page names, pages order, buttons labels, help text, new custom pages

Could Commerce Checkout Pages module be a part of Drupal Commerce, so the checkout pages titles, buttons or others could be configurable from UI?

deggertsen’s picture

At a glance at the other issue it does not appear to be a duplicate. If I understand correctly that issue is talking about making the checkout process more clear while this issue is simply to create a "continue shopping" button which would send them back to where they were shopping in order to allow them to add more products to their cart. In this case continue shopping does not mean proceed to checkout, it means lets go back so that we can add more stuff to our cart!

Correct me if I'm wrong.

vasike’s picture

nothing to correct. definitely my mystake. sorry about that.

rszrama’s picture

Component: User experience » Contributed modules
Status: Needs review » Postponed

Yeah, "needs review" is only for issues that actually have patches. That said, I'm still not convinced this needs to be a core feature, especially if there's a way to demonstrate how to do this with Views on its own. It's simply not a requirement for too many types of eCommerce sites to make it something people have to hack around to disable (i.e. using CSS).

At the very least, I wouldn't put something like this in core unless it was configurable, most likely through a custom Views area handler. Often it's easiest for elements like that to develop in contrib and find their way into core after they've been proven "in the wild", but we can make this back into a feature request for core if someone wants to come up with an area handler and an appropriate patch to the core shopping cart form.

ahimsauzi’s picture

This is such an important super must have functionality!

Works like a charm. Thank you so much for posting this solution.

~Uzi

andersiversen’s picture

The code posted works great - thanks! :)

Though if the shopping cart is empty there's no button. How do I get the button to display even though the cart is empty?

sprankles’s picture

This worked very well for me. I had one issue that I need help with. When I remove an item from my cart and choose continue shopping it causing the item be placed back in the cart as that is the last page that was loaded. Is there an adjustment that needs to be made to the else statement to remedy this? Thanks.

Willysino’s picture

Muchas gracias zorro.
Es genial.

Willysino’s picture

mysoftmusic, thank you very much, for you "mini how" is great.
Ok deggertsen, I am agree with you.

vasike’s picture

What about Commerce add to cart confirmation module?
Could this module be considered as the solution for this issue?

webmaster@girija’s picture

Thank you very much zorroposada...

That works fine.

Thank you very much

blueblot’s picture

Thanks zorroposada

works fine.

basscleff94010’s picture

Category: Feature request » Support request
Issue summary: View changes

Ryan, can you provide more details of where in the View: Commerce add to cart confirmation the link back to the source is set? Its not clear from just looking at the View.
Thank you.

Paul

bhans@zoominternet.net’s picture

FileSize
16.86 KB

I know this is very old, but there is an easy way. Edit the cart view. Add a 'Global:Text area' to the Footer. Insert an 'a href' link in the text area you just created linking back to your products listing or wherever you want them to go back to continue shopping. Oh, make sure you have full html for the editor here. Here is an example for a bootstrap based theme:

<a href="/products" class="btn btn-primary" role="button">Continue Shopping</a>

It takes back to my "products" landing page. Nice thing with bootstrap, using the btn will automatically make it a button for you. If not bootstrap, you can add some css to format it.

Also, a little more css and you can get the continue shopping button on the same line as the checkout.

Chris Matthews’s picture

@bhans...

a little more css and you can get the continue shopping button on the same line as the checkout.

Could you add to your example above based on a bootstrap theme that would put the continue shopping button on the same line?

Much appreciated,