So far i've tried adding the following code to my functions.php with no luck:
<?php
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Sign-up Fee' :
$translated_text = __( 'bin deposit', 'woocommerce-subscriptions' );
break;
case 'Apply Coupon':
$translated_text = __( 'Enter Coupon', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
?>
<?php
function my_signupfee_string( $pricestring ) {
$newprice = str_replace( 'sign-up fee', 'bin deposit', $pricestring );
return $newprice;
}
add_filter( 'woocommerce_subscriptions_sign_up_fee', 'my_signupfee_string' );
?>
Neither of these functions are working and I am new to changing the internals of a plugin like Subscriptions.
You are using the wrong filter. The woocommerce_subscriptions_sign_up_fee
filter is for changing the actual number only. The gettext
filter is about translating strings.
Try this:
function change_subscription_product_string( $subscription_string, $product, $include )
{
if( $include['sign_up_fee'] ){
$subscription_string = str_replace('sign-up fee', 'something else', $subscription_string);
}
return $subscription_string;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'change_subscription_product_string', 10, 3 );
In my example this changed the string:
'$111.10 / month for 5 months with a 3-month free trial and a $22.00 sign-up fee'
into
'$111.10 / month for 5 months with a 3-month free trial and a $22.00 something else'
The woocommerce_subscriptions_product_price_string
filter is located in class-wc-subscriptions-product.php
in the function get_price_string()
.