Last active
October 18, 2021 03:30
-
-
Save yuliyang/0d304b6f619e5f5207e01687341038af to your computer and use it in GitHub Desktop.
[WooCommerce] Add Endpoint (YITH wishlist for example)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// add wishlist endpoint | |
function ching_add_wishlist_endpoint() { | |
add_rewrite_endpoint( 'wishlist', EP_ROOT | EP_PAGES ); | |
} | |
add_action( 'init', 'ching_add_wishlist_endpoint' ); | |
function ching_wishlist_query_vars( $vars ) { | |
$vars[] = 'wishlist'; | |
return $vars; | |
} | |
add_filter( 'query_vars', 'ching_wishlist_query_vars', 0 ); | |
// WooCommerce my account order | |
function ching_woo_my_account_order( $menu_links ) { | |
$menu_links = array( | |
// 'dashboard' => __( '控制台', 'woocommerce' ), | |
'orders' => __( '訂單', 'woocommerce' ), | |
'wishlist' => __( '收藏清單', 'woocommerce' ), | |
'edit-address' => __( '地址', 'woocommerce' ), | |
'edit-account' => __( '帳戶詳細資訊', 'woocommerce' ), | |
'customer-logout' => __( '登出', 'woocommerce' ), | |
); | |
unset( $menu_links['kol'] ); | |
return $menu_links; | |
} | |
add_filter ( 'woocommerce_account_menu_items', 'ching_woo_my_account_order', 99 ); | |
function ching_wishlist_content() { | |
echo do_shortcode( '[yith_wcwl_wishlist]' ); | |
} | |
add_action( 'woocommerce_account_wishlist_endpoint', 'ching_wishlist_content' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment