Skip to content

Instantly share code, notes, and snippets.

@AmeliaBriscoe
Last active November 22, 2021 03:34
Show Gist options
  • Save AmeliaBriscoe/7294187d06025f037fdab9e865a85f81 to your computer and use it in GitHub Desktop.
Save AmeliaBriscoe/7294187d06025f037fdab9e865a85f81 to your computer and use it in GitHub Desktop.
Append the product name of the subscription to the ID in the My Account area.
<?php
/*
* Adds subscription name, with link to the product page, beside subscription ID in My Account > Subscriptions
*/
add_action( 'woocommerce_my_subscriptions_after_subscription_id', 'wcs_add_subscription_name_to_table', 35 );
function wcs_add_subscription_name_to_table( $subscription ) {
foreach ( $subscription->get_items() as $item_id => $item ) {
$_product = apply_filters( 'woocommerce_subscriptions_order_item_product', $subscription->get_product_from_item( $item ), $item );
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', sprintf( '<a href="%s">%s</a>', get_permalink( $item['product_id'] ), $item['name'] ), $item ) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment