12 replies [Last post]
spiderman's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/17/2007
Juice: 61
Was this information Helpful?

i haven't seen this discussed anywhere, and it's become apparent to me that i don't have many good ideas for the "best way" to address this question. the configurable but static 'continue shopping' link feature in the Cart Settings page is woefully inadequate for the SCW site, and I suspect lots of others at that.

i'd like to see this link become "smarter" about redirecting the user to the catalog or site page they just came from. i know that drupal has facility for this using the get/set_destination utility functions, but it's also been pointed out that a 'javascript.back(-1)' type of trick might work just as well. we're willing to put energy into this, but could use some feedback about how best to approach it.

what does the ubercart community think? ideas? directions? perhaps this is on somebody's "battle plans" and i haven't noticed? Eye-wink

cheers,
spidey

ps. congrats on the new release- we'll be upgrading SCW shortly, and very much looking forward to the beta series! Smiling

oslinux's picture
Offline
Joined: 09/06/2007
Juice: 461
Re: "smarter" continue shopping links?

you could somehow alter to drupal "destination?" module for the check out screen's page, or tell ubercart to go to a page X where you scan who you are wand what you have bought and then go on with drupal_goto function ...

theloonypin's picture
Offline
Joined: 06/09/2008
Juice: 34
smarter "continue shopping" links

Has anything further been done about this? I'd like my "continue shopping" button to take the user back to the page s/he was just at - so s/he can add the same product (in another color, probably), without all the navigation to get back to the product.

Thanks for any help,
amy

NaX
NaX's picture
Offline
Joined: 06/20/2008
Juice: 4
Re: "smarter" continue shopping links?

I solved this problem with a mini site module.

And then changed the Continue shopping link URL in (admin/store/settings/cart/edit) to continue-shopping.

Here is my mini module.
Hope that helps somebody else.

<?php
/**
* Implementation of hook_menu().
*/
function sitemodule_menu($may_cache) {
 
$items = array();
  if (
$may_cache) {
   
$items[] = array(
     
'path' => 'continue-shopping',
     
'title' => t('Continue shopping'),
     
'callback' => 'sitemodule_continue_shopping',
     
'access' => TRUE,
     
'type' => MENU_CALLBACK,
    );
  }
  return
$items;
}

function

sitemodule_continue_shopping() {
 
$path = 'catalog';
 
$items = uc_cart_get_contents(); 
  if (
is_array($items)) {
    if (
count($items)) {
      foreach (
$items as $id => $item) {           
        if (
$last === 0) {
         
$last = $item;
        }
        if (
$item->changed > $last->changed) {
         
$last = $item;
        }
      }
     
$path = 'node/'. $last->nid;
    }
  }
 
drupal_goto($path);
}
?>
fALk's picture
Offline
Joined: 06/07/2008
Juice: 26
Re: Re: "smarter" continue shopping links?

This only works if I set the

if ($may_cache) {

to

if (!$may_cache) {

since I have no clue what I am doing and purely logically reverse engeneering can you give me a clou on what the $may_cache does and if I shouldn´t be setting this to false?

(the site I am using this for is currently in production and not caching anything - might that be the problem?)

EDIT:::

Ok it works now thanks.

For anyone else who never made a mini module them-self - if you change something in the code (like the name of the callback function) you need to turn off and then re-enable the module. It is cached and makes absolutely sense to work that way (module is cached when you enable it).

::::

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
fALk wrote: For anyone else
fALk wrote:

For anyone else who never made a mini module them-self - if you change something in the code (like the name of the callback function) you need to turn off and then re-enable the module. It is cached and makes absolutely sense to work that way (module is cached when you enable it).

fwiw, your trouble is with the menu cache specifically. Static menu items should be cached to improve page serving time. However, when developing, instead of disabling/enabling the module, I just keep phpMyAdmin open and empty the cache_menu table when I make changes. An alternative is to use a block from the devel module to clear the cache.

NaX
NaX's picture
Offline
Joined: 06/20/2008
Juice: 4
Re: Re: Re: "smarter" continue shopping links?

When working with D5 and new menu items you can also just go to the menu page (admin/build/menu). This will rebuild the menu cache every time you go to that page.

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: "smarter" continue shopping links?

I never used the "continue shopping" in my previous project, but I'm on a project that will implement it and it's true, it's too limited ATM.

I have several ideas to make it Uber (so, it sounds good with ubercart ^^).

First things, The cart setting page should accept "previous" as a valid return url for that button. This would return the user to the page he was before pressing the "add to cart" button.

Another usefull option would be to add a textarea in which a store owner could write some custom HTML. If this textarea is not empty, when a user click on the continue shopping button, it popup the HTML set by the store owner in a nice javascript popup. This would allow to set up a panel of return links. This is IMHO and in the opinion of this great article about the continue shopping button, the best solution.

blindrocket's picture
Offline
Joined: 12/10/2008
Juice: 52
Re: Re: "smarter" continue shopping links?

I felt the same way when testing the continue shopping link out. I thought it was strange that it took users back to the catalog front rather than the category they came from.

aaronp@drupal.org's picture
Offline
Joined: 12/09/2008
Juice: 23
Re: "smarter" continue shopping links?

Still using D5, but this is a quick workaround to make the "Continue Shopping" link to a javascript that takes you back a single page.

Put the following in your theme's template.php file:

function phptemplate_uc_cart_view_form($form) {
  drupal_add_css(drupal_get_path('module', 'uc_cart') .'/uc_cart.css');

  $output = '<div id="cart-form-products">'
          . tapir_get_table('uc_cart_view_table', $form) .'</div>';

  if (($page = variable_get('uc_continue_shopping_url', '')) != '<none>') {
    if (variable_get('uc_continue_shopping_type', 'link') == 'link') {
      $output .= '<div id="cart-form-buttons"><div id="continue-shopping-link"><a href="javascript:history.go(-1)">Continue Shopping</a></div>'
               . drupal_render($form) .'</div>';
    }
    else {
      $button = drupal_render($form['continue_shopping']);
      $output .= '<div id="cart-form-buttons"><div id="update-checkout-buttons">'
               . drupal_render($form) .'</div><div id="continue-shopping-button">'
               . $button .'</div></div>';
    }
  }
  else {
    $output .= '<div id="cart-form-buttons">'. drupal_render($form) .'</div>';
  }

  return $output;
}

That'll override the function that outputs the link and replace it with a static link that says "Continue Shopping" that'll take you back one page. You'll lose the ability to change the text of the link from your checkout settings page (although I'm sure there's a workaround for that).

longwave's picture
Offline
Joined: 09/20/2008
Juice: 487
Re: "smarter" continue shopping links?

I added this jQuery snippet to my page template:

<script language="JavaScript">
$(function() {
  $('#edit-continue-shopping, #continue-shopping-link a').click(function() {
    window.history.go(-1);
    return false;
  });
});
</script>

This works for both the link and button variants.

--
These forums are for general support questions about Ubercart.
Bug reports and feature requests should be posted at http://drupal.org/project/issues/ubercart
Latest API documentation can be found at http://api.ubercart.me/

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: "smarter" continue shopping links?

Just wanted to say that per this issue on d.o I committed a fix that will send users back to the page they came from if they click the "Continue shopping" link or button after being redirected to the cart when adding a product to it. There are minor deficiencies in the implementation b/c of a problem I was having w/ the Forms API, but they aren't significant enough for me to pursue right now.

charitygrace's picture
Offline
Joined: 11/30/2010
Juice: 19
Thanks

so i'm in Drupal 6 and I was still having problems with the continue shopping link reverting to the default supplied address in the settings rather than the previous page. this js worked for me though i feel like this is an issue that should be solved in ubercart. thanks.

charity