Ive been trying (and failing) to get discounts to show in the shopping cart block here;
http://drupal.org/node/507820
Although im doing it wrong, it seems their aren't too many steps to achieve this. Could someone write a how to theming guide for this?
Id be happy to rewrite it, add screen shots etc, but at the moment I cant figure how to get this to work.
Thanks
Comments
Comment #1
gillisig commentedI was dealing with the same thing.. and after a few hours i figured it out.. Im gonna try to write it down now in a simple manner so you can possibly write a tutorial or something.
Be aware that this is absolutely the first time I try to describe something like this or contribute in anyway.. i have only been using drupal for 2 weeks or so.
Basicly I added the following code to /modules/ubercart/uc_cart/uc_cart.module at line 688
(right after "function theme_uc_cart_block_content($help_text, $items, $item_count, $item_text, $total, $summary_links) {" and what follows that line.. so actually right after after "return $output;")
Then at the bottom of my template.php file (which is in my case located at /themes/THEME_NAME/template.php) I added the next code, be aware that where i write THEME_NAME you will have to replace it with your theme name
I hope this works and is more clear than the nonsense where you had to go back and forth in the other forum to get the info you needed and puzzle it together like I did, the reason the codes didnt work was that somethings needed to be changed slightly but with these codes all you should have to do is paste them at the correct place and rename the beginning of the second code with your theme name.
I hope this helps someone
Regards,
Gilli Hustad
P.S. Thanks should go to a_lawry for figuring all this out and writing this code, I simply took it and tried to make it more clear and simple.
Comment #2
abemonkey commentedThank YOU!!! I couldn't get this figured out before I got these instructions. I have one issue. The discount amount isn't showing after the "Total Discounts:" line. I am running version 6.x-2.2. What version are you running? Do you have any ideas of what I might need to change. The only other variable that I can think of is that some of my products with discounts have attributes. Thanks for any feedback! Also I'm running drupal 6.19 not 6.20 as I had a major issue when I attempted to update to 6.20 and had to restore from my backup to get back up and running again. Don't think that would make any difference in this case though.
Comment #3
gillisig commentedIm running version 6.x-2.4 but actually im encountering that error also.. I just chose to ignore it since i mostly wanted the correct total amount to show up, but I am pretty sure that it has something to do with the following line since I removed it from the original code because it was keeping the code from working for some reason.
"$subtotal += get_discounts_taxed_price($item->price, $item) * $item->qty;"
But since theres only 2 weeks since I started using Drupal and php I am not gonna try to crack this problem for now :)
Regards,
Gilli Hustad
Comment #4
abemonkey commentedI'm better at JavaScript than PHP so I guess I'll just solve this that way but I'd like to fix the PHP code to do what I want if anyone figures this out let me know! Thanks!
Comment #5
abemonkey commentedFor those of you who want the total discount amounts to show in the block I used the jquery calculation plugin which can be found here. Just add the plugin to your theme's .info file and use this code:
Comment #6
jdln commentedHi abemonkey, I like your thinking, ive been struggling with this issue for ages and jquery is often an easier way to go.
The calculation plug in looks quite simple but where do you get the data to use for the sum? My site has a 10% discount for orders over a certain amount. Where do I grab this 10% from and how can I only have the jquery run if the order is large enough to get a discount?
Thanks
Comment #7
mttjn commentedVery nice - thanks so much for writing that up.
Couple of problems: (1) some missing brackets in the if() statement (2) did you try adding products (and so qualifying for a discount) and then removing all products? You may find your shopping cart block disappears! These are fixed with the code below. (Note: this post only refers to the code that goes in the template.tpl.php file; the code for uc_cart.module is the same)
One thing I would like to know: does anyone know how to write the code for uc_cart.module as a custom module, rather than adding it directly to uc_cart.module? Thanks.
Comment #8
mttjn commentedThe solution I've just posted works... but agreed: jQuery would be a whole lot easier! We just need to pass the discounted total variable from uc_discounts.module to the theme, pick it with jQuery, and then switch the figure that's showing. Im sure this can be done, but im not sure how... if anyone can shine a light on this(?), would appreciate it.
Comment #9
nitebreedSubscribing