我想在支付方法頁面添加一個鏈接,以便登錄用戶可以輕松更改方法。或者加一個。
我已經設定了正確的鉤子,我正在做一些其他的事情,但不知道如何繼續?
add_filter('woocommerce_account_menu_items', array($this, 'shorty_account_menu_items'), 10, 1);
function shorty_account_menu_items($items) {
$items['edit-account'] = 'Settings';
$items['orders'] = 'My History';
unset($items['dashboard']);
return $items;
}
uj5u.com熱心網友回復:
您使用的過濾器鉤子是正確的。要顯示支付方式頁面的鏈接,請將端點推入 $items 陣列并輸出整個陣列。
用法:
add_filter('woocommerce_account_menu_items', 'shorty_account_menu_items');
function shorty_account_menu_items($items) {
$items['payment-methods']='Payment Methods';
return $items;
}
您還可以使用以下代碼段將支付方式鏈接移動到注銷鏈接上方:
add_filter('woocommerce_account_menu_items', function($items) {
$logout = $items['customer-logout'];
unset($items['customer-logout']);
$items['payment-methods'] = "Payment Methods";
$items['customer-logout'] = $logout;
return $items;
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/324552.html
標籤:WordPress的 求购
