robertstaddon / buddypress-woocommerce

Move WooCommerce My Account area to BuddyPress profile
22 stars 4 forks source link

order details not showing inside buddypress profile #4

Open sayantandas opened 7 years ago

sayantandas commented 7 years ago

if I click on the order details, the order details are shown in http://website/my-account/order/orderid. It's better if the order details can be shown inside the buddypress profile

tadinski commented 7 years ago

+1

Abee23 commented 7 years ago

Yes I'm having the same issue I'm not able to view the order details in buddypress profile I added a case for view-order then url is generated fine but when I visit ,it displays page not found Please help me as soon as possible

JohnTendik commented 5 years ago

I know this is kind of old and outdated, but I wanted to put in my 2c here and tell others what 'worked' for me. Its a workaround for sure. I didn't want the entire themecraft plugin, I simply needed orders and view orders to work with my buddypress integration so this was a great starting point.

To change the view order url you need to use the filter.. here's an example of how that would look

  add_filter( 'woocommerce_get_view_order_url', 'view_order_url', 10, 2 );

  public function view_order_url( $view_order_url, $order ) {
    $current_user = wp_get_current_user();
    return wc_get_endpoint_url( 'view-order', $order->get_id(),  '/members/' . $current_user->user_nicename . '/account/');
  }

then you need to add another sub-tab inside of the bp_navigation() function which creates the nav items for the woocommerce area. An example:

bp_core_new_subnav_item(
      array(
        'name' => __( 'View Order', 'buddypress' ),
        'slug' => 'view-order',
        'parent_url' => trailingslashit( $bp->loggedin_user->domain . 'account' ),
        'parent_slug' => 'account',
        'screen_function' => array( $this, 'account_screens' ),
        'show_for_displayed_user' => false,
        'user_has_access' => bp_is_my_profile(),
        'position' => 100,
        'item_css_id' => 'account-view_order',
      )
    );

Now unfortunately this will add an extra tab in the sub-nav area, so you will see Dashboard, orders, view order, etc, etc in the sub menu. I wasn't able to figure out how to create this subpage and also hide it from the nav. Maybe someone else can pickup my slack where I fell short, but for the time being I simply used the item_css_id to target that menu item and use display:none; to hide it from the user.

This is my 2c, hopefully it will lead someone in the right direction.

toby12222 commented 4 years ago

This worked perfect for me ♥, is there any possibility to do the same for the woocommerce membership plugin?

If you need the plugin I can send it to you without any problem