Hey,

I'm working on a new site design and I noticed there is no class for the paragraph tag that displays when a cart is empty, nor is there a body class ("cart-empty" or something would've been good) so I can't easily tell the CSS how to display the text. Note, that I don't want to re-theme the empty cart function - I'd like to do this purely in CSS.

The attached patch adds a class to both the div and the paragraph text that are rendered in theme_uc_empty_cart() and theme_uc_cart_block_items(). Please add this (it's a tiny patch) as a designer shouldn't have to write a theme override function for this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

torgosPizza’s picture

Title: Provide CSS class for empty text. Patch included » Provide CSS classes for empty cart text. Patch included

Fixing title.

torgosPizza’s picture

Title: Provide CSS classes for empty cart text. Patch included » Provide CSS classes for empty cart text (and call theme function). Patch included
Status: Active » Needs review
FileSize
396 bytes

Here's an alternative way to do it. If you insist that this modification be done through theme overrides, then we should make sure that the theme('uc_cart_empty) function is actually called on the /cart page if the cart is empty.

Attached patch adds that.

EDIT: Note this patch will cause Hunk #1 to fail in my previous patch.

TR’s picture

FileSize
738 bytes

@torgosPizza: I made a new patch which combines both of yours - it calls the theme function as in the OP and it adds the CSS classes as in #2. I changes the underscores to hyphens in the CSS class names to conform with Drupal conventions. Let me know if this works for you.

TR’s picture

Issue tags: +Ubercart theme layer

Tagging.

torgosPizza’s picture

I just realized a mistake I made in these patches - the 2nd one patches the "block" display and not the cart page. I'm not sure why I didn't make that distinction earlier. But I would imagine you don't want the block to display the entire same message that the cart page would.

For example the /cart page, when empty, I have themed to show some "suggestions" which wouldn't work the same way in a block.

So, I think the only part this patch needs to keep is where it adds the empty classes to the theme function as a sane default (otherwise there's no easy way to style it (since using .page-cart would affect both full and empty carts).

i can re-roll this to make more sense based on this, if you want.

longwave’s picture

Status: Needs review » Needs work

Agreed that the "empty cart" block message should stay separate and more simple than the page.

Also I think you only need a class on the <div> tag - if you want to target the <p> with CSS you can do that anyway, and if you're overriding the theme function then you can do what you like :)

torgosPizza’s picture

Good point. Yeah I'm not sure what I was thinking when I patched that. Obviously I was a little confused. But the overall idea is solid ;) I'll try to roll a new patch when I can.

longwave’s picture

Status: Fixed » Closed (fixed)
Issue tags: -Ubercart theme layer

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