Change “Billing Details” text to “Shipping Details” on Woocommerce checkout page

 ̄綄美尐妖づ 提交于 2019-11-27 06:32:51

问题


I currently have a bit of code in my child theme's functions.php file which is supposed to change "Billing Details" to say "Shipping Details" on my Woocommerce checkout page.

However, when I updated to Woocommerce 3.0, the code snippet stopped working. Below is the code I was using.

function wc_billing_field_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing Details' :
$translated_text = __( 'Shipping Details', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );

I would really like a code snippet that works with Woocommerce 3.0.


回答1:


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




回答2:


To override woocommerce views, you need to copy the required template files from woocommerce/templates to your theme directory. In this case copy woocommerce/templates/checkout/form_billing.php to your theme folder as woocommerce/checkout/form_billing.php and edit the following code around line 27.

<?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>

    <h3><?php _e( 'Billing &amp; Shipping', 'woocommerce' ); ?></h3>

<?php else : ?>

    <h3><?php _e( 'Billing details', 'woocommerce' ); ?></h3>

<?php endif; ?>


来源:https://stackoverflow.com/questions/44419189/change-billing-details-text-to-shipping-details-on-woocommerce-checkout-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!