diff --git a/includes/reader-revenue/my-account/class-woocommerce-my-account.php b/includes/reader-revenue/my-account/class-woocommerce-my-account.php index 4d456a7699..a612220fad 100644 --- a/includes/reader-revenue/my-account/class-woocommerce-my-account.php +++ b/includes/reader-revenue/my-account/class-woocommerce-my-account.php @@ -126,14 +126,22 @@ public static function my_account_menu_items( $items ) { if ( empty( array_filter( $billing_address ) ) && empty( array_filter( $billing_address ) ) ) { $default_disabled_items[] = 'edit-address'; } + + // Hide Orders and Payment Methods if the reader has no orders. + if ( ! $customer->get_is_paying_customer() ) { + $default_disabled_items[] = 'orders'; + $default_disabled_items[] = 'payment-methods'; + } } if ( function_exists( 'wc_get_customer_available_downloads' ) ) { - $customer_id = \get_current_user_id(); $wc_customer_downloads = \wc_get_customer_available_downloads( $customer_id ); if ( empty( $wc_customer_downloads ) ) { $default_disabled_items[] = 'downloads'; } } + if ( function_exists( 'wcs_user_has_subscription' ) && ! \wcs_user_has_subscription( $customer_id ) ) { + $default_disabled_items[] = 'subscriptions'; + } $disabled_wc_menu_items = \apply_filters( 'newspack_my_account_disabled_pages', $default_disabled_items ); foreach ( $disabled_wc_menu_items as $key ) { @@ -141,6 +149,12 @@ public static function my_account_menu_items( $items ) { unset( $items[ $key ] ); } } + + // Move "Account Details" and "S"ubscriptions" to the top of the menu. + if ( isset( $items['subscriptions'] ) ) { + $items = [ 'subscriptions' => $items['subscriptions'] ] + $items; + } + $items = [ 'edit-account' => $items['edit-account'] ] + $items; } return $items;