Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save raazon/5aff1841fa8e2b44cca7309ff6ab44b5 to your computer and use it in GitHub Desktop.

Select an option

Save raazon/5aff1841fa8e2b44cca7309ff6ab44b5 to your computer and use it in GitHub Desktop.

Revisions

  1. @duroe5698 duroe5698 renamed this gist Aug 13, 2016. 1 changed file with 0 additions and 0 deletions.
  2. @duroe5698 duroe5698 created this gist Aug 13, 2016.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    /* Add custom menu item and endpoint to WooCommerce My-Account page */

    function my_custom_endpoints() {
    add_rewrite_endpoint( 'refunds-returns', EP_ROOT | EP_PAGES );
    }

    add_action( 'init', 'my_custom_endpoints' );

    function my_custom_query_vars( $vars ) {
    $vars[] = 'refunds-returns';

    return $vars;
    }

    add_filter( 'query_vars', 'my_custom_query_vars', 0 );

    function my_custom_flush_rewrite_rules() {
    flush_rewrite_rules();
    }

    add_action( 'after_switch_theme', 'my_custom_flush_rewrite_rules' );

    function my_custom_my_account_menu_items( $items ) {
    $items = array(
    'dashboard' => __( 'Dashboard', 'woocommerce' ),
    'orders' => __( 'Orders', 'woocommerce' ),
    'downloads' => __( 'Downloads', 'woocommerce' ),
    'edit-address' => __( 'Addresses', 'woocommerce' ),
    //'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
    'edit-account' => __( 'Edit Account', 'woocommerce' ),
    'refunds-returns' => 'Refunds & Returns',
    'customer-logout' => __( 'Logout', 'woocommerce' ),
    );

    return $items;
    }

    add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );

    function my_custom_endpoint_content() {
    include 'woocommerce/myaccount/refunds-returns.php';
    }

    add_action( 'woocommerce_account_refunds-returns_endpoint', 'my_custom_endpoint_content' );