0

I'm developing a website in WordPress with WooCommerce. I am using Woocommerce Subscription. I have a product with a trial period. Now I want to change the next payment date based on the trial period. How can I get the trial period date and Next payment date? So that I can change the Second payment date. I tried using the below-mentioned code but didn't find any solution.

<?php if (has_woocommerce_subscription('','','active') && WC_Subscriptions_Product::get_trial_length( $product_id ) > 10) {
                $trial_end = WC_Subscription::get_date( 'trial_end');
                echo $trial_end;
                }
            ?>
Praveen
  • 985
  • 8
  • 31

1 Answers1

0
<?php WC_Subscription::get_date( $date_type, $timezone ) ?>

$date_type

(string) (required) The type of date to get, can be 'start', 'trial_end', 'next_payment', 'last_payment' or 'end'. Default: None

$timezone

(string) (optional) The timezone to use for the returned date, either ‘gmt’ or ‘site’. Default ‘gmt’.

You will get complete document here.

https://docs.woocommerce.com/document/subscriptions/develop/functions/

Update :

$product = wc_get_product($product_id); $period = WC_Subscriptions_Product::get_period($product); var_dump($product);

Add output here in question. You will find start and end date as well as next payment date.

Vasim Shaikh
  • 4,485
  • 2
  • 23
  • 52
  • sorry, @vasim can you provide me full code to get the Trial End Date of trial subscription and next payment date. I am unable to use your above-mentioned code. Thanks – Praveen Jan 25 '19 at 08:13
  • I can't help you without debug issue – Vasim Shaikh Jan 25 '19 at 09:40
  • https://devask.in/questions/43169889/woocommerce-subscriptions-create-order-without-trial-period – Vasim Shaikh Jan 25 '19 at 09:43
  • Thanks @vasim. Is there any possibility of changing next payment date in subscriptions after trial period using functions.Thanks – Praveen Jan 26 '19 at 01:54