12 replies [Last post]
JustJamesAus@drupal.org's picture
Offline
Joined: 01/10/2008
Juice: 22
Was this information Helpful?

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!

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Change the 'Quantity' label to 'Length' ?

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!

JustJamesAus@drupal.org's picture
Offline
Joined: 01/10/2008
Juice: 22
Good suggestion but still doesn't work

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

JustJamesAus@drupal.org's picture
Offline
Joined: 01/10/2008
Juice: 22
locale module

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

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: locale module

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

venkat-rk@drupal.org's picture
Offline
Joined: 03/19/2008
Juice: 205
Turgrid wrote:You could also
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.

glennnz's picture
Offline
Joined: 01/20/2009
Juice: 451
String Overrides

Hi

I tried changing SKU to a new label using the String Overrides module, but it doesn't work. My product page still shows SKU.

Any ideas?

Glenn

BrandTim@drupal.org's picture
Offline
Joined: 09/22/2009
Juice: 2
It's "SKU: @sku"

It took me 10 minutes to figure this out. I had to look in the code for the exact string I need to override. Stringoverrides doesn't do partial matches.

Using stringoverrides, I added these two overrides:
SKU: @sku --> Model: @sku
SKU --> Model

The first one is the View product page, the second is the Edit product page.

BrandTim

Ms_Kristina's picture
Offline
Joined: 04/05/2009
Juice: 65
Hi. I need to change the

Hi.
I need to change the labels for price, and list price.

list price = shack price
price = sale price

I've installed the stringoverrides module, and tried just entering:
List Price --> Shack Price
Price --> Sale Price

This didn't work. I was hoping someone would know the correct text to enter for the original field.

vlzvl's picture
Offline
Joined: 12/09/2009
Juice: 9
Re: Hi. I need to change the

You can do it with string overrides but there is a large possibility
that a string overrides string change will be not applied in your page.
The best way i found is this:

1) Go to your ubercart module's folder in drupal
2) Use the "Search" OS-dependent function for (exact) strings like "List Price" in the whole folder
3) Open one by one the files that contain your "List Price" string
4) if (critical) the "List Price" is found on the file in the form of
t("List Price") then you CAN actually change it with string overrides, otherwise you must find the correct form.

splash112@drupal.org's picture
Offline
Joined: 04/01/2008
Juice: 413
Re: Re: Hi. I need to change the

You should be able to do this safest with hook_price_alter....

vlzvl's picture
Offline
Joined: 12/09/2009
Juice: 9
yes thats right, the "best"

yes thats right,
the "best" way described above is for the nice String Overrides module Smiling
But, honestly, i think the best way is to just manipulate the current "language" (which is english) with "Locale" module. The steps are:

- Go /admin/build/translate/search
- Enter "Quantity" in "String contains:" (you might want to select your
"Language" first in case of multi-lingual) + click "Search"
- In normal situation an entry will pop-up. Click "edit" in "Operations"
- Add your "Quantity" version in the sizeable textarea + click "Save
Translations"

maslachak@gmail.com's picture
Offline
Joined: 02/13/2012
Juice: 6
There is no need to use

There is no need to use translation. Here is the simple module:

<?php
/*
* Implementation of hook_form_alter
* */
function YOURMODULENAME_form_alter(&$form, &$form_state, $form_id){
    switch(
$form_id){
     
        case
stristr($form_id, 'uc_product_add_to_cart_form'):
           
$form['qty']['#title'] = 'Length in Metres';
         
        
        break;
    }
}

?>