本文整理汇总了PHP中WC_Subscriptions_Order::is_item_a_subscription方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Order::is_item_a_subscription方法的具体用法?PHP WC_Subscriptions_Order::is_item_a_subscription怎么用?PHP WC_Subscriptions_Order::is_item_a_subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Subscriptions_Order
的用法示例。
在下文中一共展示了WC_Subscriptions_Order::is_item_a_subscription方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_subscription_payment_on_child_order
/**
* If the payment for a renewal order has previously failed and is then paid, we need to make sure the
* subscription payment function is called.
*
* @param $user_id int The id of the user who purchased the subscription
* @param $subscription_key string A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
* @since 1.2
*/
public static function process_subscription_payment_on_child_order($order_id, $payment_status = 'completed')
{
if (self::is_renewal($order_id, 'child')) {
$child_order = new WC_Order($order_id);
$parent_order = self::get_parent_order($child_order);
$subscriptions_in_order = $child_order->get_items();
// Should only be one subscription in the renewal order, but just in case
foreach ($subscriptions_in_order as $item) {
if (WC_Subscriptions_Order::is_item_a_subscription($parent_order, $item['id'])) {
if ('failed' == $payment_status) {
// Don't duplicate renewal order
remove_action('processed_subscription_payment_failure', __CLASS__ . '::generate_failed_payment_renewal_order', 10, 2);
WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($parent_order->id, $item['id']);
// But make sure orders are still generated for other payments in the same request
add_action('processed_subscription_payment_failure', __CLASS__ . '::generate_failed_payment_renewal_order', 10, 2);
} else {
// Don't duplicate renewal order
remove_action('processed_subscription_payment', __CLASS__ . '::generate_paid_renewal_order', 10, 2);
WC_Subscriptions_Manager::process_subscription_payments_on_order($parent_order->id, $item['id']);
// But make sure orders are still generated for other payments in the same request
add_action('processed_subscription_payment', __CLASS__ . '::generate_paid_renewal_order', 10, 2);
// Reactivate the subscription - activate_subscription doesn't operate on child orders
$subscription_key = WC_Subscriptions_Manager::get_subscription_key($parent_order->id, $item['id']);
WC_Subscriptions_Manager::reactivate_subscription($parent_order->customer_user, $subscription_key);
}
}
}
}
}