My goal is to add an advanced custom field for WooCommerce subscriptions, editable on subscription edit pages, and display the custom field value on customer subscription page. It would be great to display it also in the WooCommerce email notifications.
I see that my question has been answered in Display advanced custom fields value in Woocommerce order details and all emails thread, but apparently the answer has been removed.
I hope someone can help out.
Below code shows the ACF repeater value for a repeater sub field on the subscription page in WooCommerce My Account page. Under the subscription details.
<?php
/**
* Show ACF custom repeater field on subscription page [while]
*/
// Display XNumbers on subcription
add_action( 'woocommerce_subscription_details_table', 'display_acf_on_subcriptions', 20);
function display_acf_on_subcriptions( $subscription ) { ?>
<h2>ACF Custom Repeater XNumbers:</h2>
<?php if( have_rows('acf_xnumbers_repeater', $subscription->id) ): ?>
<table>
<tr>
<th>XNumbers</th>
</tr>
<?php while ( have_rows('acf_xnumbers_repeater', $subscription->id) ) : the_row();
$sub_value = get_sub_field('XNumbers'); ?>
<tr>
<td>
<?php echo "$sub_value"; ?>
</td>
</tr>
<?php endwhile; ?>
</table>
<br/>
<?php else : ?>
<p> There are no XNumbers found.</p>
<br/>
<?php endif;
}