14 replies [Last post]
fiasst's picture
Offline
Joined: 10/15/2007
Juice: 28
Was this information Helpful?

Could someone please show me how to get started editing the block/form?

I found: theme_uc_cart_block_content() which looks promising but I don't know how/what to rename it to in order to start editing. I've modified forms before and should be able to customize the block. I think I just need a head start.

I've opened my block.tpl and added:

<?php if ($block->module=='uc_cart' && $block->delta==0): #shopping cart block ?>
<div id="yourcart">
<div class="tl"></div>
<div class="tr"></div>
<div class="i">
<h3 class="ttl"><em>Your Cart</em></h3>
<?php print $block->content ?>
</div>
<div class="bl"></div>
<div class="br"></div>
</div>

The block won't use this template. But, thats the layout I'm looking to wrap the Cart Contents in.

I'd also like to modify the layout of the actual cart content table. Changing the '(View Cart)' and '(Checkout)' links if possible.

Finally, a quick question I've been meaning to ask. Why don't peaple use '#' comments in php? I only ever see '//' used in peoples code.

Thanks for your time,
Marc

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Re: Help themeing shopping cart block

Copy block.tpl.php to block-uc_cart.tpl.php and modify that new file - you won't need the check on the module name or delta.

Copy the theme function into template.php (Found in the same directory as block.tpl.php. If not, just create it.) Edit template.php and change the "theme_" in the function name to be "yourthemename_". Then modify the code in the function to emit the HTML you want. You might also need to override theme_uc_cart_block_title in this same manner.

<tr>.
fiasst's picture
Offline
Joined: 10/15/2007
Juice: 28
That's great!

Thankyou Smiling

kcoworks's picture
Offline
Joined: 11/22/2007
Juice: 103
Re: That's great!

If you want to go even more advanced, you copy the contents of theme_uc_cart_block_content() into your template.php, and name it phptemplate_uc_cart_block_content()
This function will be used instead if it exists, so you can modify everything there. (add code, remove code, etc...) until it looks the way you want... And above all, this is true for every theme_ function Eye-wink

fiasst's picture
Offline
Joined: 10/15/2007
Juice: 28
Re: Re: That's great!

Hey, back again.. I don't suppose there's a way to modify the full shopping cart is there?

function uc_cart_view_table($op, &$form)
from cart.module looks good but its not a theme_ function :\

I need to add a taxonomy->tid and field from each product in the cart. I could do with tweaking the layout abit too. One thing thats always frustrated me is the table row containing 'SubTotal'. It has no class or anything to latch onto in order to style it differently from the product rows above it.

Thanks for reading,
Marc

kcoworks's picture
Offline
Joined: 11/22/2007
Juice: 103
Re: Re: Re: That's great!

I used:
phptemplate_uc_cart_block_content() for the block on the left side
phptemplate_uc_cart_view_form() for the "view cart" page (original theme_ functions in uc_cart.module)
phptemplate_cart_review_table() for the review cart on the checkout page (original in uc_cart_checkout_pane.inc)

This pretty much did everything we wanted...

fiasst's picture
Offline
Joined: 10/15/2007
Juice: 28
thanks for your reply. I've

thanks for your reply.

I've re-looked through the uc_cart.module and the bit I need to theme lies under uc_cart_view_table($op, &$form). I've stuck a phptemplate_ in front of the function name but you won't be surprised to hear that didn't work.

Is this function simply out of bounds? I've got the same problem with the function uc_cart_add_item()

Thanks,
Marc

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: thanks for your reply. I've

Putting phptemplate_ in front of function names only works for functions that start with theme_. For other components, there are other safe ways to do it... can you point out what specifically you need to alter?

fiasst's picture
Offline
Joined: 10/15/2007
Juice: 28
Hi Ryan, Thanks for replying

Hi Ryan,
Thanks for replying but I think I've sorted it. I've fully modified the Cart Block and just skinned the Cart View table with CSS. It looks good enough :]

Your around a hell of a lot on these forums. Are you part of the dev team?

Marc

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
fiasst wrote:Your around a
fiasst wrote:

Your around a hell of a lot on these forums. Are you part of the dev team?

Yep, I'm around weekdays coding and trolling the forums and on the weekends when I've got nothing better to do. Eye-wink I'm heading up the project but by no means coding it all. The other developers are Lyle and Shawn and a host of community bug testers/ideamongers.

tonytosta's picture
Offline
Joined: 10/31/2008
Juice: 2
Re: fiasst wrote:Your around a

I am trying to change the redirect of the cart form (based on whether you're authenticated or not).

I have the following function in my template.php...

function phptemplate_uc_cart_view_form($form) {
global $user;

$output .= drupal_render($form);
return $output;
}

(i took out the actual changes I wanted to make to $form)

Overriding it the way I do, is resulting in loosing all the table markup. How can I can make changes to the $form object (or array) without affecting the table?

Thanks,
Tony

tracer's picture
Offline
Joined: 12/01/2008
Juice: 57
block content

Hi again Ryan.
What is the easiest way to do if i just want to show: "You have 0 products in your cart"
and the "view cart","checkout" links below, even when there are no products in the cart.
I've tried puting the code from the "function theme_uc_cart_block_content" file to
"template.php" and renaiming "function theme_uc_cart_block_content" to "function phptemplate_uc_cart_block_content"
I dont need all that code and i'm not that good with php yet Smiling
Can you just provide me with some code.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: block content

I don't have time to write up that code right now, but I will say that I just committed changes to make those theme funcs a looot easier to override. The changes are in our dev repository for now and will be pushed to d.o for the next beta release.

bighead's picture
Offline
Joined: 03/07/2009
Juice: 90
Re: Re: thanks for your reply. I've

Can you provide more information how to "re-theme" this part of uc_cart.module?

What I need?
I'm interested in the last row with "Subtotal". I need there Subtotal and Subtotal with VAT. So I'm using this modificated code (no Drupal-way) which work for me:
'#value' => '<strong>'. t('Subtotal:') .'</strong> '. uc_price($subtotal, $context). ' | <span>'. round(uc_currency_format($subtotal)*1.19) .' Kč s DPH</span> ',.
But I'm unable to put it in my template.php Sad. So I've to remember each time I update ubercart to renew this part Sad(.

Thank you for your advice.

larowlan's picture
Offline
Joined: 08/10/2008
Juice: 83
Re: Re: Re: thanks for your reply. I've

For those searching, you can override the contents of uc_cart_view_table in UC2/D6 with a custom module implementing
hook_tapir_table_header_alter (http://api.lullabot.com/hook_tapir_table_header_alter) and hook_tapir_table_alter (http://api.lullabot.com/hook_tapir_table_alter).