【问题标题】:Get if the current user has an active subscription with trial period获取当前用户是否有试用期的有效订阅
【发布时间】:2019-06-18 23:31:03
【问题描述】:

我正在使用 WooCommerce 在 WordPress 中开发一个网站。我正在使用 Woocommerce 订阅。我有一个试用期的产品。现在我想根据试用期更改下一个付款日期。如何获取试用期日期和下一个付款日期?这样我就可以更改第二个付款日期。我尝试使用下面提到的代码,但没有找到任何解决方案。

<?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;
                }
            ?>

【问题讨论】:

  • 没明白你的意思。您想获得订阅或试用结束日期吗?

标签: wordpress function woocommerce woocommerce-subscriptions


【解决方案1】:
<?php WC_Subscription::get_date( $date_type, $timezone ) ?>

$date_type

(string) (required) 要获取的日期类型,可以是'start'、'trial_end'、'next_payment'、'last_payment'或'end'。默认值:无

$时区

(string)(可选)返回日期使用的时区,“gmt”或“site”。默认‘gmt’。

您将在此处获得完整的文档。

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

更新:

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

在此处添加有问题的输出。您将找到开始和结束日期以及下一个付款日期。

【讨论】:

  • 抱歉,@vasim 能否提供完整代码以获取试用订阅的试用结束日期和下一个付款日期。我无法使用您的上述代码。谢谢
  • 没有调试问题我帮不了你
  • 谢谢@vasim。试用期过后,是否有可能使用功能更改订阅的下一个付款日期。谢谢
猜你喜欢
  • 2020-07-25
  • 2015-01-27
  • 2017-07-13
  • 2022-01-19
  • 2020-12-29
  • 2018-04-12
  • 2018-07-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多