PHP函数可以:
这是我到目前为止所拥有的:
function get_last_customer_renewal_order() {
$current_user_id = get_current_user_id();
if (has_woocommerce_subscription('','','')){
$subscriptions = wcs_get_users_subscriptions($current_user_id);
$related_order_ID = array();
$related_orders = array();
foreach($subscriptions as $subscription) {
// The subscription ID
$related_order_ID[] = $subscription->get_related_orders( 'ids', 'renewal' );
foreach($related_order_ID as $related_orders) {
foreach($related_orders as $related_order) {
$order = wc_get_order( print_r($related_order[0]));
echo $order->get_status;
}
}
}
答案 0 :(得分:0)
更新: 因此,我设法使用以下功能检索了续订ID:
function get_last_customer_renewal_order() {
$current_user_id = get_current_user_id();
if (has_woocommerce_subscription('','','')){
$subscriptions = wcs_get_users_subscriptions($current_user_id);
$related_order_ID = array();
$related_orders = array();
foreach($subscriptions as $subscription) {
// The subscription ID
$related_order_ID[] = $subscription->get_related_orders( 'ids', 'renewal' );
foreach($related_order_ID as $related_orders) {
foreach($related_orders as $related_order) {
$order_id = $related_order;
if (! $order_id = ""){
$the_order_id = $related_order;
break 3;
}
else{
}
}
}
}
//$order = wc_get_order($the_order_id);
$order = new WC_Order( $the_order_id );
$order_status = $order->get_status();
//echo $the_order_id, '</br>', $order_status;
return $order_status;
}
else{}
}