使用此代码,我可以更改结帐页面中的“您的订单”文本。但我需要更改我的购物车中的特定产品或虚拟产品是否在我的购物车中。
function custom_wc_translations($translated){
$text = array(
'Your order' => 'Your new phrase',
'any other string' => 'New string',
);
$translated = str_ireplace( array_keys($text), $text, $translated );
return $translated;
}
add_filter( 'gettext', 'custom_wc_translations', 20 );
我找到了此代码,但针对特定产品的不同位置。我怎样才能改变它?
add_filter( 'gettext', 'change_conditionally_order_review_heading_text', 10, 3 );
function change_conditionally_order_review_heading_text( $translated, $text, $domain ) {
if( $text === 'Your Order' && is_checkout() && ! is_wc_endpoint_url() ){
// HERE set the desired specific product ID
$targeted_product_id = 1122;
// Loop through cart items
foreach( WC()->cart->get_cart() as $cart_item ) {
if( $targeted_product_id == $cart_item['data']->get_id() )
return __( 'İletişim Bilgileri', $domain );
}
}
return $translated;
}
翻过高山走不出你