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


PHP WC_Subscriptions_Manager::get_subscription方法代码示例

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


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

示例1: trigger

 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($subscription_key)
 {
     global $woocommerce;
     $this->subscription_key = $subscription_key;
     $this->object = WC_Subscriptions_Manager::get_subscription($subscription_key);
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
开发者ID:bulats,项目名称:chef,代码行数:16,代码来源:class-wcs-email-cancelled-subscription.php

示例2: filter_woocommerce_my_account_my_orders_actions

 /**
  * Customise which actions are shown against a subscriptions order on the My Account page.
  *
  * @since 1.3
  */
 public static function filter_woocommerce_my_account_my_orders_actions($actions, $order)
 {
     if (WC_Subscriptions_Order::order_contains_subscription($order) || WC_Subscriptions_Renewal_Order::is_renewal($order)) {
         unset($actions['cancel']);
         if (is_numeric(get_post_meta($order->id, '_failed_order_replaced_by', true))) {
             unset($actions['pay']);
         }
         $original_order = WC_Subscriptions_Renewal_Order::get_parent_order($order);
         $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);
         $subscription_key = WC_Subscriptions_Manager::get_subscription_key($original_order->id, $product_id);
         $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
         if (empty($subscription) || !in_array($subscription['status'], array('on-hold', 'pending'))) {
             unset($actions['pay']);
         }
     }
     return $actions;
 }
开发者ID:bulats,项目名称:chef,代码行数:24,代码来源:class-wc-subscriptions-checkout.php

示例3: wc_subs_exporter_get_filtered_subscriptions

 function wc_subs_exporter_get_filtered_subscriptions($export)
 {
     global $wpdb;
     $subscriptions = $filtered_subscriptions = array();
     $sql = "SELECT DISTINCT i.order_id, m.product_id, p.meta_value\n\t\t\t\tFROM\n\t\t\t\t(\n\t\t\t\tSELECT order_item_id,\n\t\t\t\tMAX(CASE WHEN meta_key = '_product_id' THEN meta_value END) product_id\n\t\t\t\tFROM {$wpdb->prefix}woocommerce_order_itemmeta\n\t\t\t\tWHERE meta_key LIKE '_subscription%' \n\t\t\t\t\tOR meta_key LIKE '_recurring%'\n\t\t\t\t\tOR meta_key = '_product_id'\n\t\t\t\tGROUP BY order_item_id\n\t\t\t\tHAVING MAX(meta_key LIKE '_subscription%')\n\t\t\t\t\t+ MAX(meta_key LIKE '_recurring%') > 0\n\t\t\t\t) m JOIN {$wpdb->prefix}woocommerce_order_items i \n\t\t\t\tON m.order_item_id = i.order_item_id \n\t\t\t\tLEFT JOIN {$wpdb->prefix}postmeta p \n\t\t\t\tON i.order_id = p.post_id \n\t\t\t\tAND p.meta_key = '_customer_user'\n\t\t\t\tLEFT JOIN {$wpdb->prefix}posts po \n\t\t\t\tON p.post_id = po.ID\n\t\t\t\tWHERE po.post_type = 'shop_order' AND po.post_parent = 0";
     $order_ids_and_product_ids = $wpdb->get_results($sql);
     foreach ($order_ids_and_product_ids as $order_id_and_product_id) {
         if (empty($order_id_and_product_id->product_id)) {
             continue;
         }
         $subscription_key = $order_id_and_product_id->order_id . '_' . $order_id_and_product_id->product_id;
         $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
         if (empty($subscription)) {
             continue;
         }
         // filter status
         if (!array_key_exists($subscription['status'], $export->status)) {
             continue;
         }
         // filter dates
         if ($export->dates_from && strtotime($subscription['start_date']) < strtotime($export->dates_from)) {
             continue;
         } elseif ($export->dates_to && strtotime($subscription['start_date']) > strtotime($export->dates_to)) {
             continue;
         }
         $subscriptions[$order_id_and_product_id->meta_value][$subscription_key] = $subscription;
     }
     $processed_rows = 0;
     foreach ($subscriptions as $user => $user_subscriptions) {
         if (++$processed_rows <= $export->offset) {
             continue;
         }
         foreach ($user_subscriptions as $key => $subscription) {
             $filtered_subscriptions[$user][$key] = $subscription;
         }
         if ($processed_rows == $export->limit_volume) {
             break;
         }
     }
     return $filtered_subscriptions;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:41,代码来源:functions.php

示例4: maybe_replace_pay_shortcode

 /**
  * If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form.
  *
  * @since 1.4
  */
 public static function maybe_replace_pay_shortcode()
 {
     global $woocommerce;
     if (!self::$is_request_to_change_payment) {
         return;
     }
     ob_clean();
     do_action('before_woocommerce_pay');
     echo '<div class="woocommerce">';
     if (!empty(self::$woocommerce_errors)) {
         foreach (self::$woocommerce_errors as $error) {
             WC_Subscriptions::add_notice($error, 'error');
         }
     }
     if (!empty(self::$woocommerce_messages)) {
         foreach (self::$woocommerce_messages as $message) {
             WC_Subscriptions::add_notice($message, 'success');
         }
     }
     $subscription_key = $_GET['change_payment_method'];
     $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
     if (wp_verify_nonce($_GET['_wpnonce'], __FILE__) === false) {
         WC_Subscriptions::add_notice(__('There was an error with your request. Please try again.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } elseif (!WC_Subscriptions_Manager::user_owns_subscription($subscription_key)) {
         WC_Subscriptions::add_notice(__('That doesn\'t appear to be one of your subscriptions.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } elseif (empty($subscription)) {
         WC_Subscriptions::add_notice(__('Invalid subscription.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } elseif (!WC_Subscriptions_Manager::can_subscription_be_changed_to('new-payment-method', $subscription_key, get_current_user_id())) {
         WC_Subscriptions::add_notice(__('The payment method can not be changed for that subscription.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } else {
         $order = new WC_Order($subscription['order_id']);
         $order_id = absint($_GET['order_id']);
         $order_key = isset($_GET['key']) ? $_GET['key'] : $_GET['order'];
         $product_id = $subscription['product_id'];
         $next_payment_timestamp = WC_Subscriptions_Order::get_next_payment_timestamp($order, $product_id);
         if (!empty($next_payment_timestamp)) {
             $next_payment_string = sprintf(__(' Next payment is due %s.', 'woocommerce-subscriptions'), date_i18n(woocommerce_date_format(), $next_payment_timestamp));
         } else {
             $next_payment_string = '';
         }
         WC_Subscriptions::add_notice(sprintf(__('Choose a new payment method.%s', 'woocommerce-subscriptions'), $next_payment_string), 'notice');
         WC_Subscriptions::print_notices();
         if ($order->order_key == $order_key) {
             // Set customer location to order location
             if ($order->billing_country) {
                 $woocommerce->customer->set_country($order->billing_country);
             }
             if ($order->billing_state) {
                 $woocommerce->customer->set_state($order->billing_state);
             }
             if ($order->billing_postcode) {
                 $woocommerce->customer->set_postcode($order->billing_postcode);
             }
             // Show form
             WC_Subscriptions_Order::$recurring_only_price_strings = true;
             woocommerce_get_template('checkout/form-change-payment-method.php', array('order' => $order, 'subscription_key' => $subscription_key), '', plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/');
             WC_Subscriptions_Order::$recurring_only_price_strings = false;
         } else {
             WC_Subscriptions::add_notice(__('Invalid order.', 'woocommerce-subscriptions'), 'error');
             WC_Subscriptions::print_notices();
         }
     }
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:72,代码来源:class-wc-subscriptions-change-payment-gateway.php

示例5: get_first_payment_date

 /**
  * Make sure anything requesting the first payment date for a synced subscription on the front-end receives
  * a date which takes into account the day on which payments should be processed.
  *
  * This is necessary as the self::calculate_first_payment_date() is not called when the subscription is active
  * (which it isn't until the first payment is completed and the subscription is activated).
  *
  * @since 1.5
  */
 public static function get_first_payment_date($first_payment_date, $order, $product_id, $type)
 {
     $subscription_key = WC_Subscriptions_Manager::get_subscription_key($order->id, $product_id);
     if (self::order_contains_synced_subscription($order->id) && 1 >= WC_Subscriptions_Manager::get_subscriptions_completed_payment_count($subscription_key)) {
         $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
         // Don't prematurely set the first payment date when manually adding a subscription from the admin
         if (defined('WOOCOMMERCE_CHECKOUT') && true === WOOCOMMERCE_CHECKOUT || !is_admin() || 'active' == $subscription['status']) {
             $id_for_calculation = !empty($subscription['variation_id']) ? $subscription['variation_id'] : $subscription['product_id'];
             $first_payment_timestamp = self::calculate_first_payment_date($id_for_calculation, 'timestamp', $order->order_date);
             if (0 != $first_payment_timestamp) {
                 $first_payment_date = 'mysql' == $type ? date('Y-m-d H:i:s', $first_payment_timestamp) : $first_payment_timestamp;
             }
         }
     }
     return $first_payment_date;
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:25,代码来源:class-wc-subscriptions-synchroniser.php

示例6: get_all_users_subscriptions

 /**
  * Gets all the active and inactive subscriptions for all users.
  *
  * @return array An associative array containing all users with subscriptions and the details of their subscriptions: 'user_id' => $subscriptions
  * @since 1.0
  */
 public static function get_all_users_subscriptions()
 {
     global $wpdb;
     $subscriptions = array();
     $sql = "SELECT DISTINCT i.order_id, m.product_id, p.meta_value\n\t\t\t\tFROM\n\t\t\t\t(\n\t\t\t\tSELECT order_item_id,\n\t\t\t\tMAX(CASE WHEN meta_key = '_product_id' THEN meta_value END) product_id\n\t\t\t\tFROM {$wpdb->prefix}woocommerce_order_itemmeta\n\t\t\t\tWHERE meta_key LIKE '_subscription%' \n\t\t\t\t\tOR meta_key LIKE '_recurring%'\n\t\t\t\t\tOR meta_key = '_product_id'\n\t\t\t\tGROUP BY order_item_id\n\t\t\t\tHAVING MAX(meta_key LIKE '_subscription%')\n\t\t\t\t\t+ MAX(meta_key LIKE '_recurring%') > 0\n\t\t\t\t) m JOIN {$wpdb->prefix}woocommerce_order_items i \n\t\t\t\tON m.order_item_id = i.order_item_id \n\t\t\t\tLEFT JOIN {$wpdb->prefix}postmeta p \n\t\t\t\tON i.order_id = p.post_id \n\t\t\t\tAND p.meta_key = '_customer_user'\n\t\t\t\tLEFT JOIN {$wpdb->prefix}posts po \n\t\t\t\tON p.post_id = po.ID\n\t\t\t\tWHERE po.post_type = 'shop_order' AND po.post_parent = 0";
     $order_ids_and_product_ids = $wpdb->get_results($sql);
     foreach ($order_ids_and_product_ids as $order_id_and_product_id) {
         if (empty($order_id_and_product_id->product_id)) {
             continue;
         }
         $subscription_key = $order_id_and_product_id->order_id . '_' . $order_id_and_product_id->product_id;
         $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
         $subscriptions[$order_id_and_product_id->meta_value][$subscription_key] = $subscription;
     }
     return apply_filters('woocommerce_all_users_subscriptions', $subscriptions);
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:22,代码来源:class-wc-subscriptions-manager.php

示例7: get_user_membership_subscription

 /**
  * Get the subscription for a membership
  *
  * @since 1.0.0
  * @param int $user_membership_id User Membership ID
  * @return array|null Subscription or null, if not found
  */
 public function get_user_membership_subscription($user_membership_id)
 {
     // 2.0 onwards
     if ($this->is_subscriptions_gte_2_0()) {
         $subscription_id = $this->get_user_membership_subscription_id($user_membership_id);
         if (!$subscription_id) {
             return null;
         }
         return wcs_get_subscription($subscription_id);
     } else {
         $subscription_key = $this->get_user_membership_subscription_key($user_membership_id);
         if (!$subscription_key) {
             return null;
         }
         $user_membership = wc_memberships_get_user_membership($user_membership_id);
         // It seems that the order has been deleted
         if (false === get_post_status($user_membership->get_order_id())) {
             return null;
         }
         // It seems the subscription product has been removed from the order
         if (!WC_Subscriptions_Order::get_item_id_by_subscription_key($subscription_key)) {
             return null;
         }
         return WC_Subscriptions_Manager::get_subscription($subscription_key);
     }
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:33,代码来源:class-wc-memberships-integration-subscriptions.php

示例8: can_subscription_be_renewed

 /**
  * Check if a given subscription can be renewed. 
  *
  * For a subscription to be renewable, it must be inactive (expired or cancelled) and its parent order
  * must not have already been superseded by a renewal order. This last part is mainly just to prevent
  * displaying "Renew" links on subscriptions that have already been renewed.
  *
  * @param $subscription_key string A subscription key of the form created by @see self::get_subscription_key()
  * @param $user_id int The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
  * @since 1.2
  */
 public static function can_subscription_be_renewed($subscription_key, $user_id = '')
 {
     $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key, $user_id);
     if (empty($subscription)) {
         $subscription_can_be_renewed = false;
     } else {
         $renewal_orders = get_posts(array('meta_key' => '_original_order', 'meta_value' => $subscription['order_id'], 'post_type' => 'shop_order', 'post_parent' => 0));
         if (empty($renewal_orders) && in_array($subscription['status'], array('cancelled', 'expired', 'trash', 'failed'))) {
             $subscription_can_be_renewed = true;
         } else {
             $subscription_can_be_renewed = false;
         }
     }
     return apply_filters('woocommerce_can_subscription_be_renewed', $subscription_can_be_renewed, $subscription, $subscription_key, $user_id);
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:26,代码来源:class-wc-subscriptions-renewal-order.php

示例9: maybe_update_subscription_order_addresses

 public function maybe_update_subscription_order_addresses($user_id, $load_address)
 {
     global $woocommerce, $wp;
     if (!WC_Subscriptions_Manager::user_has_subscription($user_id)) {
         return;
     }
     if ($load_address != 'shipping') {
         return;
     }
     $subscription_ids = array();
     if (isset($_POST['update_all_subscriptions_addresses'])) {
         $users_subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($user_id);
         foreach ($users_subscriptions as $subscription) {
             array_push($subscription_ids, $subscription['order_id']);
         }
     } elseif (isset($_POST['update_subscription_address'])) {
         $subscription = WC_Subscriptions_Manager::get_subscription($_POST['update_subscription_address']);
         // Update the address only if the user actually owns the subscription
         if (!empty($subscription)) {
             array_push($subscription_ids, $subscription['order_id']);
         }
     }
     if (count($subscription_ids) > 0) {
         $base_order = $order = wc_get_order($subscription_ids[0]);
         $args = array('numberposts' => -1, 'post_type' => 'shop_order', 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'shop_order_status', 'field' => 'slug', 'terms' => array('processing'))), 'meta_query' => array(array('key' => '_customer_user', 'value' => $user_id), array('key' => '_original_order', 'value' => $subscription_ids)));
         $posts = get_posts($args);
         $address = array('first_name' => $base_order->shipping_first_name, 'last_name' => $base_order->shipping_last_name, 'address_1' => $base_order->shipping_address_1, 'address_2' => $base_order->shipping_address_2, 'city' => $base_order->shipping_city, 'state' => $base_order->shipping_state, 'postcode' => $base_order->shipping_postcode, 'country' => $base_order->shipping_country);
         foreach ($posts as $post) {
             $order = wc_get_order($post->ID);
             $order->set_address($address, 'shipping');
         }
     }
 }
开发者ID:whatthefork,项目名称:woocommerce-fedex-shipping-labels,代码行数:33,代码来源:woocommerce-fedex-shipping-labels.php

示例10: sensei_customer_bought_product

 /**
  * Checks if a user (by email) has bought an item.
  * @access public
  * @since  1.0.0
  * @param  string $customer_email
  * @param  int $user_id
  * @param  int $product_id
  * @return bool
  */
 public static function sensei_customer_bought_product($customer_email, $user_id, $product_id)
 {
     global $wpdb;
     $emails = array();
     if ($user_id) {
         $user = get_user_by('id', intval($user_id));
         $emails[] = $user->user_email;
     }
     if (is_email($customer_email)) {
         $emails[] = $customer_email;
     }
     if (sizeof($emails) == 0) {
         return false;
     }
     $orders = get_posts(array('posts_per_page' => -1, 'meta_key' => '_customer_user', 'meta_value' => intval($user_id), 'post_type' => 'shop_order', 'post_status' => array('wc-processing', 'wc-completed')));
     foreach ($orders as $order_id) {
         $order = new WC_Order($order_id->ID);
         if ($order->post_status == 'wc-completed') {
             if (0 < sizeof($order->get_items())) {
                 foreach ($order->get_items() as $item) {
                     // Allow product ID to be filtered
                     $product_id = apply_filters('sensei_bought_product_id', $product_id, $order);
                     // Check if user has bought product
                     if ($item['product_id'] == $product_id || $item['variation_id'] == $product_id) {
                         // Check if user has an active subscription for product
                         if (class_exists('WC_Subscriptions_Manager')) {
                             $sub_key = WC_Subscriptions_Manager::get_subscription_key($order_id->ID, $product_id);
                             if ($sub_key) {
                                 $sub = WC_Subscriptions_Manager::get_subscription($sub_key);
                                 if ($sub && isset($sub['status'])) {
                                     if ('active' == $sub['status']) {
                                         return true;
                                     } else {
                                         return false;
                                     }
                                 }
                             }
                         }
                         // Customer has bought product
                         return true;
                     }
                     // End If Statement
                 }
                 // End For Loop
             }
             // End If Statement
         }
         // End If Statement
     }
     // End For Loop
 }
开发者ID:grey-rsi,项目名称:sensei,代码行数:60,代码来源:class-woothemes-sensei-utils.php

示例11: maybe_record_order_payment

 /**
  * Records the initial payment against a subscription. 
  *
  * This function is called when a gateway calls @see WC_Order::payment_complete() and payment
  * is completed on an order. It is also called when an orders status is changed to completed or
  * processing for those gateways which never call @see WC_Order::payment_complete(), like the 
  * core WooCommerce Cheque and Bank Transfer gateways.
  *
  * @param $order WC_Order | int A WC_Order object or ID of a WC_Order order.
  * @since 1.1.2
  */
 public static function maybe_record_order_payment($order)
 {
     if (!is_object($order)) {
         $order = new WC_Order($order);
     }
     $subscriptions_in_order = self::get_recurring_items($order);
     foreach ($subscriptions_in_order as $subscription_item) {
         $subscription_key = WC_Subscriptions_Manager::get_subscription_key($order->id, $subscription_item['id']);
         $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key, $order->customer_user);
         // No payments have been recorded yet
         if (empty($subscription['completed_payments'])) {
             // Don't duplicate orders
             remove_action('processed_subscription_payment', 'WC_Subscriptions_Renewal_Order::generate_paid_renewal_order', 10, 2);
             WC_Subscriptions_Manager::process_subscription_payments_on_order($order->id);
             WC_Subscriptions_Manager::safeguard_scheduled_payments($order->customer_user, $subscription_key);
             // Make sure orders are still generated for other payments in the same request
             add_action('processed_subscription_payment', 'WC_Subscriptions_Renewal_Order::generate_paid_renewal_order', 10, 2);
         }
     }
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:31,代码来源:class-wc-subscriptions-order.php

示例12: maybe_update_subscription_addresses

 /**
  * When a subscriber's billing or shipping address is successfully updated, check if the subscriber
  * has also requested to update the addresses on existing subscriptions and if so, go ahead and update
  * the addresses on the initial order for each subscription.
  *
  * @param int $user_id The ID of a user who own's the subscription (and address)
  * @since 1.3
  */
 public static function maybe_update_subscription_addresses($user_id)
 {
     global $woocommerce;
     if (!WC_Subscriptions_Manager::user_has_subscription($user_id) || !isset($_GET['address'])) {
         return;
     }
     $load_address = isset($_GET['address']) ? esc_attr($_GET['address']) : '';
     $load_address = $load_address == 'billing' || $load_address == 'shipping' ? $load_address : '';
     $address_fields = $woocommerce->countries->get_address_fields(esc_attr($_POST[$load_address . '_country']), $load_address . '_');
     if (isset($_POST['update_all_subscriptions_addresses'])) {
         $users_subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($user_id);
         foreach ($users_subscriptions as $subscription) {
             self::maybe_update_order_address($subscription, $address_fields);
         }
     } elseif (isset($_POST['update_subscription_address'])) {
         $subscription = WC_Subscriptions_Manager::get_subscription($_POST['update_subscription_address']);
         // Update the address only if the user actually owns the subscription
         if (!empty($subscription)) {
             self::maybe_update_order_address($subscription, $address_fields);
         }
     }
 }
开发者ID:bulats,项目名称:chef,代码行数:30,代码来源:class-wc-subscriptions-addresses.php

示例13: ps_do_this_daily

/**
 * On the scheduled action hook, run the function.
 */
function ps_do_this_daily()
{
    global $wpdb;
    //    if(date('l') == "Saturday") {        // Cron run daily but execute only in sunday
    $allUser = $wpdb->get_results('SELECT * FROM wp_users WHERE 1;');
    //		if(date('l') != "Tuesday" || date('l') != "Wednesday")
    $nxtTues = date_i18n('Ymd', strtotime('next tuesday'));
    // Get the Next Tuesday to run cron
    /*		else 
    			$nxtTues =  date('Ymd', strtotime('next tuesday'));         // Get the Next Tuesday to run cron*/
    //$nxtTues = $nxtTues + 7;
    $wsm = new WC_Subscriptions_Manager();
    foreach ($allUser as $auK => $auV) {
        $userID = $auV->ID;
        $parmanent_cancel_delivery = get_user_meta($userID, 'permanent_pause', true);
        if (empty($parmanent_cancel_delivery)) {
            $susPendedData = get_user_meta($userID, 'suspended', false);
            $cur_user_subscription = get_user_meta($userID, 'wp_woocommerce_subscriptions', true);
            foreach ($cur_user_subscription as $suk => $suv) {
                //$subscriptionID = $suv['order_id'] . '_' . $suv['product_id'];
                $subscriptionID = $suk;
                break;
                /* use because one time subscription */
            }
            if (in_array($nxtTues, $susPendedData)) {
                $wsm->put_subscription_on_hold($userID, $subscriptionID);
            } else {
                $s = WC_Subscriptions_Manager::get_subscription($subscriptionID, $userID);
                if (!empty($s['status']) && $s['status'] == 'on-hold') {
                    $wsm->reactivate_subscription($userID, $subscriptionID);
                }
            }
            wp_mail('biswajitghosh.mail@gmail.com', 'The subject', 'nxtTues=>' . $nxtTues . "susPendedData=>" . json_encode($cur_user_subscription) . "u=>" . $userID);
        }
    }
    //   }
}
开发者ID:bulats,项目名称:chef,代码行数:40,代码来源:functions.php

示例14: get_builder_display


//.........这里部分代码省略.........
                         }
                     }
                     $variations_builder_element_start_args = array();
                     $tm_validation = $this->get_tm_validation_rules($element);
                     $args = array('tm_element_settings' => $element, 'column' => $size, 'class' => !empty($element['class']) ? $element['class'] : "", 'title_size' => $label_size, 'title' => !empty($element['label']) ? $element['label'] : "", 'title_position' => !empty($element['label_position']) ? $element['label_position'] : "", 'title_color' => !empty($element['label_color']) ? $element['label_color'] : "", 'description' => !empty($element['description']) ? $element['description'] : "", 'description_color' => !empty($element['description_color']) ? $element['description_color'] : "", 'description_position' => !empty($element['description_position']) ? $element['description_position'] : "", 'divider' => $divider, 'required' => $element['required'], 'type' => $element['type'], 'use_images' => $element['use_images'], 'use_url' => $element['use_url'], 'rules' => $empty_rules, 'rules_type' => $empty_rules_type, 'element' => $element['type'], 'class_id' => "tm-element-ul-" . $element['type'] . " element_" . $element_counter . $form_prefix, 'uniqid' => $element['uniqid'], 'logic' => esc_html(json_encode((array) json_decode($element['clogic']))), 'haslogic' => $element['logic'], 'clear_options' => empty($element['clear_options']) ? "" : $element['clear_options'], 'exactlimit' => empty($element['exactlimit']) ? "" : 'tm-exactlimit', 'minimumlimit' => empty($element['minimumlimit']) ? "" : 'tm-minimumlimit', 'tm_validation' => esc_html(json_encode($tm_validation)));
                     if ($element['type'] != "variations") {
                         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'];
                                                     }
                                                 }
                                             }
                                         }
                                     }
开发者ID:baden03,项目名称:access48,代码行数:67,代码来源:class-tm-extra-product-options.php

示例15: get_valid_order_ids_granting_group_membership_from_order_items

 /**
  * Returns an array of order IDs for valid orders that grant group
  * membership for the given group to the user related to the order.
  * 
  * @param int $user_id
  * @param int $group_id
  * @return array of int, order IDs
  */
 public static function get_valid_order_ids_granting_group_membership_from_order_items($user_id, $group_id)
 {
     $order_ids = array();
     if (!empty($user_id)) {
         $base_statuses = array('processing', 'completed');
         $statuses = array('completed');
         $options = get_option('groups-woocommerce', array());
         $order_status = isset($options[GROUPS_WS_MEMBERSHIP_ORDER_STATUS]) ? $options[GROUPS_WS_MEMBERSHIP_ORDER_STATUS] : GROUPS_WS_DEFAULT_MEMBERSHIP_ORDER_STATUS;
         if ($order_status == 'processing') {
             $statuses[] = 'processing';
         }
         // DO NOT use groups_ws_order_status( $statuses ) for $statuses or $base_statuses here,
         // $order->status doesn't provide the wc- prefix.
         $groups_product_groups = get_user_meta($user_id, '_groups_product_groups', true);
         if (empty($groups_product_groups)) {
             $groups_product_groups = array();
         }
         foreach ($groups_product_groups as $order_id => $product_ids) {
             if ($order = Groups_WS_Helper::get_order($order_id)) {
                 // If this is a completed/processing order, consider group assignments.
                 // We check the order status for non-subscription products below,
                 // for subscriptions the subscription status is checked.
                 if (in_array($order->status, $base_statuses)) {
                     // Note that for orders placed with versions up to 1.4.1, the following won't give the results we might expect if the product group-related information has changed since the order was placed.
                     // As we don't store that information (WC doesn't store the whole lot of the product when purchased, nor does GW) checking the duration based on the product is the best effort at
                     // finding out about the group membership duration we can make.
                     // Use the order items (only existing order items are taken into account).
                     if ($items = $order->get_items()) {
                         foreach ($items as $item) {
                             if ($product = $order->get_product_from_item($item)) {
                                 // Use the groups that were stored for the product when it was ordered,
                                 // this avoids hickups when the product's groups were changed since.
                                 if (isset($product_ids[$product->id]) && isset($product_ids[$product->id]['groups'])) {
                                     $product_groups = $product_ids[$product->id]['groups'];
                                     if (in_array($group_id, $product_groups)) {
                                         // non-subscriptions
                                         if (!class_exists('WC_Subscriptions_Product') || !WC_Subscriptions_Product::is_subscription($product->id)) {
                                             if (in_array($order->status, $statuses)) {
                                                 if (isset($product_ids[$product->id]) && isset($product_ids[$product->id]['version'])) {
                                                     $has_duration = isset($product_ids[$product->id]['duration']) && $product_ids[$product->id]['duration'] && isset($product_ids[$product->id]['duration_uom']);
                                                 } else {
                                                     $has_duration = Groups_WS_Product::has_duration($product);
                                                 }
                                                 // unlimited membership
                                                 if (!$has_duration) {
                                                     if (!in_array($order_id, $order_ids)) {
                                                         $order_ids[] = $order_id;
                                                     }
                                                 } else {
                                                     if (isset($product_ids[$product->id]) && isset($product_ids[$product->id]['version'])) {
                                                         $duration = Groups_WS_Product::calculate_duration($product_ids[$product->id]['duration'], $product_ids[$product->id]['duration_uom']);
                                                     } else {
                                                         // <= 1.4.1
                                                         $duration = Groups_WS_Product::get_duration($product);
                                                     }
                                                     // time-limited membership
                                                     if ($duration) {
                                                         $start_date = $order->order_date;
                                                         if ($paid_date = get_post_meta($order_id, '_paid_date', true)) {
                                                             $start_date = $paid_date;
                                                         }
                                                         $end = strtotime($start_date) + $duration;
                                                         if (time() < $end) {
                                                             if (!in_array($order_id, $order_ids)) {
                                                                 $order_ids[] = $order_id;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         } else {
                                             // include active subscriptions ( subscriptions >= 2.x )
                                             if (function_exists('wcs_get_subscriptions_for_order')) {
                                                 if ($subscriptions = wcs_get_subscriptions_for_order($order_id)) {
                                                     if (is_array($subscriptions)) {
                                                         foreach ($subscriptions as $subscription) {
                                                             if ($subscription->has_product($product->id)) {
                                                                 $valid = false;
                                                                 if ($subscription->get_status() == 'active') {
                                                                     $valid = true;
                                                                 } else {
                                                                     if ($subscription->get_status() == 'cancelled') {
                                                                         $hook_args = array('subscription_id' => $subscription->id);
                                                                         $end_timestamp = wp_next_scheduled('scheduled_subscription_end_of_prepaid_term', $hook_args);
                                                                         if ($end_timestamp !== false && $end_timestamp > time()) {
                                                                             $valid = true;
                                                                         }
                                                                     }
                                                                 }
                                                                 if ($valid) {
                                                                     if (!in_array($order_id, $order_ids)) {
                                                                         $order_ids[] = $order_id;
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:class-groups-ws-handler.php


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