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


PHP WC_Subscriptions_Order::get_item_by_product_id方法代码示例

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


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

示例1: validate_switch_request

 /**
  * When a product is added to the cart, check if it is being added to switch a subscription and if so,
  * make sure it's valid (i.e. not the same subscription).
  *
  * @since 1.4
  */
 public static function validate_switch_request($is_valid, $product_id, $quantity, $variation_id = '')
 {
     global $woocommerce;
     if (!isset($_GET['switch-subscription'])) {
         return $is_valid;
     }
     $subscription = WC_Subscriptions_Manager::get_subscription($_GET['switch-subscription']);
     // Check if the chosen variation's attributes are different to the existing subscription's attributes (to support switching between a "catch all" variation)
     $original_order = new WC_Order($subscription['order_id']);
     $item = WC_Subscriptions_Order::get_item_by_product_id($original_order, $subscription['product_id']);
     $identical_attributes = true;
     foreach ($_POST as $key => $value) {
         if (false !== strpos($key, 'attribute_') && !empty($item[str_replace('attribute_', '', $key)]) && $item[str_replace('attribute_', '', $key)] != $value) {
             $identical_attributes = false;
             break;
         }
     }
     if ($product_id == $subscription['product_id'] && (empty($variation_id) || $variation_id == $subscription['variation_id'] && true == $identical_attributes)) {
         WC_Subscriptions::add_notice(__('You can not switch to the same subscription.', 'woocommerce-subscriptions'), 'error');
         $is_valid = false;
     }
     return $is_valid;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:29,代码来源:class-wc-subscriptions-switcher.php

示例2: email_replacements

 public function email_replacements($reps, $email_data, $email_order, $email_row)
 {
     global $wpdb, $woocommerce;
     $email_type = $email_row->email_type;
     $order_date = '';
     $order_datetime = '';
     $order_id = '';
     if ($email_order->order_id) {
         $order = new WC_Order($email_order->order_id);
         $order_date = date(get_option('date_format'), strtotime($order->order_date));
         $order_datetime = date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($order->order_date));
         $order_id = apply_filters('woocommerce_order_number', '#' . $email_order->order_id, $order);
         $item = WC_Subscriptions_Order::get_item_by_product_id($order);
         $item_id = WC_Subscriptions_Order::get_items_product_id($item);
         $renewal = WC_Subscriptions_Order::get_next_payment_timestamp($order, $item_id);
         $renew_date = date(get_option('date_format'), $renewal);
         // calc days to renew
         $now = current_time('timestamp');
         $diff = $renewal - $now;
         $days_to_renew = 0;
         if ($diff > 0) {
             $days_to_renew = floor($diff / 86400);
         }
         $item_url = FUE::create_email_url($email_order->id, $email_row->id, $email_data['user_id'], $email_data['email_to'], get_permalink($item_id));
         $categories = '';
         if ($item_id) {
             $cats = get_the_terms($item_id, 'product_cat');
             if (is_array($cats) && !empty($cats)) {
                 foreach ($cats as $cat) {
                     $categories .= $cat->name . ', ';
                 }
                 $categories = rtrim($categories, ', ');
             }
         }
         $reps = array_merge($reps, array($order_id, $order_date, $order_datetime, $email_data['first_name'], $email_data['first_name'] . ' ' . $email_data['last_name'], $email_data['email_to'], $renew_date, $days_to_renew, '<a href="' . $item_url . '">' . get_the_title($item_id) . '</a>', $categories));
     }
     return $reps;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:38,代码来源:class.fue_subscriptions.php

示例3: before_woocommerce_pay

 /**
  * Check if a payment is being made on a failed renewal order from 'My Account'. If so,
  * redirect the order into a cart/checkout payment flow.
  *
  * @since 1.3
  */
 public static function before_woocommerce_pay()
 {
     global $woocommerce, $wp;
     if (isset($_GET['pay_for_order']) && (isset($_GET['order']) && isset($_GET['order_id']) || isset($_GET['key']) && isset($wp->query_vars['order-pay']))) {
         // Pay for existing order
         $order_key = isset($_GET['key']) ? $_GET['key'] : $_GET['order'];
         // WC 2.1 compatibility
         $order_id = isset($wp->query_vars['order-pay']) ? $wp->query_vars['order-pay'] : absint($_GET['order_id']);
         $order = new WC_Order($order_id);
         $failed_order_replaced_by = get_post_meta($order_id, '_failed_order_replaced_by', true);
         if (is_numeric($failed_order_replaced_by)) {
             WC_Subscriptions::add_notice(sprintf(__('Sorry, this failed order has already been paid. See order %s.', 'woocommerce-subscriptions'), $failed_order_replaced_by), 'error');
             wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
             exit;
         }
         if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed')) && WC_Subscriptions_Renewal_Order::is_renewal($order)) {
             // If order being paid is a parent order, get the original order, else query parent_order
             if (WC_Subscriptions_Renewal_Order::is_renewal($order_id, array('order_role' => 'parent'))) {
                 $role = 'parent';
                 $original_order = new WC_Order(WC_Subscriptions_Order::get_meta($order, 'original_order', false));
             } elseif (WC_Subscriptions_Renewal_Order::is_renewal($order_id, array('order_role' => 'child'))) {
                 $role = 'child';
                 $original_order = WC_Subscriptions_Renewal_Order::get_parent_order($order_id);
             }
             $order_items = WC_Subscriptions_Order::get_recurring_items($original_order);
             $first_order_item = reset($order_items);
             $product_id = WC_Subscriptions_Order::get_items_product_id($first_order_item);
             $product = get_product($product_id);
             $variation_id = '';
             $variation_data = array();
             // Display error message for deleted products
             if (false === $product) {
                 WC_Subscriptions::add_notice(self::$product_deleted_error_message, 'error');
                 // Make sure we don't actually need the variation ID
             } elseif ($product->is_type(array('variable-subscription'))) {
                 $item = WC_Subscriptions_Order::get_item_by_product_id($original_order, $product_id);
                 $variation_id = $item['variation_id'];
                 $variation = get_product($variation_id);
                 // Display error message for deleted product variations
                 if (false === $variation) {
                     WC_Subscriptions::add_notice(self::$product_deleted_error_message, 'error');
                     $variation_data = array();
                 } else {
                     $variation_data = $variation->get_variation_attributes();
                 }
             } elseif ($product->is_type(array('subscription_variation'))) {
                 // Handle existing renewal orders incorrectly using variation_id as the product_id
                 $product_id = $product->id;
                 $variation_id = $product->get_variation_id();
                 $variation_data = $product->get_variation_attributes();
             }
             $woocommerce->cart->empty_cart(true);
             $woocommerce->cart->add_to_cart($product_id, 1, $variation_id, $variation_data, array('subscription_renewal' => array('original_order' => $original_order->id, 'failed_order' => $order_id, 'role' => $role)));
             wp_safe_redirect($woocommerce->cart->get_checkout_url());
             exit;
         }
     }
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:64,代码来源:class-wc-subscriptions-renewal-order.php

示例4: get_content_plain

 /**
  * get_content_plain function.
  *
  * @access public
  * @return string
  */
 function get_content_plain()
 {
     $order = new WC_Order($this->object['order_id']);
     $item_name = WC_Subscriptions_Order::get_item_name($this->object['order_id'], $this->object['product_id']);
     $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $this->object['product_id']);
     $product = $order->get_product_from_item($order_item);
     if (isset($product->variation_data)) {
         $item_name .= ' (' . woocommerce_get_formatted_variation($product->variation_data, true) . ')';
     }
     WC_Subscriptions_Order::$recurring_only_price_strings = true;
     $recurring_total = WC_Subscriptions_Order::get_formatted_order_total(0, $order);
     WC_Subscriptions_Order::$recurring_only_price_strings = false;
     if ($end_of_prepaid_term = wp_next_scheduled('scheduled_subscription_end_of_prepaid_term', array('user_id' => (int) $order->user_id, 'subscription_key' => $this->subscription_key))) {
         $end_of_prepaid_term = date_i18n(woocommerce_date_format(), $end_of_prepaid_term + get_option('gmt_offset') * 3600);
     }
     ob_start();
     woocommerce_get_template($this->template_plain, array('subscription_key' => $this->subscription_key, 'subscription' => $this->object, 'order' => $order, 'email_heading' => $this->get_heading(), 'item_name' => $item_name, 'recurring_total' => $recurring_total, 'last_payment' => date_i18n(woocommerce_date_format(), WC_Subscriptions_Manager::get_last_payment_date($this->subscription_key, '', 'timestamp')), 'end_of_prepaid_term' => $end_of_prepaid_term), '', $this->template_base);
     return ob_get_clean();
 }
开发者ID:bulats,项目名称:chef,代码行数:25,代码来源:class-wcs-email-cancelled-subscription.php

示例5: woo_ce_get_subscription_order_item

function woo_ce_get_subscription_order_item( $order_id = 0, $product_id = 0 ) {

	if( method_exists( 'WC_Subscriptions_Order', 'get_item_by_product_id' ) )
		$order_item = WC_Subscriptions_Order::get_item_by_product_id( $order_id, $product_id );
	return $order_item;

}
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:7,代码来源:subscription.php

示例6: get_builder_display


//.........这里部分代码省略.........
                         wc_get_template('tm-builder-element-start.php', $args, $this->_namespace, $this->template_path);
                     } else {
                         $variations_builder_element_start_args = $args;
                     }
                     $field_counter = 0;
                     $init_class = "TM_EPO_FIELDS_" . $element['type'];
                     if (!class_exists($init_class) && !empty($this->tm_builder_elements[$element['type']]["_is_addon"])) {
                         $init_class = "TM_EPO_FIELDS";
                     }
                     if (isset($this->tm_builder_elements[$element['type']]) && ($this->tm_builder_elements[$element['type']]["is_post"] == "post" || $this->tm_builder_elements[$element['type']]["is_post"] == "display") && class_exists($init_class)) {
                         $field_obj = new $init_class();
                         if ($this->tm_builder_elements[$element['type']]["is_post"] == "post") {
                             if ($this->tm_builder_elements[$element['type']]["type"] == "single" || $this->tm_builder_elements[$element['type']]["type"] == "multiplesingle") {
                                 $tabindex++;
                                 $name_inc = $this->tm_builder_elements[$element['type']]["post_name_prefix"] . "_" . $element_counter . $form_prefix;
                                 if ($this->tm_builder_elements[$element['type']]["type"] == "single") {
                                     $is_fee = !empty($element['rules_type']) && $element['rules_type'][0][0] == "subscriptionfee";
                                     $is_cart_fee = !empty($element['rules_type']) && isset($element['rules_type'][0]) && isset($element['rules_type'][0][0]) && $element['rules_type'][0][0] == "fee";
                                 } elseif ($this->tm_builder_elements[$element['type']]["type"] == "multiplesingle") {
                                     $is_fee = !empty($element['selectbox_fee']) && $element['selectbox_fee'][0][0] == "subscriptionfee";
                                     $is_cart_fee = !empty($element['selectbox_cart_fee']) && $element['selectbox_cart_fee'][0][0] == "fee";
                                 }
                                 if ($is_fee) {
                                     $name_inc = $fee_name . $name_inc;
                                 } elseif ($is_cart_fee) {
                                     $name_inc = $cart_fee_name . $name_inc;
                                 }
                                 if (isset($_GET['switch-subscription']) && (function_exists('wcs_get_subscription') || class_exists('WC_Subscriptions_Manager') && class_exists('WC_Subscriptions_Order'))) {
                                     $item = false;
                                     if (function_exists('wcs_get_subscription')) {
                                         $subscription = wcs_get_subscription($_GET['switch-subscription']);
                                         if ($subscription instanceof WC_Subscription) {
                                             $original_order = new WC_Order($subscription->order->id);
                                             $item = WC_Subscriptions_Order::get_item_by_product_id($original_order, $subscription->id);
                                         }
                                     } else {
                                         $subscription = WC_Subscriptions_Manager::get_subscription($_GET['switch-subscription']);
                                         $original_order = new WC_Order($subscription['order_id']);
                                         $item = WC_Subscriptions_Order::get_item_by_product_id($original_order, $subscription['product_id']);
                                     }
                                     if ($item) {
                                         $saved_data = maybe_unserialize($item["item_meta"]["_tmcartepo_data"][0]);
                                         foreach ($saved_data as $key => $val) {
                                             if (isset($val["key"])) {
                                                 if ($element['uniqid'] == $val["section"]) {
                                                     $_GET['tmcp_' . $name_inc] = $val["key"];
                                                     if (isset($val['quantity'])) {
                                                         $_GET['tmcp_' . $name_inc . '_quantity'] = $val['quantity'];
                                                     }
                                                 }
                                             } else {
                                                 if ($element['uniqid'] == $val["section"]) {
                                                     $_GET['tmcp_' . $name_inc] = $val["value"];
                                                     if (isset($val['quantity'])) {
                                                         $_GET['tmcp_' . $name_inc . '_quantity'] = $val['quantity'];
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 } elseif (!empty($this->cart_edit_key) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'tm-edit')) {
                                     $_cart = WC()->cart;
                                     if (isset($_cart->cart_contents) && isset($_cart->cart_contents[$this->cart_edit_key])) {
                                         if (!empty($_cart->cart_contents[$this->cart_edit_key]['tmcartepo'])) {
                                             $saved_epos = $_cart->cart_contents[$this->cart_edit_key]['tmcartepo'];
                                             foreach ($saved_epos as $key => $val) {
开发者ID:baden03,项目名称:access48,代码行数:67,代码来源:class-tm-extra-product-options.php

示例7: email_replacements

 public function email_replacements($reps, $email_data, $email_order, $email_row)
 {
     global $wpdb, $woocommerce;
     $email_type = $email_row->email_type;
     $order_date = '';
     $order_datetime = '';
     $order_id = '';
     if ($email_order->order_id) {
         $order = WC_FUE_Compatibility::wc_get_order($email_order->order_id);
         $order_date = date(get_option('date_format'), strtotime($order->order_date));
         $order_datetime = date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($order->order_date));
         $order_id = apply_filters('woocommerce_order_number', '#' . $email_order->order_id, $order);
         $billing_address = $order->get_formatted_billing_address();
         $shipping_address = $order->get_formatted_shipping_address();
         $item = WC_Subscriptions_Order::get_item_by_product_id($order);
         $item_id = WC_Subscriptions_Order::get_items_product_id($item);
         $renewal = self::calculate_next_payment_timestamp($order, $item_id);
         $subs_key = WC_Subscriptions_Manager::get_subscription_key($email_order->order_id, $item_id);
         $renew_date = date(get_option('date_format'), $renewal);
         $end_date = WC_Subscriptions_Manager::get_subscription_expiration_date($subs_key, '', 'timestamp');
         if ($end_date == 0) {
             $end_date = __('Until Cancelled', 'follow_up_emails');
         } else {
             $end_date = date(get_option('date_format'), $end_date);
         }
         // calc days to renew
         $now = current_time('timestamp');
         $diff = $renewal - $now;
         $days_to_renew = 0;
         if ($diff > 0) {
             $days_to_renew = floor($diff / 86400);
         }
         $item_url = FUE_Sending_Mailer::create_email_url($email_order->id, $email_row->id, $email_data['user_id'], $email_data['email_to'], get_permalink($item_id));
         $categories = '';
         if ($item_id) {
             $cats = get_the_terms($item_id, 'product_cat');
             if (is_array($cats) && !empty($cats)) {
                 foreach ($cats as $cat) {
                     $categories .= $cat->name . ', ';
                 }
                 $categories = rtrim($categories, ', ');
             }
         }
         $reps = array_merge($reps, array($order_id, $order_date, $order_datetime, $billing_address, $shipping_address, $email_data['username'], $email_data['first_name'], $email_data['first_name'] . ' ' . $email_data['last_name'], $email_data['email_to'], $renew_date, $end_date, $days_to_renew, '<a href="' . $item_url . '">' . get_the_title($item_id) . '</a>', $categories));
     }
     return $reps;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:47,代码来源:class-fue-addon-subscriptions.php

示例8: reactivate_subscription_with_paypal

 /**
  * When a store manager or user reactivates a subscription in the store, also reactivate the subscription with PayPal. 
  *
  * How PayPal Handles suspension is discussed here: https://www.x.com/developers/paypal/forums/nvp/reactivate-recurring-profile
  *
  * @since 1.1
  */
 public static function reactivate_subscription_with_paypal($order, $product_id)
 {
     $profile_id = self::get_subscriptions_paypal_id($order, $product_id);
     // Make sure a subscriptions status is active with PayPal
     $response = self::change_subscription_status($profile_id, 'Reactivate');
     $item = WC_Subscriptions_Order::get_item_by_product_id($order, $product_id);
     if (isset($response['ACK']) && $response['ACK'] == 'Success') {
         $order->add_order_note(sprintf(__('Subscription "%s" reactivated with PayPal', WC_Subscriptions::$text_domain), $item['name']));
     }
 }
开发者ID:bulats,项目名称:chef,代码行数:17,代码来源:gateway-paypal-standard-subscriptions.php

示例9: process_subscription_payment_failure

 /**
  * Processes a failed payment on a subscription by recording the failed payment and cancelling the subscription if it exceeds the 
  * maximum number of failed payments allowed on the site. 
  *
  * @param $user_id int The id of the user who owns the expiring subscription. 
  * @param $subscription_key string A subscription key of the form obtained by @see get_subscription_key( $order_id, $product_id )
  * @since 1.0
  */
 public static function process_subscription_payment_failure($user_id, $subscription_key)
 {
     // Store a record of the subscription payment date
     $subscription = self::get_users_subscription($user_id, $subscription_key);
     if (!isset($subscription['failed_payments'])) {
         $subscription['failed_payments'] = 0;
     }
     $subscription['failed_payments'] = $subscription['failed_payments'] + 1;
     self::update_users_subscriptions($user_id, array($subscription_key => $subscription));
     $order = new WC_Order($subscription['order_id']);
     $item = WC_Subscriptions_Order::get_item_by_product_id($order, $subscription['product_id']);
     $max_failed_payments = get_option(WC_Subscriptions_Admin::$option_prefix . '_max_failed_payments', 3);
     // Allow a short circuit for plugins & payment gateways to force max failed payments exceeded
     $failed_payments_exceeded = apply_filters('woocommerce_subscriptions_max_failed_payments_exceeded', false, $user_id, $subscription_key);
     // Have we reached the maximum failed payments allowed on the subscription
     if ($failed_payments_exceeded || $subscription['failed_payments'] >= $max_failed_payments && intval($max_failed_payments) !== 0) {
         self::cancel_subscription($user_id, $subscription_key);
         $order->add_order_note(sprintf(__('Cancelled Subscription "%s". Maximum number of failed subscription payments reached.', WC_Subscriptions::$text_domain), $item['name']));
         if ('yes' == get_option(WC_Subscriptions_Admin::$option_prefix . '_generate_renewal_order')) {
             $renewal_order_id = WC_Subscriptions_Renewal_Order::generate_renewal_order($order, $subscription['product_id'], array('new_order_role' => 'parent'));
         }
     } else {
         // Log payment failure on order
         $order->add_order_note(sprintf(__('Payment failed for subscription "%s".', WC_Subscriptions::$text_domain), $item['name']));
         // Place the subscription on-hold
         self::put_subscription_on_hold($user_id, $subscription_key);
     }
     do_action('processed_subscription_payment_failure', $user_id, $subscription_key);
 }
开发者ID:bulats,项目名称:chef,代码行数:37,代码来源:class-wc-subscriptions-manager.php

示例10:

">
					<?php 
        }
        ?>
						<?php 
        echo WC_Subscriptions_Order::get_item_name($subscription_details['order_id'], $subscription_details['product_id']);
        ?>
					<?php 
        if (false !== $product) {
            ?>
					</a>
					<?php 
        }
        ?>
					<?php 
        $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $subscription_details['product_id']);
        ?>
					<?php 
        if (WC_Subscriptions::is_woocommerce_pre('2.4')) {
            ?>
						<?php 
            $item_meta = new WC_Order_Item_Meta($order_item['item_meta'], $product);
            ?>
					<?php 
        } else {
            ?>
						<?php 
            $item_meta = new WC_Order_Item_Meta($order_item, $product);
            ?>
					<?php 
        }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:31,代码来源:my-subscriptions.php

示例11: replace_variables

 public function replace_variables($text, $email_order)
 {
     $order = new WC_Order($email_order->order_id);
     $item = WC_Subscriptions_Order::get_item_by_product_id($order);
     $item_id = WC_Subscriptions_Order::get_items_product_id($item);
     $renewal = WC_Subscriptions_Order::get_next_payment_timestamp($order, $item_id);
     $renew_date = date(get_option('date_format'), $renewal);
     // calc days to renew
     $now = current_time('timestamp');
     $diff = $renewal - $now;
     $days_to_renew = 0;
     if ($diff > 0) {
         $days_to_renew = floor($diff / 86400);
     }
     $search = array('{subs_renew_date}', '{days_to_renew}');
     $replacements = array($renew_date, $days_to_renew);
     return str_replace($search, $replacements, $text);
 }
开发者ID:bulats,项目名称:chef,代码行数:18,代码来源:class.fue_subscriptions.php

示例12: prepare_items

 /**
  * Get, sort and filter subscriptions for display.
  *
  * @uses $this->_column_headers
  * @uses $this->items
  * @uses $this->get_columns()
  * @uses $this->get_sortable_columns()
  * @uses $this->get_pagenum()
  * @uses $this->set_pagination_args()
  * @since 1.0
  */
 function prepare_items()
 {
     $screen = get_current_screen();
     $per_page = $this->get_items_per_page($screen->get_option('per_page', 'option'), 10);
     $this->get_column_info();
     $this->process_actions();
     if (isset($_REQUEST['s'])) {
         $subscriptions_grouped_by_user = WC_Subscriptions_Manager::search_subscriptions($_REQUEST['s']);
     } elseif (isset($_GET['_customer_user']) || isset($_GET['_product_id'])) {
         if (isset($_GET['_customer_user']) && !empty($_GET['_customer_user'])) {
             $subscriptions_grouped_by_user = array($_GET['_customer_user'] => WC_Subscriptions_Manager::get_users_subscriptions($_GET['_customer_user']));
         } else {
             $subscriptions_grouped_by_user = WC_Subscriptions_Manager::get_all_users_subscriptions();
         }
         if (isset($_GET['_product_id']) && !empty($_GET['_product_id'])) {
             foreach ($subscriptions_grouped_by_user as $user_id => $subscriptions) {
                 foreach ($subscriptions as $subscription_key => $subscription) {
                     if ($subscription['product_id'] == intval($_GET['_product_id'])) {
                         continue;
                     }
                     $order_item = WC_Subscriptions_Order::get_item_by_product_id($subscription['order_id'], $subscription['product_id']);
                     if (isset($order_item['variation_id']) && $order_item['variation_id'] == intval($_GET['_product_id'])) {
                         continue;
                     }
                     unset($subscriptions_grouped_by_user[$user_id][$subscription_key]);
                 }
             }
         }
     } else {
         $subscriptions_grouped_by_user = WC_Subscriptions_Manager::get_all_users_subscriptions();
     }
     $status_to_show = isset($_GET['status']) ? $_GET['status'] : 'all';
     // Reformat the subscriptions grouped by user to be usable by each row
     $subscriptions = array();
     $this->statuses = array();
     foreach ($subscriptions_grouped_by_user as $user_id => $users_subscriptions) {
         foreach ($users_subscriptions as $subscription_key => $subscription) {
             $this->statuses[$subscription['status']] = isset($this->statuses[$subscription['status']]) ? $this->statuses[$subscription['status']] + 1 : 1;
             $all_subscriptions[$subscription_key] = $subscription + array('user_id' => $user_id, 'subscription_key' => $subscription_key);
             if ($status_to_show == $subscription['status'] || $status_to_show == 'all' && $subscription['status'] != 'trash') {
                 $subscriptions[$subscription_key] = $subscription + array('user_id' => $user_id, 'subscription_key' => $subscription_key);
             }
         }
     }
     // If we have a request for a status that does not exist, default to all subscriptions
     if (!isset($this->statuses[$status_to_show])) {
         if ($status_to_show != 'all') {
             $status_to_show = $_GET['status'] = 'all';
             foreach ($all_subscriptions as $subscription_key => $subscription) {
                 if ($all_subscriptions[$subscription_key]['status'] != 'trash') {
                     $subscriptions = $subscriptions + array($subscription_key => $subscription);
                 }
             }
         } else {
             $_GET['status'] = 'all';
         }
     }
     ksort($this->statuses);
     $this->statuses = array('all' => array_sum($this->statuses)) + $this->statuses;
     if (isset($this->statuses['trash'])) {
         $this->statuses['all'] = $this->statuses['all'] - $this->statuses['trash'];
     }
     usort($subscriptions, array(&$this, 'sort_subscriptions'));
     // Add sorted & sliced data to the items property to be used by the rest of the class
     $this->items = array_slice($subscriptions, ($this->get_pagenum() - 1) * $per_page, $per_page);
     $total_items = count($subscriptions);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
开发者ID:bulats,项目名称:chef,代码行数:79,代码来源:class-wc-subscriptions-list-table.php

示例13: wc_subs_exporter_create_csv

 function wc_subs_exporter_create_csv($export)
 {
     global $wc_subs_exporter;
     if (!$export->status) {
         return false;
     }
     if (empty($export->subscriptions)) {
         return false;
     }
     $subscription_statuses = wc_subs_exporter_get_subscription_statuses();
     $fields = array(__('Order Id', 'wc-subs-exporter'), __('Order Status', 'wc-subs-exporter'), __('Subscription Status', 'wc-subs-exporter'), __('Subscription Description', 'wc-subs-exporter'), __('Subscription Start Date', 'wc-subs-exporter'), __('Subscription Expiration Date', 'wc-subs-exporter'), __('Subscription Last Payment', 'wc-subs-exporter'), __('Email', 'wc-subs-exporter'), __('Billing First Name', 'wc-subs-exporter'), __('Billing Last Name', 'wc-subs-exporter'), __('Billing Address 1', 'wc-subs-exporter'), __('Billing Address 2', 'wc-subs-exporter'), __('Billing City', 'wc-subs-exporter'), __('Billing State', 'wc-subs-exporter'), __('Billing Zip', 'wc-subs-exporter'), __('Billing Country', 'wc-subs-exporter'), __('Shipping First Name', 'wc-subs-exporter'), __('Shipping Last Name', 'wc-subs-exporter'), __('Shipping Address 1', 'wc-subs-exporter'), __('Shipping Address 2', 'wc-subs-exporter'), __('Shipping City', 'wc-subs-exporter'), __('Shipping State', 'wc-subs-exporter'), __('Shipping Zip', 'wc-subs-exporter'), __('Shipping Country', 'wc-subs-exporter'), __('Product SKU', 'wc-subs-exporter'), __('Product Description', 'wc-subs-exporter'), __('Quantity', 'wc-subs-exporter'), __('Date Ordered', 'wc-subs-exporter'), __('Coupon Code Used', 'wc-subs-exporter'));
     $csv = '';
     if ($export->bom) {
         $csv .= chr(239) . chr(187) . chr(191) . '';
     }
     foreach ($fields as $field) {
         $csv .= wc_subs_exporter_escape_csv_value($field, $export->delimiter, $export->escape_formatting) . $export->delimiter;
     }
     $csv = substr($csv, 0, -strlen($export->delimiter)) . "\n";
     $processed_rows = 0;
     foreach ($export->subscriptions as $user => $user_subscriptions) {
         foreach ($user_subscriptions as $key => $subscription) {
             $order = new WC_Order($subscription['order_id']);
             $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $subscription['product_id']);
             $product = $order->get_product_from_item($order_item);
             if (empty($product)) {
                 continue;
             }
             $product_sku = $product->get_sku();
             $product_title = WC_Subscriptions_Order::get_item_name($subscription['order_id'], $subscription['product_id']);
             if (isset($product->variation_data)) {
                 $product_description = woocommerce_get_formatted_variation($product->variation_data, true);
             } else {
                 $product_description = $product_title;
             }
             $coupon_code_used = '';
             $coupons = $order->get_items(array('coupon'));
             foreach ($coupons as $item_id => $item) {
                 $coupon_code_used .= $item['name'] . ' ';
             }
             $start_date = substr($subscription['start_date'], 0, 10);
             if ($subscription['expiry_date']) {
                 $end_date = substr($subscription['expiry_date'], 0, 10);
             } else {
                 $end_date = '0000-00-00';
             }
             if ($order->user_id > 0) {
                 $user_info = get_userdata($order->user_id);
             }
             if (array_key_exists('completed_payments', $subscription) && is_array($subscription['completed_payments'])) {
                 $recent_payment = substr(end($subscription['completed_payments']), 0, 10);
             } else {
                 $recent_payment = '';
             }
             $order_date = substr($order->completed_date, 0, 10);
             $csv .= wc_subs_exporter_escape_csv_value($order->id, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->status, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($subscription_statuses[$subscription['status']], $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($product_title, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($start_date, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($end_date, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($recent_payment, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($user_info->user_email, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_first_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_last_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_address_1, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_address_2, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_city, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_state, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_postcode, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->billing_country, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_first_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_last_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_address_1, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_address_2, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_city, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_state, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_postcode, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order->shipping_country, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($product_sku, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($product_description, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value(1, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value($order_date, $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= wc_subs_exporter_escape_csv_value(trim($coupon_code_used), $export->delimiter, $export->escape_formatting) . $export->delimiter;
             $csv .= "\n";
         }
     }
     if (!$csv) {
         return false;
     } else {
         if (isset($wc_subs_exporter['debug']) && $wc_subs_exporter['debug']) {
             $wc_subs_exporter['debug_log'] = $csv;
         } else {
             return $csv;
         }
     }
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:97,代码来源:functions.php

示例14: process_subscription_payment_failure

 /**
  * Processes a failed payment on a subscription by recording the failed payment and cancelling the subscription if it exceeds the 
  * maximum number of failed payments allowed on the site. 
  *
  * @param int $user_id The id of the user who owns the expiring subscription. 
  * @param string $subscription_key A subscription key of the form obtained by @see get_subscription_key( $order_id, $product_id )
  * @since 1.0
  */
 public static function process_subscription_payment_failure($user_id, $subscription_key)
 {
     // Store a record of the subscription payment date
     $subscription = self::get_subscription($subscription_key);
     if (!isset($subscription['failed_payments'])) {
         $subscription['failed_payments'] = 0;
     }
     $subscription['failed_payments'] = $subscription['failed_payments'] + 1;
     self::update_users_subscriptions($user_id, array($subscription_key => $subscription));
     $order = new WC_Order($subscription['order_id']);
     $item = WC_Subscriptions_Order::get_item_by_product_id($order, $subscription['product_id']);
     // Allow a short circuit for plugins & payment gateways to force max failed payments exceeded
     if (apply_filters('woocommerce_subscriptions_max_failed_payments_exceeded', false, $user_id, $subscription_key)) {
         self::cancel_subscription($user_id, $subscription_key);
         $order->add_order_note(sprintf(__('Cancelled Subscription "%s". Maximum number of failed subscription payments reached.', 'woocommerce-subscriptions'), $item['name']));
         $renewal_order_id = WC_Subscriptions_Renewal_Order::generate_renewal_order($order, $subscription['product_id'], array('new_order_role' => 'parent'));
     } else {
         // Log payment failure on order
         $order->add_order_note(sprintf(__('Payment failed for subscription "%s".', 'woocommerce-subscriptions'), $item['name']));
         // Place the subscription on-hold
         self::put_subscription_on_hold($user_id, $subscription_key);
     }
     do_action('processed_subscription_payment_failure', $user_id, $subscription_key);
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:32,代码来源:class-wc-subscriptions-manager.php

示例15: do_subscriptions_shortcode

    /**
     * Callback for the [subscriptions] shortcode that displays subscription names for a particular user.
     *
     * @param array $attributes Shortcode attributes.
     * @return string
     */
    public static function do_subscriptions_shortcode($attributes)
    {
        $attributes = wp_parse_args($attributes, array('user_id' => 0, 'status' => 'active'));
        $status = $attributes['status'];
        $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($attributes['user_id']);
        if (empty($subscriptions)) {
            return '<ul class="user-subscriptions no-user-subscriptions">
						<li>No subscriptions found.</li>
					</ul>';
        }
        $list = '<ul class="user-subscriptions">';
        foreach ($subscriptions as $subscription) {
            if ($subscription['status'] == $status || $status == 'all') {
                $subscription_details = WC_Subscriptions_Order::get_item_name($subscription['order_id'], $subscription['product_id']);
                $order = new WC_Order($subscription['order_id']);
                $order_item = WC_Subscriptions_Order::get_item_by_product_id($subscription['order_id'], $subscription['product_id']);
                $product = $order->get_product_from_item($order_item);
                if (isset($product->variation_data)) {
                    $subscription_details .= ' <span class="subscription-variation-data">(' . woocommerce_get_formatted_variation($product->variation_data, true) . ')</span>';
                }
                $list .= sprintf('<li>%s</li>', $subscription_details);
            }
        }
        $list .= '</ul>';
        return $list;
    }
开发者ID:bulats,项目名称:chef,代码行数:32,代码来源:class-wc-subscriptions-admin.php


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