Woocommerce Items with No Price Display "Read More" - Need to Change button text

Hello,

I am trying to change the default button text for Products which have no price for my client. By default an item with no price will use the term"Read More". I would like it to say "Contact Us".

Here is a link to the test development site:
http://biobuddy.howitworks.com/shop/

Here is a screenshot of the buttons
ee2.JPG
Any help would be greatly appreciated.

Thank you,
Tia
tiabradford1984Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lucas BishopClick TrackerCommented:
Here is how you hide the "Read More" button.

Instead of hiding, you can alter the Read More text to say "Contact Us":
/*
* change read more buttons for out of stock items to read contact us
**/
if (!function_exists('woocommerce_template_loop_add_to_cart')) {
function woocommerce_template_loop_add_to_cart() {
global $product;
if (!$product->is_in_stock()) {
	echo '<a href="'.get_permalink().'" rel="nofollow" class="outstock_button">Contact Us</a>';
} 
else 
{ 
	woocommerce_get_template('loop/add-to-cart.php');
}
}
}

Open in new window

tiabradford1984Author Commented:
Hello,

Thank you for your reply.  I have pasted the code into my functions.php file, however the buttons still say Read More.  I cleared the cache in both my browser and Wordpress.

Tia
Lucas BishopClick TrackerCommented:
It could be that reference is only for an older version of Woo.

Another option that may be easier. Inside of add-to-cart.php ~ do you see any references to 'Read More' ?
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

tiabradford1984Author Commented:
I have the most recent version of Woocommerce installed.  This is the code I see listed for add-to-cart.php

<?php
/**
 * Loop Add to Cart
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.1.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

global $product;

echo apply_filters( 'woocommerce_loop_add_to_cart_link',
	sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button %s product_type_%s">%s</a>',
		esc_url( $product->add_to_cart_url() ),
		esc_attr( $product->id ),
		esc_attr( $product->get_sku() ),
		esc_attr( isset( $quantity ) ? $quantity : 1 ),
		$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
		esc_attr( $product->product_type ),
		esc_html( $product->add_to_cart_text() )
	),
$product );

Open in new window


I do not see "Read More" in the text.
tiabradford1984Author Commented:
I have the answer:

/*
 * Translate custom strings
 */

add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');

function translate_text($translated) {
    $translated = str_ireplace('Read More', 'Contact Us', $translated);
    return $translated;
}

Worked great.  Thank you for your help!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tiabradford1984Author Commented:
A tech assistant from woothemes worked with me to get the correct code. It is working very well.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.