/* Code to add in sidebar where you want to show links */
<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
<a class="" href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
</li>
<?php endforeach; ?>
=======================================================================
// Add custom button to My Account > Orders page
add_filter( 'woocommerce_my_account_my_orders_actions', 'custom_order_action_button', 10, 2 );
function custom_order_action_button( $actions, $order ) {
// Make sure the order status is completed before adding the button (modify the condition as needed)
// if ( $order->has_status( 'completed' ) ) {
// Replace 'Custom Button' with your desired button label
$actions['conversations'] = array(
'url' => 'https://www.diversityproducts.net/my-account/conversations/', // Replace '#' with the URL you want the button to point to
'name' => __( 'Message Support', 'your-text-domain' ),
);
// }
return $actions;
}
//add menu items
add_action( 'init', 'add_support_endpoint' );
function add_support_endpoint() {
add_rewrite_endpoint( 'all-users', EP_ROOT | EP_PAGES );
add_rewrite_endpoint( 'manage-orders', EP_ROOT | EP_PAGES );
add_rewrite_endpoint( 'manage-company', EP_ROOT | EP_PAGES );
add_rewrite_endpoint( 'subaccounts', EP_ROOT | EP_PAGES );
}
//add menu items slug
add_filter( 'query_vars', 'custom_support_query_vars', 0 );
function custom_support_query_vars( $vars ) {
$vars[] = 'all-users';
$vars[] = 'manage-orders';
$vars[] = 'manage-company';
$vars[] = 'subaccounts';
return $vars;
}
//add single order details
// function custom_endpoint_content() {
// if(current_user_can('administrator') || current_user_can('superadmin') || current_user_can('company_admin')) {
// // Load your custom template file here
// require_once('single-order-details.php');
// }
// }
// add_action('woocommerce_account_order-details_endpoint', 'custom_endpoint_content');
//all users page show in account page
add_action( 'woocommerce_account_all-users_endpoint', 'custom_misha_content' );
function custom_misha_content() {
if(current_user_can('administrator') || current_user_can('superadmin') || current_user_can('company_admin')) {
require_once('page-manage-users.php');
}
}
//add orderdetails page in my account
add_action( 'woocommerce_account_manage-orders_endpoint', 'custom_orders_content' );
function custom_orders_content() {
if(current_user_can('administrator') || current_user_can('superadmin') || current_user_can('company_admin')) {
require_once('page-order-details.php');
}
}
//manage company page show in account page
add_action( 'woocommerce_account_manage-company_endpoint', 'custom_company_content' );
function custom_company_content() {
if(current_user_can('administrator') || current_user_can('superadmin') || current_user_can('company_admin')) {
require_once('page-manage-company.php');
}
}
Comments
Post a Comment