-
-
Save dexit/cfcd639d9b7e1906f1423b43c412f701 to your computer and use it in GitHub Desktop.
Custom My Account Additional Tab Woocommerce
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 | |
/** | |
*Plugin Name: Myaccount Additional Tab | |
*Plugin URI: coming soon | |
*Description: Just another myaccount plugin. Simple but flexible. | |
*Author: Narendra Singh | |
*Author URI: https://roimantra.com/ | |
*Text Domain: MyAccount Tab | |
*Domain Path: /languages/ | |
*Version: 4.8 | |
* @snippet WooCommerce Add New Tab @ My Account | |
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 | |
* @sourcecode https://businessbloomer.com/?p=21253 | |
* @credits https://github.com/woothemes/woocommerce/wiki/2.6-Tabbed-My-Account-page | |
* @author Rodolfo Melogli | |
* @testedwith WooCommerce 2.6.7 | |
*/ | |
// ------------------ | |
// 1. Register new endpoint to use for My Account page | |
// Note: Resave Permalinks or it will give 404 error | |
function bbloomer_add_payment_information_endpoint() { | |
add_rewrite_endpoint( 'payment-information', EP_ROOT | EP_PAGES ); | |
} | |
add_action( 'init', 'bbloomer_add_payment_information_endpoint' ); | |
// ------------------ | |
// 2. Add new query var | |
function bbloomer_payment_information_query_vars( $vars ) { | |
$vars[] = 'payment-information'; | |
return $vars; | |
} | |
add_filter( 'query_vars', 'bbloomer_payment_information_query_vars', 0 ); | |
// ------------------ | |
// 3. Insert the new endpoint into the My Account menu | |
function bbloomer_add_payment_information_link_my_account( $items ) { | |
$items['payment-information'] = 'Payment Information'; | |
return $items; | |
} | |
add_filter( 'woocommerce_account_menu_items', 'bbloomer_add_payment_information_link_my_account' ); | |
// ------------------ | |
// 4. Add content to the new endpoint | |
function bbloomer_payment_information_content() { | |
echo '<h3>Premium WooCommerce Support</h3><p>Welcome to the WooCommerce support area. As a premium customer, you can submit a ticket should you have any WooCommerce issues with your website, snippets or customization. <i>Please contact your theme/plugin developer for theme/plugin-related support.</i></p>'; | |
echo do_shortcode( ' /* your shortcode here */ ' ); | |
} | |
add_action( 'woocommerce_account_payment-information_endpoint', 'bbloomer_payment_information_content' ); | |
function custom_endpoint_acct_menu_item( $items ) { | |
$logout = $items['customer-logout']; | |
unset( $items['customer-logout'] ); | |
$items['payment-information'] = __( 'Payment Information', 'woocommerce' ); // replace videos with your endpoint name | |
$items['customer-logout'] = $logout; | |
return $items; | |
} | |
add_filter( 'woocommerce_account_menu_items', 'custom_endpoint_acct_menu_item' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment