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


PHP WC_Subscriptions::is_woocommerce_pre_2_1方法代码示例

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


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

示例1: maybe_show_admin_notice

    /**
     * Prompt the store manager to enter their PayPal API credentials if they are using 
     * PayPal and have yet not entered their API credentials.
     *
     * @return void
     */
    public static function maybe_show_admin_notice()
    {
        self::get_wc_paypal_settings();
        if (!in_array(get_woocommerce_currency(), apply_filters('woocommerce_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB')))) {
            $valid_for_use = false;
        } else {
            $valid_for_use = true;
        }
        if (WC_Subscriptions::is_woocommerce_pre_2_1()) {
            $payment_gateway_tab_url = admin_url('admin.php?page=woocommerce_settings&tab=payment_gateways&section=WC_Gateway_Paypal');
        } else {
            $payment_gateway_tab_url = admin_url('admin.php?page=wc-settings&tab=checkout&section=wc_gateway_paypal');
        }
        if (!self::are_credentials_set() && $valid_for_use && 'yes' == self::$paypal_settings['enabled'] && !has_action('admin_notices', 'WC_Subscriptions_Admin::admin_installed_notice') && current_user_can('manage_options')) {
            ?>
<div id="message" class="updated warning">
	<p>
		<?php 
            printf(__('Just a few more steps to configure PayPal to sell subscriptions. Please %sset up the PayPal IPN%s and %senter your API credentials%s so that you can suspend and cancel subscriptions.', 'woocommerce-subscriptions'), '<a href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '</a>', '<a href="' . $payment_gateway_tab_url . '">', '</a>');
            ?>
	</p>
</div>
<?php 
        }
    }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:31,代码来源:gateway-paypal-standard-subscriptions.php

示例2: change_payment_method_button

 /**
  * Add a "Change Payment Method" button to the "My Subscriptions" table.
  *
  * @param array $all_actions The $subscription_key => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
  * @param array $subscriptions All of a given users subscriptions that will be displayed on the "My Subscriptions" table
  * @since 1.4
  */
 public static function change_payment_method_button($all_actions, $subscriptions)
 {
     foreach ($all_actions as $subscription_key => $actions) {
         $order = new WC_Order($subscriptions[$subscription_key]['order_id']);
         if (WC_Subscriptions_Manager::can_subscription_be_changed_to('new-payment-method', $subscription_key, get_current_user_id())) {
             if (!WC_Subscriptions::is_woocommerce_pre_2_1()) {
                 // WC 2.1+
                 $url = add_query_arg(array('change_payment_method' => $subscription_key, 'order_id' => $order->id), $order->get_checkout_payment_url());
                 $url = wp_nonce_url($url, __FILE__);
             } else {
                 $url = add_query_arg(array('change_payment_method' => $subscription_key, 'order_id' => $order->id, 'order' => $order->order_key), get_permalink(woocommerce_get_page_id('pay')));
                 $url = wp_nonce_url($url, __FILE__);
             }
             $all_actions[$subscription_key] = array('change_payment_method' => array('url' => $url, 'name' => __('Change Payment Method', 'woocommerce-subscriptions'))) + $all_actions[$subscription_key];
         }
     }
     return $all_actions;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:25,代码来源:class-wc-subscriptions-change-payment-gateway.php

示例3: settings_tab_url

 /**
  * A WooCommerce version aware function for getting the Subscriptions admin settings
  * tab URL.
  *
  * @since 1.4.5
  * @return string
  */
 public static function settings_tab_url()
 {
     if (WC_Subscriptions::is_woocommerce_pre_2_1()) {
         $settings_tab_url = admin_url('admin.php?page=woocommerce_settings&tab=subscriptions');
     } else {
         $settings_tab_url = admin_url('admin.php?page=wc-settings&tab=subscriptions');
     }
     return apply_filters('woocommerce_subscriptions_settings_tab_url', $settings_tab_url);
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:16,代码来源:class-wc-subscriptions-admin.php

示例4: generate_renewal_order


//.........这里部分代码省略.........
         $order_meta_query .= " AND `meta_key` NOT IN ('_payment_method', '_payment_method_title', '_recurring_payment_method', '_recurring_payment_method_title', '_shipping_method', '_shipping_method_title', '_recurring_shipping_method', '_recurring_shipping_method_title')";
     } else {
         $order_meta_query .= " AND `meta_key` NOT LIKE '_order_recurring_%' AND `meta_key` NOT IN ('_payment_method', '_payment_method_title', '_recurring_payment_method', '_recurring_payment_method_title', '_shipping_method', '_shipping_method_title', '_recurring_shipping_method', '_recurring_shipping_method_title')";
     }
     // Allow extensions to add/remove order meta
     $order_meta_query = apply_filters('woocommerce_subscriptions_renewal_order_meta_query', $order_meta_query, $original_order->id, $renewal_order_id, $args['new_order_role']);
     // Carry all the required meta from the old order over to the new order
     $order_meta = $wpdb->get_results($order_meta_query, 'ARRAY_A');
     $order_meta = apply_filters('woocommerce_subscriptions_renewal_order_meta', $order_meta, $original_order->id, $renewal_order_id, $args['new_order_role']);
     foreach ($order_meta as $meta_item) {
         add_post_meta($renewal_order_id, $meta_item['meta_key'], maybe_unserialize($meta_item['meta_value']), true);
     }
     $outstanding_balance = WC_Subscriptions_Order::get_outstanding_balance($original_order, $product_id);
     $failed_payment_multiplier = 1;
     if (false == $args['checkout_renewal']) {
         // If there are outstanding payment amounts, add them to the order, otherwise set the order details to the values of the recurring totals
         if ($outstanding_balance > 0 && 'yes' == get_option(WC_Subscriptions_Admin::$option_prefix . '_add_outstanding_balance', 'no')) {
             $failed_payment_multiplier = WC_Subscriptions_Order::get_failed_payment_count($original_order, $product_id);
         }
         // Set order totals based on recurring totals from the original order
         $cart_discount = $failed_payment_multiplier * get_post_meta($original_order->id, '_order_recurring_discount_cart', true);
         $order_discount = $failed_payment_multiplier * get_post_meta($original_order->id, '_order_recurring_discount_total', true);
         $order_shipping_tax = $failed_payment_multiplier * get_post_meta($original_order->id, '_order_recurring_shipping_tax_total', true);
         $order_shipping = $failed_payment_multiplier * get_post_meta($original_order->id, '_order_recurring_shipping_total', true);
         $order_tax = $failed_payment_multiplier * get_post_meta($original_order->id, '_order_recurring_tax_total', true);
         $order_total = $failed_payment_multiplier * get_post_meta($original_order->id, '_order_recurring_total', true);
         update_post_meta($renewal_order_id, '_cart_discount', $cart_discount);
         update_post_meta($renewal_order_id, '_order_discount', $order_discount);
         update_post_meta($renewal_order_id, '_order_shipping_tax', $order_shipping_tax);
         update_post_meta($renewal_order_id, '_order_shipping', $order_shipping);
         update_post_meta($renewal_order_id, '_order_tax', $order_tax);
         update_post_meta($renewal_order_id, '_order_total', $order_total);
         // Set shipping for orders created with WC 2.0.n (or when we are using WC 2.0.n)
         if (WC_Subscriptions::is_woocommerce_pre_2_1() || isset($original_order->recurring_shipping_method)) {
             update_post_meta($renewal_order_id, '_shipping_method', $original_order->recurring_shipping_method);
             update_post_meta($renewal_order_id, '_shipping_method_title', $original_order->recurring_shipping_method_title);
             // Also set recurring shipping as it's a parent renewal order
             if ('parent' == $args['new_order_role']) {
                 update_post_meta($renewal_order_id, '_recurring_shipping_method', $original_order->recurring_shipping_method);
                 update_post_meta($renewal_order_id, '_recurring_shipping_method_title', $original_order->recurring_shipping_method_title);
             }
         }
         // Apply the recurring shipping & payment methods to child renewal orders
         if ('child' == $args['new_order_role']) {
             update_post_meta($renewal_order_id, '_payment_method', $original_order->recurring_payment_method);
             update_post_meta($renewal_order_id, '_payment_method_title', $original_order->recurring_payment_method_title);
         }
         // Set order taxes based on recurring taxes from the original order
         $recurring_order_taxes = WC_Subscriptions_Order::get_recurring_taxes($original_order);
         foreach ($recurring_order_taxes as $index => $recurring_order_tax) {
             $item_ids = array();
             $item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_order_tax['name'], 'order_item_type' => 'tax'));
             // Also set recurring taxes on parent renewal orders
             if ('parent' == $args['new_order_role']) {
                 $item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_order_tax['name'], 'order_item_type' => 'recurring_tax'));
             }
             // Add line item meta
             foreach ($item_ids as $item_id) {
                 woocommerce_add_order_item_meta($item_id, 'compound', absint(isset($recurring_order_tax['compound']) ? $recurring_order_tax['compound'] : 0));
                 woocommerce_add_order_item_meta($item_id, 'tax_amount', woocommerce_clean($failed_payment_multiplier * $recurring_order_tax['tax_amount']));
                 woocommerce_add_order_item_meta($item_id, 'shipping_tax_amount', woocommerce_clean($failed_payment_multiplier * $recurring_order_tax['shipping_tax_amount']));
                 if (isset($recurring_order_tax['rate_id'])) {
                     woocommerce_add_order_item_meta($item_id, 'rate_id', $recurring_order_tax['rate_id']);
                 }
                 if (isset($recurring_order_tax['label'])) {
                     woocommerce_add_order_item_meta($item_id, 'label', $recurring_order_tax['label']);
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:67,代码来源:class-wc-subscriptions-renewal-order.php

示例5: maybe_show_admin_notice

    /**
     * Prompt the store manager to enter their PayPal API credentials if they are using 
     * PayPal and have yet not entered their API credentials.
     *
     * @return void
     */
    public static function maybe_show_admin_notice()
    {
        if (isset($_GET['wcs_disable_paypal_invalid_profile_id_notice'])) {
            update_option('wcs_paypal_invalid_profile_id', 'disabled');
        }
        // Check if the API credentials are being saved - we can't do this on the 'woocommerce_update_options_payment_gateways_paypal' hook because it is triggered after 'admin_notices'
        if (isset($_POST['woocommerce_paypal_api_username']) || isset($_POST['woocommerce_paypal_api_password']) || isset($_POST['woocommerce_paypal_api_signature'])) {
            $current_options = self::get_wc_paypal_settings();
            $credentials_updated = false;
            if (isset($_POST['woocommerce_paypal_api_username']) && $_POST['woocommerce_paypal_api_username'] != $current_options['api_username']) {
                $credentials_updated = true;
            } elseif (isset($_POST['woocommerce_paypal_api_password']) && $_POST['woocommerce_paypal_api_password'] != $current_options['api_password']) {
                $credentials_updated = true;
            } elseif (isset($_POST['woocommerce_paypal_api_signature']) && $_POST['woocommerce_paypal_api_signature'] != $current_options['api_signature']) {
                $credentials_updated = true;
            }
            if ($credentials_updated) {
                delete_option('wcs_paypal_credentials_error');
            }
        }
        if (!in_array(get_woocommerce_currency(), apply_filters('woocommerce_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB')))) {
            $valid_for_use = false;
        } else {
            $valid_for_use = true;
        }
        if (WC_Subscriptions::is_woocommerce_pre_2_1()) {
            $payment_gateway_tab_url = admin_url('admin.php?page=woocommerce_settings&tab=payment_gateways&section=WC_Gateway_Paypal');
        } else {
            $payment_gateway_tab_url = admin_url('admin.php?page=wc-settings&tab=checkout&section=wc_gateway_paypal');
        }
        if (!self::are_credentials_set() && $valid_for_use && 'yes' == self::$paypal_settings['enabled'] && !has_action('admin_notices', 'WC_Subscriptions_Admin::admin_installed_notice') && current_user_can('manage_options')) {
            ?>
<div id="message" class="updated error">
	<p><?php 
            printf(__('PayPal is inactive for subscription transactions. Please %sset up the PayPal IPN%s and %senter your API credentials%s to enable PayPal for Subscriptions.', 'woocommerce-subscriptions'), '<a href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '</a>', '<a href="' . $payment_gateway_tab_url . '">', '</a>');
            ?>
	</p>
</div>
<?php 
        }
        if (false !== get_option('wcs_paypal_credentials_error')) {
            ?>
<div id="message" class="updated error">
	<p><?php 
            printf(__('There is a problem with PayPal. Your API credentials may be incorrect. Please update your %sAPI credentials%s. %sLearn more%s.', 'woocommerce-subscriptions'), '<a href="' . $payment_gateway_tab_url . '">', '</a>', '<a href="https://support.woothemes.com/hc/en-us/articles/202882473#paypal-credentials" target="_blank">', '</a>');
            ?>
	</p>
</div>
<?php 
        }
        if ('yes' == get_option('wcs_paypal_invalid_profile_id')) {
            ?>
<div id="message" class="updated error">
	<p><?php 
            printf(__('There is a problem with PayPal. Your PayPal account is issuing out-of-date subscription IDs. %sLearn more%s. %sDismiss%s.', 'woocommerce-subscriptions'), '<a href="https://support.woothemes.com/hc/en-us/articles/202882473#old-paypal-account" target="_blank">', '</a>', '<a href="' . add_query_arg('wcs_disable_paypal_invalid_profile_id_notice', 'true') . '">', '</a>');
            ?>
	</p>
</div>
<?php 
        }
    }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:67,代码来源:gateway-paypal-standard-subscriptions.php

示例6: recurring_order_totals_meta_box_section

    /**
     * Display recurring order totals on the "Edit Order" page.
     *
     * @param int $post_id The post ID of the shop_order post object.
     * @since 1.2.4
     * @return void
     */
    public static function recurring_order_totals_meta_box_section($post_id)
    {
        global $woocommerce, $wpdb;
        $order = new WC_Order($post_id);
        $display_none = ' style="display: none"';
        $contains_subscription = self::order_contains_subscription($order) ? true : false;
        $chosen_gateway = WC_Subscriptions_Payment_Gateways::get_payment_gateway(get_post_meta($post_id, '_recurring_payment_method', true));
        $manual_renewal = self::requires_manual_renewal($post_id);
        $changes_supported = $chosen_gateway === false || $manual_renewal == 'true' || $chosen_gateway->supports('subscription_amount_changes') ? 'true' : 'false';
        $data = get_post_meta($post_id);
        ?>
	<div class="clear"></div>
</div>
<div id="gateway_support"<?php 
        if (!$contains_subscription) {
            echo $display_none;
        }
        ?>
>
	<input type="hidden" name="gateway_supports_subscription_changes" value="<?php 
        echo $changes_supported;
        ?>
">
	<div class="error"<?php 
        if (!$contains_subscription || $changes_supported == 'true') {
            echo $display_none;
        }
        ?>
>
		<p><?php 
        printf(__('The %s payment gateway is used to charge automatic subscription payments for this order. This gateway <strong>does not</strong> support changing a subscription\'s details.', 'woocommerce-subscriptions'), get_post_meta($post_id, '_recurring_payment_method_title', true));
        ?>
</p>
		<p>
			<?php 
        _e('It is strongly recommended you <strong>do not change</strong> any of the recurring totals or subscription item\'s details.', 'woocommerce-subscriptions');
        ?>
			<a href="http://docs.woothemes.com/document/subscriptions/add-or-modify-a-subscription/#section-4"><?php 
        _e('Learn More', 'woocommerce-subscriptions');
        ?>
 &raquo;</a>
		</p>
	</div>
</div>
<div id="recurring_order_totals"<?php 
        if (!$contains_subscription) {
            echo $display_none;
        }
        ?>
>
	<h3><?php 
        _e('Recurring Totals', 'woocommerce-subscriptions');
        ?>
</h3>

	<div class="totals_group">
		<h4><span class="tax_total_display inline_total"></span><?php 
        _e('Shipping for Renewal Orders', 'woocommerce-subscriptions');
        ?>
</h4>
		<div id="recurring_shipping_rows">
		<?php 
        if (!WC_Subscriptions::is_woocommerce_pre_2_1()) {
            if ($woocommerce->shipping()) {
                $shipping_methods = $woocommerce->shipping->load_shipping_methods();
            }
            foreach (self::get_recurring_shipping_methods($order) as $item_id => $item) {
                $chosen_method = $item['method_id'];
                $shipping_title = $item['name'];
                $shipping_cost = $item['cost'];
                include plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/admin/post-types/writepanels/order-shipping-html.php';
            }
            // Shipping created pre 2.1
            if (isset($data['_recurring_shipping_method'])) {
                $item_id = 'old';
                // so that when saving, we know to delete the data in the old form
                $chosen_method = !empty($data['_recurring_shipping_method'][0]) ? $data['_recurring_shipping_method'][0] : '';
                $shipping_title = !empty($data['_recurring_shipping_method_title'][0]) ? $data['_recurring_shipping_method_title'][0] : '';
                $shipping_cost = !empty($data['_order_recurring_shipping_total'][0]) ? $data['_order_recurring_shipping_total'][0] : '0.00';
                include plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/admin/post-types/writepanels/order-shipping-html.php';
            }
            ?>
		<?php 
        } else {
            // WC < 2.1
            ?>
			<ul class="totals">
				<li class="wide">
					<label><?php 
            _e('Label:', 'woocommerce-subscriptions');
            ?>
</label>
					<input type="text" id="_recurring_shipping_method_title" name="_recurring_shipping_method_title" placeholder="<?php 
//.........这里部分代码省略.........
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:101,代码来源:class-wc-subscriptions-order.php

示例7: add_order_meta

 /**
  * When a new order is inserted, add subscriptions related order meta.
  *
  * @since 1.0
  */
 public static function add_order_meta($order_id, $posted)
 {
     global $woocommerce;
     if (!WC_Subscriptions_Cart::cart_contains_subscription_renewal('child') && WC_Subscriptions_Order::order_contains_subscription($order_id)) {
         // This works because the 'woocommerce_add_order_item_meta' runs before the 'woocommerce_checkout_update_order_meta' hook
         // Set the recurring totals so totals display correctly on order page
         update_post_meta($order_id, '_order_recurring_discount_cart', WC_Subscriptions_Cart::get_recurring_discount_cart());
         update_post_meta($order_id, '_order_recurring_discount_total', WC_Subscriptions_Cart::get_recurring_discount_total());
         update_post_meta($order_id, '_order_recurring_shipping_tax_total', WC_Subscriptions_Cart::get_recurring_shipping_tax_total());
         update_post_meta($order_id, '_order_recurring_shipping_total', WC_Subscriptions_Cart::get_recurring_shipping_total());
         update_post_meta($order_id, '_order_recurring_tax_total', WC_Subscriptions_Cart::get_recurring_total_tax());
         update_post_meta($order_id, '_order_recurring_total', WC_Subscriptions_Cart::get_recurring_total());
         // Set the recurring payment method - it starts out the same as the original by may change later
         update_post_meta($order_id, '_recurring_payment_method', get_post_meta($order_id, '_payment_method', true));
         update_post_meta($order_id, '_recurring_payment_method_title', get_post_meta($order_id, '_payment_method_title', true));
         $order = new WC_Order($order_id);
         $order_fees = $order->get_fees();
         // the fee order items have already been set, we just need to to add the recurring total meta
         $cart_fees = $woocommerce->cart->get_fees();
         foreach ($order->get_fees() as $item_id => $order_fee) {
             // Find the matching fee in the cart
             foreach ($cart_fees as $fee_index => $cart_fee) {
                 if (sanitize_title($order_fee['name']) == $cart_fee->id) {
                     woocommerce_add_order_item_meta($item_id, '_recurring_line_total', wc_format_decimal($cart_fee->recurring_amount));
                     woocommerce_add_order_item_meta($item_id, '_recurring_line_tax', wc_format_decimal($cart_fee->recurring_tax));
                     unset($cart_fees[$fee_index]);
                     break;
                 }
             }
         }
         // Get recurring taxes into same format as _order_taxes
         $order_recurring_taxes = array();
         foreach (WC_Subscriptions_Cart::get_recurring_taxes() as $tax_key => $tax_amount) {
             $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => WC_Tax::get_rate_code($tax_key), 'order_item_type' => 'recurring_tax'));
             if ($item_id) {
                 wc_add_order_item_meta($item_id, 'rate_id', $tax_key);
                 wc_add_order_item_meta($item_id, 'label', WC_Tax::get_rate_label($tax_key));
                 wc_add_order_item_meta($item_id, 'compound', absint(WC_Tax::is_compound($tax_key) ? 1 : 0));
                 wc_add_order_item_meta($item_id, 'tax_amount', wc_format_decimal(isset(WC()->cart->recurring_taxes[$tax_key]) ? WC()->cart->recurring_taxes[$tax_key] : 0));
                 wc_add_order_item_meta($item_id, 'shipping_tax_amount', wc_format_decimal(isset(WC()->cart->recurring_shipping_taxes[$tax_key]) ? WC()->cart->recurring_shipping_taxes[$tax_key] : 0));
             }
         }
         $payment_gateways = $woocommerce->payment_gateways->payment_gateways();
         if ('yes' == get_option(WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no')) {
             update_post_meta($order_id, '_wcs_requires_manual_renewal', 'true');
         } elseif (isset($payment_gateways[$posted['payment_method']]) && !$payment_gateways[$posted['payment_method']]->supports('subscriptions')) {
             update_post_meta($order_id, '_wcs_requires_manual_renewal', 'true');
         }
         $cart_item = WC_Subscriptions_Cart::cart_contains_subscription_renewal();
         if (isset($cart_item['subscription_renewal']) && 'parent' == $cart_item['subscription_renewal']['role']) {
             update_post_meta($order_id, '_original_order', $cart_item['subscription_renewal']['original_order']);
         }
         // WC 2.1+
         if (!WC_Subscriptions::is_woocommerce_pre_2_1()) {
             // Recurring coupons
             if ($applied_coupons = $woocommerce->cart->get_coupons()) {
                 foreach ($applied_coupons as $code => $coupon) {
                     if (!isset($woocommerce->cart->recurring_coupon_discount_amounts[$code])) {
                         continue;
                     }
                     $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => $code, 'order_item_type' => 'recurring_coupon'));
                     // Add line item meta
                     if ($item_id) {
                         woocommerce_add_order_item_meta($item_id, 'discount_amount', isset($woocommerce->cart->recurring_coupon_discount_amounts[$code]) ? $woocommerce->cart->recurring_coupon_discount_amounts[$code] : 0);
                     }
                 }
             }
             // Add recurring shipping order items
             if (WC_Subscriptions_Cart::cart_contains_subscriptions_needing_shipping()) {
                 $packages = $woocommerce->shipping->get_packages();
                 $checkout = $woocommerce->checkout();
                 foreach ($packages as $i => $package) {
                     if (isset($package['rates'][$checkout->shipping_methods[$i]])) {
                         $method = $package['rates'][$checkout->shipping_methods[$i]];
                         $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => $method->label, 'order_item_type' => 'recurring_shipping'));
                         if ($item_id) {
                             woocommerce_add_order_item_meta($item_id, 'method_id', $method->id);
                             woocommerce_add_order_item_meta($item_id, 'cost', WC_Subscriptions::format_total($method->cost));
                             woocommerce_add_order_item_meta($item_id, 'taxes', array_map('wc_format_decimal', $method->taxes));
                             do_action('woocommerce_subscriptions_add_recurring_shipping_order_item', $order_id, $item_id, $i);
                         }
                     }
                 }
             }
             // Remove shipping on original order if it was added but is not required
             if (!WC_Subscriptions_Cart::charge_shipping_up_front()) {
                 foreach ($order->get_shipping_methods() as $order_item_id => $shipping_method) {
                     woocommerce_update_order_item_meta($order_item_id, 'cost', WC_Subscriptions::format_total(0));
                 }
             }
         } else {
             update_post_meta($order_id, '_recurring_shipping_method', get_post_meta($order_id, '_shipping_method', true), true);
             update_post_meta($order_id, '_recurring_shipping_method_title', get_post_meta($order_id, '_shipping_method_title', true), true);
         }
     }
//.........这里部分代码省略.........
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:101,代码来源:class-wc-subscriptions-checkout.php


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