Woocommerce Subscriptions – Set Billing Interval/Period

Question

I am working with the subscriptions plugin for Woocommerce and you can set a custom billing interval and period by making use of:

    // Set subscription billing interval
    $subscription->set_billing_interval($customInterval);

    // Set subscription billing period
    $subscription->set_billing_period('day');

Now this works great and it displays this change under ‘Subscriptions’ in the backend:

enter image description here

However, it doesn’t display this on the 100% correctly on the actual subscription, it correctly sets the billing period to be day but it doesn’t add the date to the dropdown:

enter image description here

I know you can set custom intervals globally via the following code:

function add_custom_interval( $subscription_intervals ) {

$subscription_intervals['8'] = sprintf( __( 'every %s', 'woocommerce-subscriptions' ), WC_Subscriptions::append_numeral_suffix( 8 )  );

return $subscription_intervals;
}
add_filter( 'woocommerce_subscription_period_interval_strings', 'add_custom_interval' );

I need to be able to do something similar to this inside the subscription when I am updating it.

Doing the following:

$subscription_intervals[$customInterval] = sprintf( __( 'every %s', 'woocommerce-subscriptions' ), WC_Subscriptions::append_numeral_suffix( $customInterval )  );

This returns the correct value but now I need to add that value to the dropdown when the subscription is updated.

0
zen_1991 2 months 0 Answers 9 views 0

Leave an answer