当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Subscriptions_Order::is_item_subscription方法代码示例

本文整理汇总了PHP中WC_Subscriptions_Order::is_item_subscription方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Order::is_item_subscription方法的具体用法?PHP WC_Subscriptions_Order::is_item_subscription怎么用?PHP WC_Subscriptions_Order::is_item_subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Subscriptions_Order的用法示例。


在下文中一共展示了WC_Subscriptions_Order::is_item_subscription方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _e

?>
</th>
			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php 
_e('Start Date', 'woocommerce-subscriptions');
?>
</th>
			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php 
_e('End Date', 'woocommerce-subscriptions');
?>
</th>
		</tr>
	</thead>
	<tbody>
	<?php 
foreach ($order->get_items() as $item) {
    if (WC_Subscriptions_Order::is_item_subscription($order, $item)) {
        ?>
			<tr>
				<td scope="row" style="text-align:left; border: 1px solid #eee;"><?php 
        echo $item['name'];
        ?>
</td>
				<td scope="row" style="text-align:left; border: 1px solid #eee;"><?php 
        echo date_i18n(woocommerce_date_format(), strtotime($item['subscription_start_date']));
        ?>
</td>
				<td scope="row" style="text-align:left; border: 1px solid #eee;"><?php 
        echo !empty($item['subscription_expiry_date']) ? date_i18n(woocommerce_date_format(), strtotime($item['subscription_expiry_date'])) : __('When Cancelled', 'woocommerce-subscriptions');
        ?>
			</tr>
			<?php 
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:31,代码来源:subscription-info.php

示例2: maybe_trash_subscription

 /**
  * Clear all subscriptions from a user's account for a given order.
  *
  * @param $order WC_Order The order for which subscriptions should be cleared.
  * @since 1.0
  */
 public static function maybe_trash_subscription($order)
 {
     if (!is_object($order)) {
         $order = new WC_Order($order);
     }
     if (WC_Subscriptions_Order::order_contains_subscription($order)) {
         foreach ($order->get_items() as $order_item) {
             if (WC_Subscriptions_Order::is_item_subscription($order, $order_item)) {
                 self::trash_subscription($order->customer_user, self::get_subscription_key($order->id, WC_Subscriptions_Order::get_items_product_id($order_item)));
             }
         }
     }
 }
开发者ID:bulats,项目名称:chef,代码行数:19,代码来源:class-wc-subscriptions-manager.php

示例3: 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 int $user_id The id of the user who purchased the subscription
  * @param string $subscription_key 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, array('order_role' => '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) {
             $item_id = WC_Subscriptions_Order::get_items_product_id($item);
             if (WC_Subscriptions_Order::is_item_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);
                 }
             }
         }
     }
 }
开发者ID:bulats,项目名称:chef,代码行数:38,代码来源:class-wc-subscriptions-renewal-order.php

示例4: process_subscription_payment_failure_on_order

 /**
  * This function should be called whenever a subscription payment has failed.
  *
  * The function is a convenience wrapper for @see self::process_subscription_payment_failure(), so if calling that
  * function directly, do not call this function also.
  *
  * @param int|WC_Order $order The order or ID of the order for which subscription payments should be marked against.
  * @since 1.0
  */
 public static function process_subscription_payment_failure_on_order($order, $product_id = '')
 {
     if (!is_object($order)) {
         $order = new WC_Order($order);
     }
     if (empty($product_id)) {
         $order_items = WC_Subscriptions_Order::get_recurring_items($order);
         $first_order_item = reset($order_items);
         $product_id = WC_Subscriptions_Order::get_items_product_id($first_order_item);
     }
     if (WC_Subscriptions_Order::order_contains_subscription($order) && WC_Subscriptions_Order::is_item_subscription($order, $product_id)) {
         self::process_subscription_payment_failure($order->customer_user, self::get_subscription_key($order->id, $product_id));
         do_action('processed_subscription_payment_failure_for_order', $order);
     }
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:24,代码来源:class-wc-subscriptions-manager.php

示例5: is_item_subscription

 /**
  * Tells if an order item is a subscription, provided that Subs is installed.
  *
  * @param  mixed      $order   order to check
  * @param  WC_Prder   $order   item to check
  * @return boolean             true if Subs exists and item is a Sub
  */
 function is_item_subscription($order, $item)
 {
     if (!class_exists('WC_Subscriptions_Order')) {
         return false;
     }
     return WC_Subscriptions_Order::is_item_subscription($order, $item);
 }
开发者ID:puppy09,项目名称:madC,代码行数:14,代码来源:class-wc-pb-compatibility.php

示例6: maybe_manually_change_subscriptions

 /**
  * When an order is added or updated from the admin interface, check if a new subscription product
  * has been manually added to the order, and if one has, create a new subscription. 
  * 
  * @param $post_id int The ID of the post which is the WC_Order object.
  * @param $post Object The post object of the order.
  * @since 1.1
  */
 public static function maybe_manually_change_subscriptions($post_id, $post)
 {
     $order = new WC_Order($post_id);
     // Check if all the subscription products on the order have associated subscriptions on the user's account, and if not, add a new one
     foreach ($_POST['item_id'] as $item_id) {
         if (!WC_Subscriptions_Order::is_item_subscription($order, $item_id)) {
             continue;
         }
         $subscription_key = WC_Subscriptions_Manager::get_subscription_key($post_id, $item_id);
         $subscription = array();
         // If order customer changed, move the subscription from the old customer's account to the new customer
         if (!empty($order->customer_user) && $order->customer_user != (int) $_POST['customer_user']) {
             $subscription = WC_Subscriptions_Manager::remove_users_subscription($order->customer_user, $subscription_key);
             $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions((int) $_POST['customer_user']);
             if (!empty($subscription)) {
                 $subscriptions[$subscription_key] = $subscription;
                 WC_Subscriptions_Manager::update_users_subscriptions((int) $_POST['customer_user'], $subscriptions);
             }
         }
         // In case it's a new order or the customer has changed
         $order->customer_user = $order->user_id = (int) $_POST['customer_user'];
         $subscription = WC_Subscriptions_Manager::get_users_subscription($order->customer_user, $subscription_key);
         if (empty($subscription)) {
             // Add a new subscription
             // The order doesn't may not exist yet, so we need to set a few things ourselves
             $order->order_key = uniqid('order_');
             add_post_meta($post_id, '_order_key', $order->order_key, true);
             WC_Subscriptions_Manager::create_pending_subscription_for_order($order, $item_id);
             // Add the subscription meta for this item to the order
             $functions_and_meta = array('get_period' => '_order_subscription_periods', 'get_interval' => '_order_subscription_intervals', 'get_length' => '_order_subscription_lengths');
             foreach ($functions_and_meta as $function_name => $meta_key) {
                 $subscription_meta = self::get_meta($order, $meta_key, array());
                 $subscription_meta[$item_id] = WC_Subscriptions_Product::$function_name($item_id);
                 update_post_meta($order->id, $meta_key, $subscription_meta);
             }
             // Set the subscription's status if it should be something other than pending
             switch ($order->status) {
                 case 'completed':
                 case 'processing':
                     WC_Subscriptions_Manager::activate_subscription($order->customer_user, $subscription_key);
                     break;
                 case 'refunded':
                 case 'cancelled':
                     WC_Subscriptions_Manager::cancel_subscription($order->customer_user, $subscription_key);
                     break;
                 case 'failed':
                     WC_Subscriptions_Manager::failed_subscription_signup($order->customer_user, $subscription_key);
                     break;
             }
         }
     }
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:60,代码来源:class-wc-subscriptions-order.php

示例7: pre_process_shop_order_meta

 /**
  * When an order is added or updated from the admin interface, check if a subscription product
  * has been manually added to the order or the details of the subscription have been modified, 
  * and create/update the subscription as required.
  *
  * Save subscription order meta items
  *
  * @param $post_id int The ID of the post which is the WC_Order object.
  * @param $post Object The post object of the order.
  * @since 1.1
  */
 public static function pre_process_shop_order_meta($post_id, $post)
 {
     global $woocommerce, $wpdb;
     $order_contains_subscription = false;
     $order = new WC_Order($post_id);
     $existing_product_ids = array();
     foreach ($order->get_items() as $existing_item) {
         $existing_product_ids[] = self::get_items_product_id($existing_item);
     }
     $product_ids = array();
     // WC <> 2.0 compatible posted product IDs
     if (isset($_POST['order_item_id'])) {
         foreach ($_POST['order_item_id'] as $order_item_id) {
             // WC 2.0+ has unique order item IDs and the product ID is a piece of meta
             $product_ids[$order_item_id] = woocommerce_get_order_item_meta($order_item_id, '_product_id');
         }
     } elseif (isset($_POST['item_id'])) {
         $product_ids = $_POST['item_id'];
     }
     // WC 1.x treated order item IDs as product IDs
     // Check if there are new subscription products to be added, or the order already has a subscription item
     foreach (array_merge($product_ids, $existing_product_ids) as $order_item_id => $product_id) {
         $is_existing_item = false;
         if (in_array($product_id, $existing_product_ids)) {
             $is_existing_item = true;
         }
         // If this is a new item and it's a subscription product, we have a subscription
         if (!$is_existing_item && WC_Subscriptions_Product::is_subscription($product_id)) {
             $order_contains_subscription = true;
         }
         // If this is an existing item and it's a subscription item, we have a subscription
         if ($is_existing_item && WC_Subscriptions_Order::is_item_subscription($order, $product_id)) {
             $order_contains_subscription = true;
         }
     }
     if (!$order_contains_subscription) {
         return $post_id;
     }
     // If the payment method is changing, make sure we have correct manual payment flag set
     $chosen_payment_method = stripslashes($_POST['_payment_method']);
     $existing_payment_method = get_post_meta($post_id, '_payment_method', true);
     if ($chosen_payment_method != $existing_payment_method || empty($chosen_payment_method)) {
         $payment_gateways = $woocommerce->payment_gateways->payment_gateways();
         if (isset($payment_gateways[$chosen_payment_method]) && $payment_gateways[$chosen_payment_method]->supports('subscriptions')) {
             $manual_renewal = 'false';
         } else {
             $manual_renewal = 'true';
         }
         update_post_meta($post_id, '_wcs_requires_manual_renewal', $manual_renewal);
     }
     // Make sure the recurring order totals are correct
     update_post_meta($post_id, '_order_recurring_discount_cart', stripslashes($_POST['_order_recurring_discount_cart']));
     update_post_meta($post_id, '_order_recurring_discount_total', stripslashes($_POST['_order_recurring_discount_total']));
     update_post_meta($post_id, '_order_recurring_tax_total', stripslashes($_POST['_order_recurring_tax_total']));
     update_post_meta($post_id, '_order_recurring_total', stripslashes($_POST['_order_recurring_total']));
     if (isset($_POST['recurring_order_taxes_id'])) {
         // WC 2.0+
         $tax_keys = array('recurring_order_taxes_id', 'recurring_order_taxes_rate_id', 'recurring_order_taxes_amount', 'recurring_order_taxes_shipping_amount');
         foreach ($tax_keys as $tax_key) {
             ${$tax_key} = isset($_POST[$tax_key]) ? $_POST[$tax_key] : array();
         }
         foreach ($recurring_order_taxes_id as $item_id) {
             $item_id = absint($item_id);
             $rate_id = absint($recurring_order_taxes_rate_id[$item_id]);
             if ($rate_id) {
                 $rate = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $rate_id));
                 $label = $rate->tax_rate_name ? $rate->tax_rate_name : $woocommerce->countries->tax_or_vat();
                 $compound = $rate->tax_rate_compound ? 1 : 0;
                 $code = array();
                 $code[] = $rate->tax_rate_country;
                 $code[] = $rate->tax_rate_state;
                 $code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX';
                 $code[] = absint($rate->tax_rate_priority);
                 $code = strtoupper(implode('-', array_filter($code)));
             } else {
                 $code = '';
                 $label = $woocommerce->countries->tax_or_vat();
             }
             $wpdb->update($wpdb->prefix . "woocommerce_order_items", array('order_item_name' => woocommerce_clean($code)), array('order_item_id' => $item_id), array('%s'), array('%d'));
             woocommerce_update_order_item_meta($item_id, 'rate_id', $rate_id);
             woocommerce_update_order_item_meta($item_id, 'label', $label);
             woocommerce_update_order_item_meta($item_id, 'compound', $compound);
             if (isset($recurring_order_taxes_amount[$item_id])) {
                 woocommerce_update_order_item_meta($item_id, 'tax_amount', woocommerce_clean($recurring_order_taxes_amount[$item_id]));
             }
             if (isset($recurring_order_taxes_shipping_amount[$item_id])) {
                 woocommerce_update_order_item_meta($item_id, 'shipping_tax_amount', woocommerce_clean($recurring_order_taxes_shipping_amount[$item_id]));
             }
         }
//.........这里部分代码省略.........
开发者ID:bulats,项目名称:chef,代码行数:101,代码来源:class-wc-subscriptions-order.php


注:本文中的WC_Subscriptions_Order::is_item_subscription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。