【发布时间】:2015-10-18 08:10:42
【问题描述】:
我正在使用 Woocommerce 订阅插件,在处理订单续订电子邮件中,我想显示下一个付款日期是什么时候。但是,当我尝试访问订单的下一个付款日期时,它总是返回 false。
<?php
if (WC_Subscriptions_Renewal_Order::is_renewal( $order ) ) { /* This returns true */
$parent_id = WC_Subscriptions_Renewal_Order::get_parent_order_id( $order ); /* This gets the original parent order id */
$parent_order = new WC_Order( $parent_id );
foreach ($parent_order->get_items() as $item) { /* This loops through each item in the order */
$h = WC_Subscriptions_Order::get_next_payment_date ( $parent_order, $item['product_id'] ); /* This should get the next payment date... */
var_dump($h); /* But it returns false :-( */
}
}
?>
WC_Subscriptions_Order::get_total_initial_payment() 等其他函数按预期工作。
如何获取订阅订单的下一个付款日期?
【问题讨论】:
-
get_next_payment_date()方法的第一个参数是一个$subscription_key,它似乎是从get_subscription_key()方法中检索到的。但我也在看 Subs 2.0 beta 代码,所以我不确定。请注意,get_next_payment_date()方法自 2.0 起已弃用。
标签: php wordpress woocommerce subscriptions