Change the 'Quantity' label to 'Length' ?

Posts: 9
Joined: 01/10/2008

I have a client who wants to sell fabric by the metre, so the label 'Quantity' has to say 'Length in Metres' or something similar.

How can I do this?

I had a play with the locale module as I thought I might be able to 'translate' the word, but I can't figure it out. I'm also trying a cusomt module that uses hook_form_alter() but I can't figure out how to make that work either... any hints ont he best way to do this much appreciated!

Posts: 69
Joined: 06/01/2008

I think hook_form_alter() isn't what you want for this, but instead you want to customize your display template. If you create a node-products.tpl.php (if you don't have one already), then print_r($node) you can see all of the labels and fields on the page. I haven't done this for qty in particular, but for other items I've just started off my template by doing something like: $node>quantity[#label] = "Metres".

Note: this won't change the display in the actual cart, just on the product page. But personally (as a person who buys fabric online!) I wouldn't be weirded out by seeing "Qty: 3.5" in my cart.

Good luck!

Posts: 9
Joined: 01/10/2008

Thanks for your help leenwebb...

But there doesn't seem to be a node->quantity - maybe because the quantity is not set yet? I don't know, but the only reference in the print_r($node) output I can find to 'quantity' is in the add to cart value and the body text listings like this:

[body] => <div class="product_image"><a href="http://www.joysfabricwarehouse.com.au/files/01_0.jpg" title="" class="thickbox" rel="field_image_cache_0"><img src="http://www.mysite.com.au/files/imagecache/product/files/01_0.jpg" alt="" title=""  /></a><br /></div><div class="display_price">$5.99</div><p>A beautiful silver satin material.</p>
<div class="sell_price">Price: $5.99</div><div class="dimensions">Dimensions: 100cm × 180cm × 0cm</div><div class="add_to_cart"><form action="/node/1"  accept-charset="UTF-8" method="post" id="uc-product-add-to-cart-form-1">
<div><div class="form-item" id="edit-qty-wrapper">
<label for="edit-qty">Quantity: </label>

<input type="text" maxlength="6" name="qty" id="edit-qty"  size="5" value="1" class="form-text" />
</div>
<input type="submit" name="op" id="edit-submit-1" value="Add to cart"  class="form-submit node-add-to-cart" />
<input type="hidden" name="form_token" id="edit-uc-product-add-to-cart-form-1-form-token" value="89806e1ce27aeaac3a5d9a7f88cfce31"  />
<input type="hidden" name="form_id" id="edit-uc-product-add-to-cart-form-1" value="uc_product_add_to_cart_form_1"  />

</div></form>
</div>

The body value above must be put together somewhere else, probably by ubercart.

Also, it seems like I won't be able to use hook_form_alter because the forms all have different IDs.

This is much harder than I thought it would be...

Posts: 9
Joined: 01/10/2008

It's okay, I figured out how to do it using the locale module - seems a strange way to do it but it works well.

See http://drupal.org/node/24593

Posts: 34
Joined: 03/05/2008

You could also use the string overrides (http://drupal.org/project/stringoverrides) module.

Posts: 65
Joined: 03/19/2008

Turgrid wrote:
You could also use the string overrides (http://drupal.org/project/stringoverrides) module.

Thanks for the tip. It helped me solved my problem

I was aware of the locale module, but this seems an easier way to change the label of a string.