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

PHP wcs_is_subscription函数代码示例

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

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



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

示例1: 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


示例2: maybe_revoke_immediate_access

 /**
  * When adding new downloadable content to a subscription product, check if we don't
  * want to automatically add the new downloadable files to the subscription or initial and renewal orders.
  *
  * @param bool $grant_access
  * @param string $download_id
  * @param int $product_id
  * @param WC_Order $order
  * @return bool
  * @since 2.0
  */
 public static function maybe_revoke_immediate_access($grant_access, $download_id, $product_id, $order)
 {
     if ('yes' == get_option(WC_Subscriptions_Admin::$option_prefix . '_drip_downloadable_content_on_renewal', 'no') && (wcs_is_subscription($order->id) || wcs_order_contains_subscription($order, 'any'))) {
         $grant_access = false;
     }
     return $grant_access;
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:18,代码来源:class-wcs-download-handler.php


示例3: 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


示例4: 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


示例5: wcs_get_subscription

/**
 * Main function for returning subscriptions. Wrapper for the wc_get_order() method.
 *
 * @since  2.0
 * @param  mixed $the_subscription Post object or post ID of the order.
 * @return WC_Subscription
 */
function wcs_get_subscription($the_subscription)
{
    if (is_object($the_subscription) && wcs_is_subscription($the_subscription)) {
        $the_subscription = $the_subscription->id;
    }
    $subscription = WC()->order_factory->get_order($the_subscription);
    if (!wcs_is_subscription($subscription)) {
        $subscription = false;
    }
    return apply_filters('wcs_get_subscription', $subscription);
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:18,代码来源:wcs-functions.php


示例6: process_payment

 /**
  * Process payment
  *
  * @param int $order_id
  */
 public function process_payment($order_id)
 {
     if (!$this->order_contains_subscription($order_id) && !wcs_is_subscription($order_id)) {
         return parent::process_payment($order_id);
     }
     $amazon_billing_agreement_id = isset($_POST['amazon_billing_agreement_id']) ? wc_clean($_POST['amazon_billing_agreement_id']) : '';
     try {
         if (!$amazon_billing_agreement_id) {
             throw new Exception(__('An Amazon payment method was not chosen.', 'woocommerce-gateway-amazon-payments-advanced'));
         }
         $order = new WC_Order($order_id);
         $order_total = $order->get_total();
         $this->log(__FUNCTION__, "Info: Beginning processing of payment for (subscription) order {$order_id} for the amount of {$order_total} {$order->get_order_currency()}.");
         // Set the Billing Agreement Details
         $this->set_billing_agreement_details($order, $amazon_billing_agreement_id);
         // Confirm the Billing Agreement
         $this->confirm_billing_agreement($order_id, $amazon_billing_agreement_id);
         // Get the Billing Agreement Details, with FULL address (now that we've confirmed)
         $result = $this->get_billing_agreement_details($order_id, $amazon_billing_agreement_id);
         // Store the subscription destination
         $this->store_subscription_destination($order_id, $result);
         // Store Billing Agreement ID on the order and it's subscriptions
         $result = update_post_meta($order_id, 'amazon_billing_agreement_id', $amazon_billing_agreement_id);
         if ($result) {
             $this->log(__FUNCTION__, "Info: Successfully stored billing agreement in meta for order {$order_id}.");
         } else {
             $this->log(__FUNCTION__, "Error: Failed to store billing agreement in meta for order {$order_id}.");
         }
         $subscriptions = wcs_get_subscriptions_for_order($order_id);
         foreach ($subscriptions as $subscription) {
             $result = update_post_meta($subscription->id, 'amazon_billing_agreement_id', $amazon_billing_agreement_id);
             if ($result) {
                 $this->log(__FUNCTION__, "Info: Successfully stored billing agreement in meta for subscription {$subscription->id} (parent order {$order_id}).");
             } else {
                 $this->log(__FUNCTION__, "Error: Failed to store billing agreement in meta for subscription {$subscription->id} (parent order {$order_id}).");
             }
         }
         // Authorize/Capture initial payment, if initial payment required
         if ($order_total > 0) {
             return $this->authorize_payment($order, $amazon_billing_agreement_id);
         }
         // No payment needed now, free trial or coupon used - mark order as complete
         $order->payment_complete();
         $this->log(__FUNCTION__, "Info: Zero-total initial payment for (subscription) order {$order_id}. Payment marked as complete.");
         // Remove items from cart
         WC()->cart->empty_cart();
         // Return thank you page redirect
         return array('result' => 'success', 'redirect' => $this->get_return_url($order));
     } catch (Exception $e) {
         $this->log(__FUNCTION__, "Error: Exception encountered: {$e->getMessage()}");
         wc_add_notice(sprintf(__('Error: %s', 'woocommerce-gateway-amazon-payments-advanced'), $e->getMessage()), 'error');
         return;
     }
 }
开发者ID:lilweirdward,项目名称:blofishwordpress,代码行数:59,代码来源:class-wc-gateway-amazon-payments-advanced-subscriptions.php


示例7: create_payload

 /**
  * Setup payload for subscription webhook delivery.
  *
  * @since 2.0
  */
 public static function create_payload($payload, $resource, $resource_id, $id)
 {
     if ('subscription' == $resource && empty($payload) && wcs_is_subscription($resource_id)) {
         $webhook = new WC_Webhook($id);
         $event = $webhook->get_event();
         $current_user = get_current_user_id();
         wp_set_current_user($webhook->get_user_id());
         WC()->api->WC_API_Subscriptions->register_routes(array());
         $payload = WC()->api->WC_API_Subscriptions->get_subscription($resource_id);
         wp_set_current_user($current_user);
     }
     return $payload;
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:18,代码来源:class-wcs-webhooks.php


示例8: 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


示例9: 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


示例10: cart_items_loaded_from_session

 /**
  * Does some housekeeping. Fires after the items have been passed through the get items from session filter. Because
  * that filter is not good for removing cart items, we need to work around that by doing it later, in the cart
  * loaded from session action.
  *
  * This checks cart items whether underlying subscriptions / renewal orders they depend exist. If not, they are
  * removed from the cart.
  *
  * @param $cart WC_Cart the one we got from session
  */
 public function cart_items_loaded_from_session($cart)
 {
     $removed_count_subscription = $removed_count_order = 0;
     foreach ($cart->cart_contents as $key => $item) {
         if (isset($item[$this->cart_item_key]['subscription_id']) && !wcs_is_subscription($item[$this->cart_item_key]['subscription_id'])) {
             $cart->remove_cart_item($key);
             $removed_count_subscription++;
             continue;
         }
         if (isset($item[$this->cart_item_key]['renewal_order_id']) && !'shop_order' == get_post_type($item[$this->cart_item_key]['renewal_order_id'])) {
             $cart->remove_cart_item($key);
             $removed_count_order++;
             continue;
         }
     }
     if ($removed_count_subscription) {
         $error_message = esc_html(_n('We couldn\'t find the original subscription for an item in your cart. The item was removed.', 'We couldn\'t find the original subscriptions for items in your cart. The items were removed.', $removed_count_subscription, 'woocommerce-subscriptions'));
         if (!wc_has_notice($error_message, 'notice')) {
             wc_add_notice($error_message, 'notice');
         }
     }
     if ($removed_count_order) {
         $error_message = esc_html(_n('We couldn\'t find the original renewal order for an item in your cart. The item was removed.', 'We couldn\'t find the original renewal orders for items in your cart. The items were removed.', $removed_count_order, 'woocommerce-subscriptions'));
         if (!wc_has_notice($error_message, 'notice')) {
             wc_add_notice($error_message, 'notice');
         }
     }
 }
开发者ID:slavic18,项目名称:cats,代码行数:38,代码来源:class-wcs-cart-renewal.php


示例11: get_products

 /**
  * Get original products for a renewal order - so that we can ensure renewal coupons are only applied to those
  *
  * @param  object $subscription subscription
  * @return array $product_ids an array of product ids on a subscription renewal order
  * @since 2.0.10
  */
 protected function get_products($subscription)
 {
     $product_ids = array();
     if (wcs_is_subscription($subscription)) {
         foreach ($subscription->get_items() as $item) {
             $product_id = $item['variation_id'] ? $item['variation_id'] : $item['product_id'];
             if (!empty($product_id)) {
                 $product_ids[] = $product_id;
             }
         }
     }
     return $product_ids;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:20,代码来源:class-wcs-cart-renewal.php


示例12: get_paypal_args

 /**
  * Override the default PayPal standard args in WooCommerce for subscription purchases when
  * automatic payments are enabled and when the recurring order totals is over $0.00 (because
  * PayPal doesn't support subscriptions with a $0 recurring total, we need to circumvent it and
  * manage it entirely ourselves.)
  *
  * @since 2.0
  */
 public static function get_paypal_args($paypal_args, $order)
 {
     if (wcs_order_contains_subscription($order, array('parent', 'renewal', 'resubscribe', 'switch')) || wcs_is_subscription($order)) {
         if (self::are_reference_transactions_enabled()) {
             $paypal_args = self::get_api()->get_paypal_args($paypal_args, $order);
         } else {
             $paypal_args = WCS_PayPal_Standard_Request::get_paypal_args($paypal_args, $order);
         }
     }
     return $paypal_args;
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:19,代码来源:class-wcs-paypal.php


示例13: maybe_zero_total

 /**
  * Make sure certain totals are set to 0 when the request is to change the payment method without charging anything.
  *
  * @since 1.4
  */
 public static function maybe_zero_total($total, $subscription)
 {
     global $wp;
     if (!empty($_POST['_wcsnonce']) && wp_verify_nonce($_POST['_wcsnonce'], 'wcs_change_payment_method') && isset($_POST['woocommerce_change_payment']) && $subscription->order_key == $_GET['key'] && $subscription->id == absint($_POST['woocommerce_change_payment'])) {
         $total = 0;
     } elseif (!self::$is_request_to_change_payment && isset($wp->query_vars['order-pay']) && wcs_is_subscription(absint($wp->query_vars['order-pay']))) {
         // if the request to pay for the order belongs to a subscription but there's no GET params for changing payment method, the receipt page is being used to collect credit card details so we still need to $0 the total
         $total = 0;
     }
     return $total;
 }
开发者ID:slavic18,项目名称:cats,代码行数:16,代码来源:class-wc-subscriptions-change-payment-gateway.php


示例14: wcs_get_subscriptions_for_renewal_order

/**
 * Get the subscription to which a renewal order relates.
 *
 * @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
 * @since 2.0
 */
function wcs_get_subscriptions_for_renewal_order($order)
{
    if (!is_object($order)) {
        $order = wc_get_order($order);
    }
    $subscriptions = array();
    $subscription_ids = get_post_meta($order->id, '_subscription_renewal', false);
    foreach ($subscription_ids as $subscription_id) {
        if (wcs_is_subscription($subscription_id)) {
            $subscriptions[$subscription_id] = wcs_get_subscription($subscription_id);
        }
    }
    return apply_filters('wcs_subscriptions_for_renewal_order', $subscriptions, $order);
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:20,代码来源:wcs-renewal-functions.php


示例15: is_subscription

 /**
  * Is $order_id a subscription?
  * @param  int  $order_id
  * @return boolean
  */
 protected function is_subscription($order_id)
 {
     return function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id));
 }
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:9,代码来源:class-wc-gateway-stripe-addons.php


示例16: process_payment

 /**
  * Process the payment
  *
  * @param  int $order_id
  * @return array
  */
 public function process_payment($order_id)
 {
     // Processing subscription
     if ($this->order_contains_subscription($order_id) || function_exists('wcs_is_subscription') && wcs_is_subscription($order_id)) {
         return $this->process_subscription($order_id);
         // Processing pre-order
     } elseif ($this->order_contains_pre_order($order_id)) {
         return $this->process_pre_order($order_id);
         // Processing regular product
     } else {
         return parent::process_payment($order_id);
     }
 }
开发者ID:bmcgowan,项目名称:woocommerce-payeezy,代码行数:19,代码来源:class-wc-payeezy-gateway-addons.php


示例17: order_has_subscription

		/**
		 * Check if the order has a subscription (either according to Subscriptions 1.5 or 2.0)
		 *
		 * @param string $order_id The ID of the order to check
		 * @return mixed Either 1 (Subscriptions 1.5), 2 (Subscriptions 2) or false (no order)
		 */
		function order_has_subscription($order_id) {
			// Subscriptions not loaded
			if (!class_exists('WC_Subscriptions_Order')) return false;

			// Subscriptions v2.0
			if (function_exists('wcs_order_contains_subscription')) {
				if (wcs_order_contains_subscription($order_id) || wcs_order_contains_renewal( $order_id ) || ( function_exists( 'wcs_is_subscription' ) && wcs_is_subscription( $order_id ))) {
					return 2;
				} else {
					return false;
				}
			}
			
			// Subscriptions v1.5
			if (WC_Subscriptions_Order::order_contains_subscription($order_id)) {
				return 1;
			}

			return false;
		}
开发者ID:verbazend,项目名称:AWFA,代码行数:26,代码来源:woocommerce-nab-dp.php


示例18: get_synced_sign_up_fee

 /**
  * Filters WC_Subscriptions_Order::get_sign_up_fee() to make sure the sign-up fee for a subscription product
  * that is synchronised is returned correctly.
  *
  * @param float The initial sign-up fee charged when the subscription product in the order was first purchased, if any.
  * @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
  * @param int $product_id The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
  * @return float The initial sign-up fee charged when the subscription product in the order was first purchased, if any.
  * @since 2.0
  */
 public static function get_synced_sign_up_fee($sign_up_fee, $subscription, $product_id)
 {
     if (wcs_is_subscription($subscription) && self::subscription_contains_synced_product($subscription) && count(wcs_get_line_items_with_a_trial($subscription->id)) < 0) {
         $sign_up_fee = max($subscription->get_total_initial_payment() - $subscription->get_total(), 0);
     }
     return $sign_up_fee;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:17,代码来源:class-wc-subscriptions-synchroniser.php


示例19: cart_contains_switches

 /**
  * Check if the cart includes any items which are to switch an existing subscription's item.
  *
  * @return bool|array Returns all the items that are for a switching or false if none of the items in the cart are a switch request.
  * @since 2.0
  */
 public static function cart_contains_switches()
 {
     $subscription_switches = false;
     if (is_admin() && (!defined('DOING_AJAX') || false == DOING_AJAX)) {
         return $subscription_switches;
     }
     if (isset(WC()->cart)) {
         // We use WC()->cart->cart_contents instead of WC()->cart->get_cart() to prevent recursion caused when get_cart_from_session() too early is called ref: https://github.com/woothemes/woocommerce/commit/1f3365f2066b1e9d7e84aca7b1d7e89a6989c213
         foreach (WC()->cart->cart_contents as $cart_item_key => $cart_item) {
             if (isset($cart_item['subscription_switch'])) {
                 if (wcs_is_subscription($cart_item['subscription_switch']['subscription_id'])) {
                     $subscription_switches[$cart_item_key] = $cart_item['subscription_switch'];
                 } else {
                     WC()->cart->remove_cart_item($cart_item_key);
                     WC_Subscriptions::add_notice(__('Your cart contained an invalid subscription switch request. It has been removed.', 'woocommerce-subscriptions'), 'error');
                 }
             }
         }
     }
     return $subscription_switches;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:27,代码来源:class-wc-subscriptions-switcher.php


示例20: add_order_note

 /**
  * Add order note to subscription to record the renewal order
  *
  * @param WC_Order|int $renewal_order
  * @param WC_Subscription|int $subscription
  * @since 2.0
  */
 public static function add_order_note($renewal_order, $subscription)
 {
     if (!is_object($subscription)) {
         $subscription = wcs_get_subscription($subscription);
     }
     if (!is_object($renewal_order)) {
         $renewal_order = wc_get_order($renewal_order);
     }
     if (is_a($renewal_order, 'WC_Order') && wcs_is_subscription($subscription)) {
         // translators: placeholder is order number, hash before order number
         $order_number = sprintf(__('#%s', 'woocommerce-subscriptions'), $renewal_order->get_order_number());
         // translators: placeholder is order ID
         $subscription->add_order_note(sprintf(__('Order %s created to record renewal.', 'woocommerce-subscriptions'), sprintf('<a href="%s">%s</a> ', esc_url(wcs_get_edit_post_link($renewal_order->id)), $order_number)));
     }
     return $renewal_order;
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:23,代码来源:class-wc-subscriptions-renewal-order.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wcs_order_contains_renewal函数代码示例发布时间:2022-05-23
下一篇:
PHP wcs_get_subscriptions_for_order函数代码示例发布时间: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