Hi every one let me try to explain this.
PLEASE NOTE: i use the woo commerce block plugin (for the cart and checkout pages to replace the original shortcode)
i want to change my instances where the word shipping is to change to the word Delivery
i use this hook in my functions.php and it did change the one word to delivery so that worked
add_filter('woocommerce_shipping_package_name', 'change_shipping_text_to_delivery', 20, 3 );
function change_shipping_text_to_delivery( $sprintf, $i, $package ) {
$sprintf = sprintf( _nx( 'Delivery', 'Delivery %d', ( $i + 1 ), 'delivery packages', 'woocommerce' ), ( $i + 1 ) );
return $sprintf;
}
as you can see on the cart page it only changed the one word not the other two
okay then when i go to my PROCEED TO CHECKOUT AND GO TO THE PAGE
THIS IS MY CHECKOUT PAGE(also UNCHAGED)
i have insert this in my php functions did not work
/*
* Change the string "Shipping" to "Delivery" on Order Received page.
*/
add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');
function translate_reply($translated) {
$translated = str_ireplace('Shipping', 'Delivery', $translated);
return $translated;
}
i also tried going to my plugin folder
i did get some code in there where i replaced the strings shipping to delviery and it did not do anything !
return (
<FormStep
id="shipping-fields"
disabled={ checkoutIsProcessing }
className="wc-block-checkout__shipping-fields"
title={ __( 'Shipping address', 'woo-gutenberg-products-block' ) }
description={ __(
'Enter the physical address where you want us to deliver your order.',
'woo-gutenberg-products-block'
) }
>
{ children }
<CheckboxControl
className="wc-block-checkout__use-address-for-billing"
label={ __(
'Use same address for billing',
'woo-gutenberg-products-block'
) }
checked={ shippingAsBilling }
onChange={ ( isChecked ) => setShippingAsBilling( isChecked ) }
/>
</FormStep>
Please can someone help me i just want to change those words to DELIVERY
i did come right with this code but i had to remove the woo commerce gutenberg block i reverted back to the default woo commerce shortcodes
add_filter('woocommerce_shipping_package_name', 'change_shipping_text_to_delivery', 20, 3 );
function change_shipping_text_to_delivery( $sprintf, $i, $package ) {
$sprintf = sprintf( _nx( 'Delivery', 'Delivery %d', ( $i + 1 ), 'delivery packages', 'woocommerce' ), ( $i + 1 ) );
return $sprintf;
}function shipchange( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Ship to a different address?' :
$translated_text = __( 'Deliver to a different address?', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter('gettext', 'shipchange', 20, 3);
add_filter( 'woocommerce_shipping_package_name' , 'woocommerce_replace_text_shipping_to_delivery', 10, 3);
/**
*
* Function to replace shipping text to delivery text
*
* @param $package_name
* @param $i
* @param $package
*
* @return string
*/
function woocommerce_replace_text_shipping_to_delivery($package_name, $i, $package){
return sprintf( _nx( 'Delivery', 'Delivery %d', ( $i + 1 ), 'shipping packages', 'put-here-you-domain-i18n' ), ( $i + 1 ) );
}
/*
* Change the string "Shipping" to "Delivery" on Order Received page.
*/
add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');
function translate_reply($translated) {
$translated = str_ireplace('Shipping', 'Delivery', $translated);
return $translated;
}