We use WooCommerce subscription and I created that snippet below to display the renewal count on MyAccount page.
This is working. But, I found out, that the initial parent order also count as a "paid". So actually I only want to count the renewals from a subscription means exclude the initial order from that count.
I guess when I always calc -1 like $get_paid_count -1
then it works. But that solution is not very clean. Any suggestions how I can do that in a clean way?
function show_paid_renewals( $subscription ) {
$get_paid_count = $subscription->get_payment_count();
foreach ( $subscription->get_items() as $item ) {
?>
<tr>
<td><?php esc_html_e( 'Erhaltene Lieferungen: ' . $item->get_product()->get_title(), 'woocommerce-subscriptions' ); ?></td>
<td>
<?php echo esc_html( $get_paid_count ); ?>
</td>
</tr>
<?php
}
}
add_action( 'woocommerce_subscription_before_actions', 'show_paid_renewals', 99, 1 );