更改 WooCommerce 订单支付页面标题

问题描述

试图更改“支付订单”页面/“客户支付页面”的标题

fetch(url,{ method: 'GET',headers: { 'Content-Type': 'text/xml','Accept-Encoding': 'gzip,deflate',},} ) .then((response) => { console.log(response); response.text(); }) .then((data) => { const parser = new DOMParser(); const xml = parser.parseFromString(data,'text/xml'); console.log(xml); }) .catch(console.error);

以下暂时无法使用,修改了感谢页面标题

https://url.com/checkout/order-pay/753/?pay_for_order=true&key=wc_order_xxxxxx

解决方法

更新

您可以使用以下内容更改“Pay for order”页面标题:

add_filter( 'the_title','change_pay_for_order_title' );
function change_pay_for_order_title( $title ) {
    if ( is_wc_endpoint_url( 'order-pay' ) ) {
        return __('Checkout','woocommerce');
    }
    return $title;
}

或者以下基于“order-pay”端点的代码(但改变了面包屑)

add_filter( 'woocommerce_endpoint_order-pay_title','change_checkout_order_pay_title' );
function change_checkout_order_pay_title( $title ) {
    return __( "Checkout","woocommerce" );
}

代码位于活动子主题(或活动主题)的functions.php 文件中。经测试有效。

相关:Set My Account custom items endpoints titles in WooCommerce