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

krisgraham’s picture

You 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.

walden’s picture

How 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?

krisgraham’s picture

If 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

josi123’s picture

I need to do the same thing. If you have implemented that, could you please share the code? Thanks.

wesjones’s picture

I am trying to do the same thing. Please share code. Thanks

walden’s picture

Still working on it, will re post when I've found a solution.

walden’s picture

I'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)

 #cart-register .node-add-to-cart{
background:transparent url(register.png) no-repeat; /* button image */
border:none; /* get rid of button border */
height:36px; /* button height */
width:110px; /* button width */
/* all below just hides the button text */
font-size: 0px;
display:block;
line-height: 0px;
text-indent: -999px;
}

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.

rszrama’s picture

Status: Active » Fixed

You 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.

rszrama’s picture

Title: Possible to change "add to cart" to "register" in select cases » Allow add to cart button text to be edited, possibly move to UC ATC Tweaks
Project: UC Node Checkout » UC Variable Price
Version: 6.x-2.0-beta3 » 6.x-1.x-dev
Component: Miscellaneous » Code
Category: support » bug
Status: Fixed » Active

Meh, 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. :-/

rszrama’s picture

Status: Active » Fixed
ehtisham’s picture

Thanks for the module rszrama. Here is the correct URL:
http://drupal.org/project/uc_atctweaks

Status: Fixed » Closed (fixed)

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

IFL Todd’s picture

Status: Closed (fixed) » Active

Re-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

hixster’s picture

uc 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