Change Billing Details text to Shipping Details on WooCommerce checkout page
function wc_billing_field_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing details' :
$translated_text = __( 'Billing Info', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );
Tested OK with WooCommerce 3.0.6
How to change Billing details title on WooCommerce checkout page with a hook
Change switch ( $translated_text ) {
with switch ( $text ) {
in your code.
This is because $text
contains the original (undertranslated) text while $translated_text
contains... the name of the variable already indicates it.
Or use
function filter_gettext( $translated, $original_text, $domain ) {
// Is admin
if ( is_admin() ) return $translated;
// No match
if ( $original_text != 'Billing details' ) return $translated;
// Match
$translated = __( 'Billing Info', $domain );
return $translated;
}
add_filter( 'gettext', 'filter_gettext', 10, 3 );
Change Checkout Billing Details text for a specific product in Woocommerce
To change a translatable text in checkout page when there is a specific item in cart, use the following:
add_filter( 'gettext', 'change_conditionally_checkout_heading_text', 10, 3 );
function change_conditionally_checkout_heading_text( $translated, $text, $domain ) {
if( $text === 'Billing details' && is_checkout() && ! is_wc_endpoint_url() ){
// HERE set the desired specific product ID
$targeted_product_id = 1980;
// Loop through cart items
foreach( WC()->cart->get_cart() as $cart_item ) {
if( $targeted_product_id == $cart_item['data']->get_id() ) {
return __( 'Your Details', $domain );
break; // Stop the loop
}
}
}
return $translated;
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
Note: In Woocommerce checkout the text to change is "Billing details" without a capital in "Details"
How to change Billing details title to a title with html tags on WooCommerce checkout page with a hook
add_filter('esc_html', 'billing_details_title', 10, 2);
function billing_details_title($safe_text, $text) {
if ('Billing details' === $text && is_checkout()) {
return '<div>123</div>';
}
return $safe_text;
}
Change wording on Woocommerce Checkout page
It would be better to override the checkout/form-checkout.php and checkout/review-order.php
Or You can use gettext
filter .
This filter hook is applied to the translated text by the
internationalization functions (__(), _e(), etc.)
function th_wc_order_review_strings( $translated_text, $text, $domain ) {
if(is_checkout()){
switch ($translated_text) {
case 'Billing details' :
$translated_text = __( 'Billing Info', 'woocommerce' );
break;
case 'Additional information':
$translated_text = __('New Field Name', 'woocommerce');
break;
case 'Your order':
$translated_text = __('My Order', 'woocommerce');
break;
case 'Product':
$translated_text = __('Your Product', 'woocommerce');
break;
}
}
return $translated_text;
}
add_filter( 'gettext', 'th_wc_order_review_strings', 20, 3 );
Try changing the above code to your requirements.
How to change text of shipping address and billing address on order recieved page of woocommerce checkout?
You can change display according to your need from your theme.
See woocommerce template structure...
Follow instructions in links.
Find order/order-details.php
file and edit this file via your theme...
This will make easy to overwrite woo-commerce code and display...
Change texts Billing and Shipping in Woocommerce admin order pages
You can use the WordPress gettext
hook as follows (targeting non translated original texts):
add_filter( 'gettext', 'change_admin_order_edit_pages_texts', 10, 3 );
function change_admin_order_edit_pages_texts( $translated_text, $text, $domain ) {
global $pagenow, $post_type;
if( in_array($pagenow, ['post.php', 'post-new.php']) && 'shop_order' === $post_type && is_admin() ) {
if( 'Billing' === $text ) {
$translated_text = __('Test 1', $domain); // <== Here the replacement txt
}
if( 'Shipping' === $text ) {
$translated_text = __('Test 2', $domain); // <== Here the replacement txt
}
}
return $translated_text;
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
How to conditionally change WooCommerce billing address title if no separate shipping address is entered
My Account
https://github.com/woocommerce/woocommerce/blob/master/templates/order/order-details-customer.php
- This template can be overridden by copying it to yourtheme/woocommerce/order/order-details-customer.php.
Replace (line: 31)
<h2 class="woocommerce-column__title"><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>
With
<h2 class="woocommerce-column__title">
<?php
// Show shipping = false
if ( !$show_shipping ) {
$title = 'Billing & Shipping address';
} else {
$title = 'Billing address';
}
esc_html_e( $title, 'woocommerce' );
?>
</h2>
https://github.com/woocommerce/woocommerce/blob/master/templates/emails/email-addresses.php
- This template can be overridden by copying it to yourtheme/woocommerce/emails/email-addresses.php.
Replace (line: 29)
<h2><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>
With
<h2>
<?php
// Billing_address
if ( !$order->needs_shipping_address() ) {
$title = 'Billing & Shipping address';
} else {
$title = 'Billing address';
}
esc_html_e( $title, 'woocommerce' );
?>
</h2>
Related Topics
Call to Undefined Function Oci_Connect, PHP_Oci8_12C.Dll, Windows 8.1, PHP5.6.6
Tcpdf and Insert an Image Base64 Encoded
How to Access MySQLi Connection in Another Class on Another Page
PHP Datetime::Createfromformat in 5.2
How to Create a New Page in Prestashop Admin Panel
How to Start a Windows Gui Program Using PHP
Import Class Conditionally with the Keyword 'Use'
How to Set Document Root to Be a Subdirectory Using .Htaccess and Not Vhost
Creating a Secure File Hosting Server for PDFs
Get Values Stdclass Object PHP
From the String Name of a Class, How to Get a Static Variable