本文整理汇总了PHP中WC_Subscriptions_Order::get_item_by_subscription_key方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Order::get_item_by_subscription_key方法的具体用法?PHP WC_Subscriptions_Order::get_item_by_subscription_key怎么用?PHP WC_Subscriptions_Order::get_item_by_subscription_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Subscriptions_Order
的用法示例。
在下文中一共展示了WC_Subscriptions_Order::get_item_by_subscription_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_subscription
/**
* Return an associative array of a given subscriptions details (if it exists).
*
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param deprecated don't use
* @return array Subscription details
* @since 1.1
*/
public static function get_subscription($subscription_key, $deprecated = null)
{
if (null != $deprecated) {
_deprecated_argument(__CLASS__ . '::' . __FUNCTION__, '1.4');
}
$item = WC_Subscriptions_Order::get_item_by_subscription_key($subscription_key);
if (!empty($item)) {
$subscription = array('order_id' => $item['order_id'], 'product_id' => $item['product_id'], 'variation_id' => $item['variation_id'], 'status' => isset($item['subscription_status']) ? $item['subscription_status'] : 'pending', 'period' => $item['subscription_period'], 'interval' => $item['subscription_interval'], 'length' => isset($item['subscription_length']) ? $item['subscription_length'] : 0, 'start_date' => isset($item['subscription_start_date']) ? $item['subscription_start_date'] : 0, 'expiry_date' => isset($item['subscription_expiry_date']) ? $item['subscription_expiry_date'] : 0, 'end_date' => isset($item['subscription_end_date']) ? $item['subscription_end_date'] : 0, 'trial_expiry_date' => isset($item['subscription_trial_expiry_date']) ? $item['subscription_trial_expiry_date'] : 0, 'failed_payments' => isset($item['subscription_failed_payments']) ? $item['subscription_failed_payments'] : 0, 'completed_payments' => isset($item['subscription_completed_payments']) ? $item['subscription_completed_payments'] : 0, 'suspension_count' => isset($item['subscription_suspension_count']) ? $item['subscription_suspension_count'] : 0, 'last_payment_date' => isset($item['subscription_completed_payments']) ? end($item['subscription_completed_payments']) : '');
} else {
$subscription = array();
}
return apply_filters('woocommerce_get_subscription', $subscription, $subscription_key, $deprecated);
}