Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static function init() {
add_action( 'plugins_loaded', [ __CLASS__, 'woocommerce_subscriptions_integration_init' ] );
add_filter( 'woocommerce_subscriptions_product_limited_for_user', [ __CLASS__, 'maybe_limit_subscription_product_for_user' ], 10, 3 );
add_filter( 'woocommerce_subscriptions_product_trial_length', [ __CLASS__, 'limit_free_trials_to_one_per_user' ], 10, 2 );
add_filter( 'wcs_get_users_subscriptions', [ __CLASS__, 'filter_subscriptions_for_account_page' ], 10, 1 );
}

/**
Expand Down Expand Up @@ -208,5 +209,23 @@ public static function limit_free_trials_to_one_per_user( $trial_length, $produc

return $trial_length;
}

/**
* Remove 'trash' subscriptions from the subscriptions list on the My Account page.
*
* @param array $subscriptions The subscriptions.
* @return array The filtered subscriptions.
*/
public static function filter_subscriptions_for_account_page( $subscriptions ) {
if ( function_exists( 'is_account_page' ) && is_account_page() ) {
$subscriptions = array_filter(
$subscriptions,
function( $subscription ) {
return ! $subscription->has_status( 'trash' );
}
);
}
return $subscriptions;
}
}
WooCommerce_Subscriptions::init();
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,20 @@
</a>

<ul>
<?php
// Check if viewing a single subscription page.
$is_viewing_single_subscription = false;
if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'view-subscription' ) ) {
$is_viewing_single_subscription = true;
}
?>
<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
<?php
// Highlight subscriptions menu item if viewing a single subscription.
$is_current_item = wc_is_current_account_menu_item( $endpoint ) || ( $is_viewing_single_subscription && 'subscriptions' === $endpoint );
?>
<li class="<?php echo esc_attr( wc_get_account_menu_item_classes( $endpoint ) ); ?>">
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>" <?php echo wc_is_current_account_menu_item( $endpoint ) ? 'aria-current="page"' : ''; ?> class="newspack-ui__button newspack-ui__button--small <?php echo wc_is_current_account_menu_item( $endpoint ) ? 'newspack-ui__button--accent' : 'newspack-ui__button--ghost'; ?>">
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>" <?php echo $is_current_item ? 'aria-current="page"' : ''; ?> class="newspack-ui__button newspack-ui__button--small <?php echo $is_current_item ? 'newspack-ui__button--accent' : 'newspack-ui__button--ghost'; ?>">
<?php echo esc_html( $label ); ?>
</a>
</li>
Expand Down
16 changes: 16 additions & 0 deletions src/newspack-ui/scss/elements/woocommerce/_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@
border: none !important;
}
}

&.woocommerce-account.newspack-my-account {
.woocommerce-message {
.woocommerce-Button.button {
background: transparent;
border-radius: 0;
color: inherit;
float: none;
font-size: inherit;
font-weight: inherit;
min-height: auto;
padding: 0;
text-decoration: underline;
}
}
}
}

/** See #3292. */
Expand Down