یکی از ویژگی های برتر ما ارائه پشتیبانی پرسش و پاسخ حرفه ای ووکامرس برای حامیانی است که ثبت نام می کنند. بنابراین ، چگونه می توان یک “برگه” اضافی به صفحه “حساب من” اضافه کرد و چگونه می توان محتوای داخل آن را اضافه کرد؟

این کدی است که من استفاده کردم اگر این آموزش را مفید می دانید ، در صورت تمایل در زیر نظر دهید.

WooCommerce: How to Add a New Tab to the My Account Page
WooCommerce: How to Add a New Tab to the My Account Page

قطعه کد PHP: نحوه افزودن برگه جدید @ صفحه حساب من در ووکامرس


// ------------------
// 1. Register new endpoint (URL) for My Account page
// Note: Re-save Permalinks or it will give 404 error
  
function ej_add_premium_support_endpoint() {
    add_rewrite_endpoint( 'premium-support', EP_ROOT | EP_PAGES );
}
  
add_action( 'init', 'ej_add_premium_support_endpoint' );
  
// ------------------
// 2. Add new query var
  
function ej_premium_support_query_vars( $vars ) {
    $vars[] = 'premium-support';
    return $vars;
}
  
add_filter( 'query_vars', 'ej_premium_support_query_vars', 0 );
  
// ------------------
// 3. Insert the new endpoint into the My Account menu
  
function ej_add_premium_support_link_my_account( $items ) {
    $items['premium-support'] = 'Premium Support';
    return $items;
}
  
add_filter( 'woocommerce_account_menu_items', 'ej_add_premium_support_link_my_account' );
  
// ------------------
// 4. Add content to the new tab
  
function ej_premium_support_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_premium-support_endpoint', 'ej_premium_support_content' );
// Note: add_action must follow 'woocommerce_account_{your-endpoint-slug}_endpoint' format

آیا افزونه ای (قابل اطمینان) هم برای آن وجود دارد؟

اگر دوست دارید کد نویسی کنید اما با PHP 100٪ اطمینان ندارید ، تصمیم گرفتم به دنبال یک افزونه قابل اعتماد باشم که به همان نتیجه برسد.

در این حالت ، من پلاگین YITH WooCommerce Customize My Account Page را توصیه می کنم. علاوه بر افزودن برگه های جدید حساب من ، می توانید منوی برگه را به اطراف منتقل کنید ، طرح رنگ را سفارشی کنید ، بنرها را اضافه کنید ، reCaptcha را در فرم های ثبت نام و ورود به سیستم تنظیم کنید ، مرتب کنید ، تغییر نام دهید ، برگه ها را حذف کنید و گروه بندی کنید ، برگه ها را به صورت مشروط نشان دهید با توجه به نقش کاربر و موارد دیگر.

اما درصورتی که از افزونه ها متنفرید و مایل به کدگذاری هستید (یا می خواهید آن را امتحان کنید) ، پس به خواندن ادامه دهید …

دسته‌بندی:

Woocommerce,