Maybe I'm completely ignorant, but I've searched the forum and the issues and can't come up with anything discussing this except for a 2006 post. Is there an admin option to modify the empty cart message that a user sees when his/her cart is empty? I've looked all around and cannot find it. It would make sense (to me) for it to be in the cart options admin screen.

I used the devel module to locate the source of the code, and it's pointing me to use the theme_uc_empty_cart template function in a template.php file, however this seems very cumbersome to simply change the verbiage of a text based message.

Any help would be greatly appreciated. Thanks.

CommentFileSizeAuthor
#1 uc_emptycartlink.zip1.64 KBDurrok
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Durrok’s picture

Issue tags: +Ubercart, +cart, +cart links
FileSize
1.64 KB

Hey apt94jesse, I had the exact same issue. I created a module that adds the link back to the empty cart page. I have tested it with the latest version of Ubercart and it works great. Sadly I was denied access to upload the module but hopefully someone can get some use out of it.

Let me know if you have any problems, I've tested it on two Ubercart installs so far and have had no issues.

TR’s picture

Status: Active » Closed (won't fix)

@apt94jesse: I don't see it as "cumbersome" to create a one line .tpl.php file to display whatever markup you like as an empty cart message. This is just normal, typical Drupal theming, and gives you great flexibility to do things like add graphics and links (as in #1) that you wouldn't be able to do if this were just an admin-defined string. Plus, it avoids the major issue with admin-defined strings in that they are a pain to translate - requires the i18n module plus lots of work to go through and translate each admin-defined string. A string wrapped in t() in a theme function, however, is trivial to translate.

@Durrok: I don't see how your code solves anything - in fact it makes things worse because you no longer use a theme function so now the admin can't override the message format that you chose in your module. If instead you used a .tpl.php to override theme_uc_empty_cart() then you wouldn't need a module and it would be much easier to change.

I looked at your CVS request issue #771412: Durrok [durrok] and I completely agree with what sun was saying. I think he gave a good explanation of why the application was denied, and what the standards are for adding a module to the drupal.org CVS.

Durrok’s picture

TR - I went about fixing the issue the wrong way I suppose. I'm still new and attempting to help. I want to add this feature into Ubercart, not just create a .tpl.php file that may be overwritten when I update or cause problems down the line. I would be willing to turn my module into a patch for this instead so that you there would simply be a checkbox on the cart settings page to enable this option.

If I take the time to create the patch would be willing to look over it and if it is up to snuff integrate it in?

EDIT: Also I apologize apt94jesse, I misread your post. My module adds a continue shopping link to an empty cart page. However it is trivial to include that with the patch I will be creating so I will add this as well.

hixster’s picture

I'm also after adding a link to this page.

@TR , could you elaborate on what one line content would need to be created for the empty cart page? It seems the page is generated by theme function theme_uc_empty_cart, so I'm assuming that the template file would need some logic to determine if the cart is empty of not?

hixster’s picture

o.k , so it seems the easiest way to do this is the override the theme_uc_empty_cart function by adding the overridden function to your template.php file in your themes directory like so:

function phptemplate_uc_empty_cart() {
  return '<p>'. t('What ever empty cart message you want here .') .'</p>';
}

Remembering to change the function name from :

theme_uc_empty_cart()

to:

phptemplate_uc_empty_cart()
fineartist99’s picture

I added

function phptemplate_uc_empty_cart() {
  return '<p>'. t('There are no items in your cart. Visit the <a href="linkGoesHere">shop</a> to add items to your cart.') .'</p>';
}

to my themes template.php document and nothing get's changed when the cart is empty. I cleared my cache as well and still no change. What file do I need to edit and what do I need to put in it to change the default "There are no products in your shopping cart." message. Thanks in advance.

fineartist99’s picture

Issue summary: View changes

In the "uc_cart.theme.inc" within modules > ubercart > uc_cart I altered this line

function theme_uc_empty_cart() {
  return '<p class="uc-cart-empty">' . t('There are no products in your shopping cart.') . '</p>';
}

To whatever I wanted and the empty cart message was able to get changed. Simplest solution.