Is it possible to Change the "add to cart" button text to "Register" depending on the product type (class). I'd like it to continue to say "Add to cart" in the part of my store for standard products, but say "register" if someone is registering for an offline class or conference. I noticed the ubercart setting where you can change the text of the button globally, but was wondering how to override this based on product type or some other differentiator. Any advice is appreciated.
Cheers
Comments
Comment #1
krisgraham commentedYou could use hook_form_alter to change the title of the form button with a module. Though if uc_node_checkout is already doing this, you may want to name your module something alphabetically later than this. I name modules like these starting with a "z" because in the past I've had issues with the order in which forms getting processed by different modules and I believe it does something alphabetically.
Comment #2
walden commentedHow would I determine if the text needs to be changed or not? For example, how would the module know if the page was a "class" product or a regular product?
Comment #3
krisgraham commentedIf the page is a class the url would be something like node/add/[classname], if it's a product, then it may just be node/[productname], if that's the case for your site, you could do an arg check, something like
if ((arg(0) != 'node') && (arg(1) != 'add')){ //theme button for products, but not product classes }
Hope that helps
Comment #4
josi123 commentedI need to do the same thing. If you have implemented that, could you please share the code? Thanks.
Comment #5
wesjones commentedI am trying to do the same thing. Please share code. Thanks
Comment #6
walden commentedStill working on it, will re post when I've found a solution.
Comment #7
walden commentedI've found an alternative solution to this problem, which is very quick to implement. It is pretty easy to use an image instead of a button for the add to cart behavior. I created a different class (new content type) for the product which needed the button changed. Then I made a node-yourclassnamehere.tpl.php file for that content type and added a new style(cart-register below) I could hook onto to uniquely identify that button.
Here's the CSS required to override the button (courtesy ubercart.org)
The one downside to this solution is that when you hover over the button, your cursor doesn't change as it normally would. As a plus, you can have awesome looking add to cart buttons.
Comment #8
rszrama commentedYou actually don't need custom code for this any more. I wrote a module called UC Add to Cart Tweaks that adds a product feature you can use to change the add to cart button text. This module lets you assign the product feature to every product of a given class by default if you configure and use a product class for all the products you want to use the "Register" language.
Comment #9
rszrama commentedMeh, spoke to soon. I should've checked first. This is a feature of the UC Variable Price module that I wrote at the same time. However, looking through the code, I see that I added a setting for it but never implemented the feature. I think I'll consider moving it from UC Variable Price to UC Add to Cart Tweaks and actually implementing it or something. :-/
Comment #10
rszrama commentedComment #11
ehtisham commentedThanks for the module rszrama. Here is the correct URL:
http://drupal.org/project/uc_atctweaks
Comment #13
IFL Todd commentedRe-opening. I do see this in the current version of uc variable price, but not in the current version of uc add to cart tweaks. The Add to cart form element titles ui in uc variable price have no affect.
Please advise.
Thanks
Comment #14
hixster commenteduc variable price button tweaks do work BUT you need to enable the button ' Check this box to add a default product feature to every product of this class using these settings.' , so that module does not allow the button text to be over-ridden without making the product variable price , which is undesirable