• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wcs_get_subscription函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wcs_get_subscription函数的典型用法代码示例。如果您正苦于以下问题:PHP wcs_get_subscription函数的具体用法?PHP wcs_get_subscription怎么用?PHP wcs_get_subscription使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: cancel_subscriptions

 /**
  * Find all subscription with a given billing agreement ID and cancel them becasue that billing agreement has been
  * cancelled at PayPal, and therefore, no future payments can be charged.
  *
  * @since 2.0
  */
 protected function cancel_subscriptions($billing_agreement_id)
 {
     $subscription_ids = get_posts(array('posts_per_page' => -1, 'post_type' => 'shop_subscription', 'post_status' => 'any', 'fields' => 'ids', 'orderby' => 'date', 'order' => 'DESC', 'meta_query' => array(array('key' => '_paypal_subscription_id', 'compare' => '=', 'value' => $billing_agreement_id))));
     if (empty($subscription_ids)) {
         return;
     }
     $note = esc_html__('Billing agreement cancelled at PayPal.', 'woocommerce-subscriptions');
     foreach ($subscription_ids as $subscription_id) {
         $subscription = wcs_get_subscription($subscription_id);
         try {
             if (false !== $subscription && !$subscription->has_status(wcs_get_subscription_ended_statuses())) {
                 $subscription->cancel_order($note);
                 WC_Gateway_Paypal::log(sprintf('Subscription %s Cancelled: %s', $subscription_id, $note));
             }
         } catch (Exception $e) {
             WC_Gateway_Paypal::log(sprintf('Unable to cancel subscription %s: %s', $subscription_id, $e->getMessage()));
         }
     }
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:25,代码来源:class-wcs-paypal-reference-transaction-ipn-handler.php


示例2: filter_orders

 /**
  * Filter the "Orders" list to show only orders associated with a specific subscription.
  *
  * @param string $where
  * @param string $request
  * @return string
  * @since 2.0
  */
 public static function filter_orders($where)
 {
     global $typenow, $wpdb;
     if (is_admin() && 'shop_order' == $typenow) {
         $related_orders = array();
         if (isset($_GET['_subscription_related_orders']) && $_GET['_subscription_related_orders'] > 0) {
             $subscription_id = absint($_GET['_subscription_related_orders']);
             $subscription = wcs_get_subscription($subscription_id);
             if (!wcs_is_subscription($subscription)) {
                 // translators: placeholder is a number
                 wcs_add_admin_notice(sprintf(__('We can\'t find a subscription with ID #%d. Perhaps it was deleted?', 'woocommerce-subscriptions'), $subscription_id), 'error');
                 $where .= " AND {$wpdb->posts}.ID = 0";
             } else {
                 self::$found_related_orders = true;
                 $where .= sprintf(" AND {$wpdb->posts}.ID IN (%s)", implode(',', array_map('absint', array_unique($subscription->get_related_orders('ids')))));
             }
         }
     }
     return $where;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:28,代码来源:class-wc-subscriptions-admin.php


示例3: save

 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     if ('shop_subscription' == $post->post_type && !empty($_POST['woocommerce_meta_nonce']) && wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
         if (isset($_POST['_billing_interval'])) {
             update_post_meta($post_id, '_billing_interval', $_POST['_billing_interval']);
         }
         if (!empty($_POST['_billing_period'])) {
             update_post_meta($post_id, '_billing_period', $_POST['_billing_period']);
         }
         $subscription = wcs_get_subscription($post_id);
         $dates = array();
         foreach (wcs_get_subscription_date_types() as $date_key => $date_label) {
             if ('last_payment' == $date_key) {
                 continue;
             }
             $utc_timestamp_key = $date_key . '_timestamp_utc';
             // A subscription needs a start date, even if it wasn't set
             if (isset($_POST[$utc_timestamp_key])) {
                 $datetime = $_POST[$utc_timestamp_key];
             } elseif ('start' === $date_key) {
                 $datetime = current_time('timestamp', true);
             } else {
                 // No date to set
                 continue;
             }
             $dates[$date_key] = date('Y-m-d H:i:s', $datetime);
         }
         try {
             $subscription->update_dates($dates, 'gmt');
             wp_cache_delete($post_id, 'posts');
         } catch (Exception $e) {
             wcs_add_admin_notice($e->getMessage(), 'error');
         }
     }
 }
开发者ID:slavic18,项目名称:cats,代码行数:38,代码来源:class-wcs-meta-box-subscription-schedule.php


示例4: output_rows

 /**
  * Displays the renewal orders in the Related Orders meta box.
  *
  * @param object $post A WordPress post
  * @since 2.0
  */
 public static function output_rows($post)
 {
     $subscriptions = array();
     $orders = array();
     // On the subscription page, just show related orders
     if (wcs_is_subscription($post->ID)) {
         $subscriptions[] = wcs_get_subscription($post->ID);
     } elseif (wcs_order_contains_subscription($post->ID, array('parent', 'renewal'))) {
         $subscriptions = wcs_get_subscriptions_for_order($post->ID, array('order_type' => array('parent', 'renewal')));
     }
     // First, display all the subscriptions
     foreach ($subscriptions as $subscription) {
         $subscription->relationship = __('Subscription', 'woocommerce-subscriptions');
         $orders[] = $subscription;
     }
     //Resubscribed
     $initial_subscriptions = array();
     if (wcs_is_subscription($post->ID)) {
         $initial_subscriptions = wcs_get_subscriptions_for_resubscribe_order($post->ID);
         $resubscribed_subscriptions = get_posts(array('meta_key' => '_subscription_resubscribe', 'meta_value' => $post->ID, 'post_type' => 'shop_subscription', 'post_status' => 'any', 'posts_per_page' => -1));
         foreach ($resubscribed_subscriptions as $subscription) {
             $subscription = wcs_get_subscription($subscription);
             $subscription->relationship = _x('Resubscribed Subscription', 'relation to order', 'woocommerce-subscriptions');
             $orders[] = $subscription;
         }
     } else {
         if (wcs_order_contains_subscription($post->ID, array('resubscribe'))) {
             $initial_subscriptions = wcs_get_subscriptions_for_order($post->ID, array('order_type' => array('resubscribe')));
         }
     }
     foreach ($initial_subscriptions as $subscription) {
         $subscription->relationship = _x('Initial Subscription', 'relation to order', 'woocommerce-subscriptions');
         $orders[] = $subscription;
     }
     // Now, if we're on a single subscription or renewal order's page, display the parent orders
     if (1 == count($subscriptions)) {
         foreach ($subscriptions as $subscription) {
             if (false !== $subscription->order) {
                 $subscription->order->relationship = _x('Parent Order', 'relation to order', 'woocommerce-subscriptions');
                 $orders[] = $subscription->order;
             }
         }
     }
     // Finally, display the renewal orders
     foreach ($subscriptions as $subscription) {
         foreach ($subscription->get_related_orders('all', 'renewal') as $order) {
             $order->relationship = _x('Renewal Order', 'relation to order', 'woocommerce-subscriptions');
             $orders[] = $order;
         }
     }
     $orders = apply_filters('woocommerce_subscriptions_admin_related_orders_to_display', $orders, $subscriptions, $post);
     foreach ($orders as $order) {
         if ($order->id == $post->ID) {
             continue;
         }
         include 'views/html-related-orders-row.php';
     }
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:64,代码来源:class-wcs-meta-box-related-orders.php


示例5: maybe_remove_or_add_item_to_subscription

 /**
  * Process the remove or re-add a line item from a subscription request.
  *
  * @since 2.0
  */
 public static function maybe_remove_or_add_item_to_subscription()
 {
     if (isset($_GET['subscription_id']) && (isset($_GET['remove_item']) || isset($_GET['undo_remove_item'])) && isset($_GET['_wpnonce'])) {
         $subscription = wcs_is_subscription($_GET['subscription_id']) ? wcs_get_subscription($_GET['subscription_id']) : false;
         $undo_request = isset($_GET['undo_remove_item']) ? true : false;
         $item_id = $undo_request ? $_GET['undo_remove_item'] : $_GET['remove_item'];
         if (false === $subscription) {
             wc_add_notice(sprintf(_x('Subscription #%d does not exist.', 'hash before subscription ID', 'woocommerce-subscriptions'), $_GET['subscription_id']), 'error');
             wp_safe_redirect(wc_get_page_permalink('myaccount'));
             exit;
         }
         if (self::validate_remove_items_request($subscription, $item_id, $undo_request)) {
             if ($undo_request) {
                 // handle undo request
                 $removed_item = WC()->session->get('removed_subscription_items', array());
                 if (!empty($removed_item[$item_id]) && $subscription->id == $removed_item[$item_id]) {
                     // restore the item
                     wc_update_order_item($item_id, array('order_item_type' => 'line_item'));
                     unset($removed_item[$item_id]);
                     WC()->session->set('removed_subscription_items', $removed_item);
                     // restore download permissions for this item
                     $line_items = $subscription->get_items();
                     $line_item = $line_items[$item_id];
                     $_product = $subscription->get_product_from_item($line_item);
                     $product_id = wcs_get_canonical_product_id($line_item);
                     if ($_product && $_product->exists() && $_product->is_downloadable()) {
                         $downloads = $_product->get_files();
                         foreach (array_keys($downloads) as $download_id) {
                             wc_downloadable_file_permission($download_id, $product_id, $subscription, $line_item['qty']);
                         }
                     }
                     // translators: 1$: product name, 2$: product id
                     $subscription->add_order_note(sprintf(_x('Customer added "%1$s" (Product ID: #%2$d) via the My Account page.', 'used in order note', 'woocommerce-subscriptions'), wcs_get_line_item_name($line_item), $product_id));
                 } else {
                     wc_add_notice(__('Your request to undo your previous action was unsuccessful.', 'woocommerce-subscriptions'));
                 }
             } else {
                 // handle remove item requests
                 WC()->session->set('removed_subscription_items', array($item_id => $subscription->id));
                 // remove download access for the item
                 $line_items = $subscription->get_items();
                 $line_item = $line_items[$item_id];
                 $product_id = wcs_get_canonical_product_id($line_item);
                 WCS_Download_Handler::revoke_downloadable_file_permission($product_id, $subscription->id, $subscription->get_user_id());
                 // remove the line item from subscription but preserve its data in the DB
                 wc_update_order_item($item_id, array('order_item_type' => 'line_item_removed'));
                 // translators: 1$: product name, 2$: product id
                 $subscription->add_order_note(sprintf(_x('Customer removed "%1$s" (Product ID: #%2$d) via the My Account page.', 'used in order note', 'woocommerce-subscriptions'), wcs_get_line_item_name($line_item), $product_id));
                 // translators: placeholders are 1$: item name, and, 2$: opening and, 3$: closing link tags
                 wc_add_notice(sprintf(__('You have successfully removed "%1$s" from your subscription. %2$sUndo?%3$s', 'woocommerce-subscriptions'), $line_item['name'], '<a href="' . esc_url(self::get_undo_remove_url($subscription->id, $item_id, $subscription->get_view_order_url())) . '" >', '</a>'));
             }
         }
         $subscription->calculate_totals();
         wp_safe_redirect($subscription->get_view_order_url());
         exit;
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:62,代码来源:class-wcs-remove-item.php


示例6: wcs_get_subscriptions_for_switch_order

/**
 * Get the subscriptions that had an item switch for a given order (if any).
 *
 * @param int|WC_Order $order_id The post_id of a shop_order post or an instance of a WC_Order object
 * @return array Subscription details in post_id => WC_Subscription form.
 * @since  2.0
 */
function wcs_get_subscriptions_for_switch_order($order_id)
{
    if (is_object($order_id)) {
        $order_id = $order_id->id;
    }
    $subscriptions = array();
    $subscription_ids = get_post_meta($order_id, '_subscription_switch', false);
    foreach ($subscription_ids as $subscription_id) {
        $subscriptions[$subscription_id] = wcs_get_subscription($subscription_id);
    }
    return $subscriptions;
}
开发者ID:slavic18,项目名称:cats,代码行数:19,代码来源:wcs-switch-functions.php


示例7: enqueue_styles_scripts

 /**
  * Print admin styles/scripts
  */
 public function enqueue_styles_scripts()
 {
     global $post;
     // Get admin screen id
     $screen = get_current_screen();
     if ('shop_subscription' == $screen->id) {
         wp_register_script('jstz', plugin_dir_url(WC_Subscriptions::$plugin_file) . '/assets/js/admin/jstz.min.js');
         wp_register_script('momentjs', plugin_dir_url(WC_Subscriptions::$plugin_file) . '/assets/js/admin/moment.min.js');
         wp_enqueue_script('wcs-admin-meta-boxes-subscription', plugin_dir_url(WC_Subscriptions::$plugin_file) . '/assets/js/admin/meta-boxes-subscription.js', array('wc-admin-meta-boxes', 'jstz', 'momentjs'), WC_VERSION);
         wp_localize_script('wcs-admin-meta-boxes-subscription', 'wcs_admin_meta_boxes', apply_filters('woocommerce_subscriptions_admin_meta_boxes_script_parameters', array('i18n_start_date_notice' => __('Please enter a start date in the past.', 'woocommerce-subscriptions'), 'i18n_past_date_notice' => __('Please enter a date at least one hour into the future.', 'woocommerce-subscriptions'), 'i18n_next_payment_start_notice' => __('Please enter a date after the trial end.', 'woocommerce-subscriptions'), 'i18n_next_payment_trial_notice' => __('Please enter a date after the start date.', 'woocommerce-subscriptions'), 'i18n_trial_end_start_notice' => __('Please enter a date after the start date.', 'woocommerce-subscriptions'), 'i18n_trial_end_next_notice' => __('Please enter a date before the next payment.', 'woocommerce-subscriptions'), 'i18n_end_date_notice' => __('Please enter a date after the next payment.', 'woocommerce-subscriptions'), 'process_renewal_action_warning' => __("Are you sure you want to process a renewal?\n\nThis will charge the customer and email them the renewal order (if emails are enabled).", 'woocommerce-subscriptions'), 'payment_method' => wcs_get_subscription($post)->payment_method, 'search_customers_nonce' => wp_create_nonce('search-customers'))));
     }
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:15,代码来源:class-wcs-admin-meta-boxes.php


示例8: wcs_get_subscription_from_key

/**
 * Return an instance of a WC_Subscription object for the given subscription key (if one exists).
 *
 * @param string $subscription_key A subscription key in the deprecated form created by @see self::get_subscription_key()
 * @return WC_Subscription|null The subscription object if it can be found (i.e. an order exists) or null if no order exists for the subscription (i.e. it was manually created).
 * @since 2.0
 */
function wcs_get_subscription_from_key($subscription_key)
{
    $subscription_id = wcs_get_subscription_id_from_key($subscription_key);
    if (null !== $subscription_id && is_numeric($subscription_id)) {
        $subscription = wcs_get_subscription($subscription_id);
    }
    if (!is_object($subscription)) {
        // translators: placeholder is either subscription key or a subscription id, or, failing that, empty (e.g. "145_21" or "145")
        throw new InvalidArgumentException(sprintf(__('Could not get subscription. Most likely the subscription key does not refer to a subscription. The key was: "%s".', 'woocommerce-subscriptions'), $subscription_key));
    }
    return $subscription;
}
开发者ID:slavic18,项目名称:cats,代码行数:19,代码来源:wcs-deprecated-functions.php


示例9: get_endpoint_title

 /**
  * Set the subscription page title when viewing a subscription.
  *
  * @since 2.0
  * @param $title
  */
 public function get_endpoint_title($endpoint)
 {
     global $wp;
     switch ($endpoint) {
         case 'view-subscription':
             $subscription = wcs_get_subscription($wp->query_vars['view-subscription']);
             $title = $subscription ? sprintf(_x('Subscription #%s', 'hash before order number', 'woocommerce-subscriptions'), $subscription->get_order_number()) : '';
             break;
         default:
             $title = '';
             break;
     }
     return $title;
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:20,代码来源:class-wcs-query.php


示例10: cart_needs_payment

 /**
  * Check whether the cart needs payment even if the order total is $0 because it's a subscription switch request for a subscription using
  * PayPal Standard as the subscription.
  *
  * @param bool $needs_payment The existing flag for whether the cart needs payment or not.
  * @param WC_Cart $cart The WooCommerce cart object.
  * @return bool
  */
 public static function cart_needs_payment($needs_payment, $cart)
 {
     $cart_switch_items = WC_Subscriptions_Switcher::cart_contains_switches();
     if (false === $needs_payment && 0 == $cart->total && false !== $cart_switch_items && 'yes' !== get_option(WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no')) {
         foreach ($cart_switch_items as $cart_switch_details) {
             $subscription = wcs_get_subscription($cart_switch_details['subscription_id']);
             if ('paypal' === $subscription->payment_method && !wcs_is_paypal_profile_a(wcs_get_paypal_id($subscription->id), 'billing_agreement')) {
                 $needs_payment = true;
                 break;
             }
         }
     }
     return $needs_payment;
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:22,代码来源:class-wcs-paypal-standard-switcher.php


示例11: validate_request

 /**
  * Checks if the user's current request to change the status of their subscription is valid.
  *
  * @since 2.0
  */
 public static function validate_request($user_id, $subscription, $new_status, $wpnonce = '')
 {
     $subscription = !is_object($subscription) ? wcs_get_subscription($subscription) : $subscription;
     if (!wcs_is_subscription($subscription)) {
         WC_Subscriptions::add_notice(__('That subscription does not exist. Please contact us if you need assistance.', 'woocommerce-subscriptions'), 'error');
         return false;
     } elseif (!empty($wpnonce) && wp_verify_nonce($wpnonce, $subscription->id) === false) {
         WC_Subscriptions::add_notice(__('Security error. Please contact us if you need assistance.', 'woocommerce-subscriptions'), 'error');
         return false;
     } elseif (!user_can($user_id, 'edit_shop_subscription_status', $subscription->id)) {
         WC_Subscriptions::add_notice(__('That doesn\'t appear to be one of your subscriptions.', 'woocommerce-subscriptions'), 'error');
         return false;
     } elseif (!$subscription->can_be_updated_to($new_status)) {
         WC_Subscriptions::add_notice(sprintf(__('That subscription can not be changed to %s. Please contact us if you need assistance.', 'woocommerce-subscriptions'), $new_status), 'error');
         return false;
     }
     return true;
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:23,代码来源:class-wcs-user-change-status-handler.php


示例12: trigger_hook

 /**
  * Display a notice if functions are hooked to the old filter and apply the old filters args
  *
  * @since 2.0
  */
 protected function trigger_hook($old_hook, $new_callback_args)
 {
     if (0 === strpos($old_hook, 'admin_changed_subscription_to_')) {
         // New arg spec: $subscription_id
         // Old arg spec: $subscription_key
         $subscription = wcs_get_subscription($new_callback_args[0]);
         do_action($old_hook, wcs_get_old_subscription_key($subscription));
     } elseif (0 === strpos($old_hook, 'scheduled_subscription_payment_')) {
         // New arg spec: $amount, $renewal_order
         // Old arg spec: $amount, $original_order, $product_id
         $subscription = $new_callback_args[0];
         $subscriptions = wcs_get_subscriptions_for_renewal_order($new_callback_args[1]);
         if (!empty($subscriptions)) {
             $subscription = array_pop($subscriptions);
             do_action($old_hook, $new_callback_args[0], self::get_order($subscription), self::get_product_id($subscription));
         }
     } elseif (0 === strpos($old_hook, 'activated_subscription_') || 0 === strpos($old_hook, 'reactivated_subscription_') || 0 === strpos($old_hook, 'subscription_put_on-hold_') || 0 === strpos($old_hook, 'cancelled_subscription_') || 0 === strpos($old_hook, 'subscription_expired_')) {
         // New arg spec: $subscription
         // Old arg spec: $order, $product_id
         $subscription = $new_callback_args[0];
         do_action($old_hook, self::get_order($subscription), self::get_product_id($subscription));
     } elseif (0 === strpos($old_hook, 'customer_changed_subscription_to_')) {
         // New arg spec: $subscription
         // Old arg spec: $subscription_key
         do_action($old_hook, wcs_get_old_subscription_key($new_callback_args[0]));
     } elseif (0 === strpos($old_hook, 'woocommerce_subscriptions_updated_recurring_payment_method_to_')) {
         // New arg spec: $subscription, $old_payment_method
         // Old arg spec: $order, $subscription_key, $old_payment_method
         $subscription = $new_callback_args[0];
         $old_payment_method = $new_callback_args[2];
         do_action($old_hook, self::get_order($subscription), wcs_get_old_subscription_key($subscription), $old_payment_method);
     } elseif (0 === strpos($old_hook, 'woocommerce_subscriptions_updated_recurring_payment_method_from_')) {
         // New arg spec: $subscription, $new_payment_method
         // Old arg spec: $order, $subscription_key, $new_payment_method
         $subscription = $new_callback_args[0];
         $new_payment_method = $new_callback_args[1];
         do_action($old_hook, self::get_order($subscription), wcs_get_old_subscription_key($subscription), $new_payment_method);
     } elseif (0 === strpos($old_hook, 'woocommerce_subscriptions_changed_failing_payment_method_')) {
         // New arg spec: $subscription, $renewal_order
         // Old arg spec: $original_order, $renewal_order, $subscription_key
         $subscription = $new_callback_args[0];
         do_action($old_hook, self::get_order($subscription), $new_callback_args[1], wcs_get_old_subscription_key($subscription));
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:49,代码来源:class-wcs-dynamic-action-deprecator.php


示例13: orderByItemId

 /**
  * Get order containing item.
  *
  * @since 160608 Order item utilities.
  *
  * @param string|int $item_id Order item ID.
  *
  * @return \WC_Abstract_Order|null Order on success.
  */
 public function orderByItemId($item_id)
 {
     if (!($item_id = (int) $item_id)) {
         return null;
         // Not possible.
     }
     $WpDb = $this->s::wpDb();
     // DB instance.
     $table = $WpDb->prefix . 'woocommerce_order_items';
     $sql = '
         SELECT `order_id` FROM `' . esc_sql($table) . '`
          WHERE `order_item_id` = %s LIMIT 1';
     $sql = $WpDb->prepare($sql, $item_id);
     // Prepare.
     if (!($order_id = (int) $WpDb->get_var($sql))) {
         return null;
         // Not possible; can't get order ID.
     } elseif (!($post_type = get_post_type($order_id))) {
         debug(0, $this->c::issue(vars(), 'Unable to acquire order post type.'));
         return null;
         // Not possible; can't get post type.
     }
     switch ($post_type) {
         // Based on post type.
         case 'shop_subscription':
             $subscription_id = $order_id;
             // It's a subscription ID.
             if ($WC_Subscription = wcs_get_subscription($subscription_id)) {
                 return $WC_Subscription;
             }
             return null;
             // Not possible.
         // Not possible.
         case 'shop_order':
         default:
             // Any other order type.
             if ($WC_Order = wc_get_order($order_id)) {
                 return $WC_Order;
             }
             return null;
             // Not possible.
     }
 }
开发者ID:websharks,项目名称:wp-sharks-core,代码行数:52,代码来源:WcOrderItem.php


示例14: maybe_repair_subscriptions

 /**
  * Update any subscription that need to be repaired.
  *
  * @return array The counts of repaired and unrepaired subscriptions
  */
 public static function maybe_repair_subscriptions($subscription_ids_to_repair)
 {
     global $wpdb;
     // don't allow data to be half upgraded on a subscription in case of a script timeout or other non-recoverable error
     $wpdb->query('START TRANSACTION');
     $repaired_count = $unrepaired_count = 0;
     foreach ($subscription_ids_to_repair as $subscription_id) {
         $subscription = wcs_get_subscription($subscription_id);
         if (false !== $subscription && self::maybe_repair_subscription($subscription)) {
             WCS_Upgrade_Logger::add(sprintf('For subscription %d: repair completed', $subscription->id));
             $repaired_count++;
             update_post_meta($subscription_id, '_wcs_repaired_2_0_2', 'true');
         } else {
             WCS_Upgrade_Logger::add(sprintf('For subscription %d: no repair needed', $subscription->id));
             $unrepaired_count++;
             update_post_meta($subscription_id, '_wcs_repaired_2_0_2', 'false');
         }
     }
     $wpdb->query('COMMIT');
     return array('repaired_count' => $repaired_count, 'unrepaired_count' => $unrepaired_count);
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:26,代码来源:class-wcs-repair-2-0-2.php


示例15: output_rows

 /**
  * Displays the renewal orders in the Related Orders meta box.
  *
  * @param object $post A WordPress post
  * @since 2.0
  */
 public static function output_rows($post)
 {
     $subscriptions = array();
     $orders = array();
     // On the subscription page, just show related orders
     if (wcs_is_subscription($post->ID)) {
         $subscriptions[] = wcs_get_subscription($post->ID);
     } elseif (wcs_order_contains_subscription($post->ID, array('parent', 'renewal'))) {
         $subscriptions = wcs_get_subscriptions_for_order($post->ID, array('order_type' => array('parent', 'renewal')));
     }
     // First, display all the subscriptions
     foreach ($subscriptions as $subscription) {
         $subscription->relationship = _x('Subscription', 'relation to order', 'woocommerce-subscriptions');
         $orders[] = $subscription;
     }
     // Now, if we're on a single subscription or renewal order's page, display the parent orders
     if (1 == count($subscriptions)) {
         foreach ($subscriptions as $subscription) {
             if (false !== $subscription->order) {
                 $subscription->order->relationship = _x('Parent Order', 'relation to order', 'woocommerce-subscriptions');
                 $orders[] = $subscription->order;
             }
         }
     }
     // Finally, display the renewal orders
     foreach ($subscriptions as $subscription) {
         foreach ($subscription->get_related_orders('all', 'renewal') as $order) {
             $order->relationship = _x('Renewal Order', 'relation to order', 'woocommerce-subscriptions');
             $orders[] = $order;
         }
     }
     foreach ($orders as $order) {
         if ($order->id == $post->ID) {
             continue;
         }
         include 'views/html-related-orders-row.php';
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:44,代码来源:class-wcs-meta-box-related-orders.php


示例16: change_payment_method_via_pay_shortcode

 /**
  * Process the change payment form.
  *
  * Based on the @see woocommerce_pay_action() function.
  *
  * @access public
  * @return void
  * @since 1.4
  */
 public static function change_payment_method_via_pay_shortcode()
 {
     if (isset($_POST['_wcsnonce']) && wp_verify_nonce($_POST['_wcsnonce'], 'wcs_change_payment_method')) {
         $subscription = wcs_get_subscription(absint($_POST['woocommerce_change_payment']));
         do_action('woocommerce_subscription_change_payment_method_via_pay_shortcode', $subscription);
         ob_start();
         if ($subscription->order_key == $_GET['key']) {
             // Set customer location to order location
             if ($subscription->billing_country) {
                 WC()->customer->set_country($subscription->billing_country);
             }
             if ($subscription->billing_state) {
                 WC()->customer->set_state($subscription->billing_state);
             }
             if ($subscription->billing_postcode) {
                 WC()->customer->set_postcode($subscription->billing_postcode);
             }
             if ($subscription->billing_city) {
                 WC()->customer->set_city($subscription->billing_city);
             }
             // Update payment method
             $new_payment_method = woocommerce_clean($_POST['payment_method']);
             // Allow some payment gateways which can't process the payment immediately, like PayPal, to do it later after the payment/sign-up is confirmed
             if (apply_filters('woocommerce_subscriptions_update_payment_via_pay_shortcode', true, $new_payment_method, $subscription)) {
                 self::update_payment_method($subscription, $new_payment_method);
             }
             $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
             // Validate
             $available_gateways[$new_payment_method]->validate_fields();
             // Process payment for the new method (with a $0 order total)
             if (wc_notice_count('error') == 0) {
                 $result = $available_gateways[$new_payment_method]->process_payment($subscription->id);
                 $result = apply_filters('woocommerce_subscriptions_process_payment_for_change_method_via_pay_shortcode', $result, $subscription);
                 // Redirect to success/confirmation/payment page
                 if ('success' == $result['result']) {
                     WC_Subscriptions::add_notice(__('Payment method updated.', 'woocommerce-subscriptions'), 'success');
                     wp_redirect($result['redirect']);
                     exit;
                 }
             }
         }
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:52,代码来源:class-wc-subscriptions-change-payment-gateway.php


示例17: save

 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     if ('shop_subscription' != $post->post_type || empty($_POST['woocommerce_meta_nonce']) || !wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
         return;
     }
     self::init_address_fields();
     // Update meta
     update_post_meta($post_id, '_customer_user', absint($_POST['customer_user']));
     if (self::$billing_fields) {
         foreach (self::$billing_fields as $key => $field) {
             update_post_meta($post_id, '_billing_' . $key, wc_clean($_POST['_billing_' . $key]));
         }
     }
     if (self::$shipping_fields) {
         foreach (self::$shipping_fields as $key => $field) {
             update_post_meta($post_id, '_shipping_' . $key, wc_clean($_POST['_shipping_' . $key]));
         }
     }
     $subscription = wcs_get_subscription($post_id);
     try {
         WCS_Change_Payment_Method_Admin::save_meta($subscription);
         if ('cancelled' == $_POST['order_status']) {
             $subscription->cancel_order();
         } else {
             $subscription->update_status($_POST['order_status'], '', true);
         }
     } catch (Exception $e) {
         // translators: placeholder is error message from by payment gateway
         wcs_add_admin_notice(sprintf(__('Unable to change payment method: %s', 'woocommerce-subscriptions'), $e->getMessage()), 'error');
     }
     do_action('woocommerce_process_shop_subscription_meta', $post_id, $post);
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:36,代码来源:class-wcs-meta-box-subscription-data.php


示例18: esc_html_e

    esc_html_e('Next Payment', 'woocommerce-subscriptions');
    ?>
</span></th>
				<th class="subscription-total order-total"><span class="nobr"><?php 
    esc_html_e('Total', 'woocommerce-subscriptions');
    ?>
</span></th>
				<th class="subscription-actions order-actions">&nbsp;</th>
			</tr>

	<tbody>
	<?php 
    foreach ($subscriptions as $subscription_id => $subscription) {
        ?>
		<?php 
        $sub = wcs_get_subscription($subscription);
        $items = $sub->get_items();
        $link = '';
        foreach ($items as $id => $item) {
            if (isset($item['product_id'])) {
                $post_id = (int) $item['product_id'];
                $link = get_post_meta($post_id, 'ndv_link', true);
            }
        }
        ?>
		<tr class="order">
			<td class="subscription-id order-number" data-title="<?php 
        esc_attr_e('ID', 'woocommerce-subscriptions');
        ?>
">
				<a href="<?php 
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:31,代码来源:my-subscriptions.php


示例19: is_subsbcription_renewal_line_item

 /**
  * Check if a product is a renewal order line item (rather than a "susbscription") - to pick up non-subsbcription products added a subscription manually
  *
  * @param  int	$product_id
  * @param  array  $cart_item
  * @param  WC_Cart  $cart The WooCommerce cart object.
  * @return boolean whether a product is a renewal order line item
  * @since 2.0.10
  */
 private static function is_subsbcription_renewal_line_item($product_id, $cart_item)
 {
     $is_subscription_line_item = false;
     if (is_object($product_id)) {
         $product = $product_id;
         $product_id = $product->id;
     } elseif (is_numeric($product_id)) {
         $product = wc_get_product($product_id);
     }
     if (!empty($cart_item['subscription_renewal'])) {
         if ($subscription = wcs_get_subscription($cart_item['subscription_renewal']['subscription_id'])) {
             foreach ($subscription->get_items() as $item) {
                 $item_product_id = $item['variation_id'] ? $item['variation_id'] : $item['product_id'];
                 if (!empty($item_product_id) && $item_product_id == $product_id) {
                     $is_subscription_line_item = true;
                 }
             }
         }
     }
     return apply_filters('woocommerce_is_subscription_renewal_line_item', $is_subscription_line_item, $product_id, $cart_item);
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:30,代码来源:class-wc-subscriptions-coupon.php


示例20: esc_html__

 *
 * @author    Prospress
 * @package   WooCommerce_Subscription/Templates
 * @version   2.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
if (empty($subscription)) {
    global $wp;
    if (!isset($wp->query_vars['view-subscription']) || 'shop_subscription' != get_post_type(absint($wp->query_vars['view-subscription'])) || !current_user_can('view_order', absint($wp->query_vars['view-subscription']))) {
        echo '<div class="woocommerce-error">' . esc_html__('Invalid Subscription.', 'woocommerce-subscriptions') . ' <a href="' . esc_url(wc_get_page_permalink('myaccount')) . '" class="wc-forward">' . esc_html__('My Account', 'woocommerce-subscriptions') . '</a>' . '</div>';
        return;
    }
    $subscription = wcs_get_subscription($wp->query_vars['view-subscription']);
}
wc_print_notices();
?>

<table class="shop_table subscription_details">
	<tr>
		<td><?php 
esc_html_e('Status', 'woocommerce-subscriptions');
?>
</td>
		<td><?php 
echo esc_html(wcs_get_subscription_status_name($subscription->get_status()));
?>
</td>
	</tr>
开发者ID:swaroop42,项目名称:RockRose,代码行数:31,代码来源:view-subscription.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wcs_get_subscriptions_for_order函数代码示例发布时间:2022-05-23
下一篇:
PHP wcs_get_canonical_product_id函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap