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


PHP wc_add_order_item_meta函数代码示例

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


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

示例1: _add_booking_order_meta

 function _add_booking_order_meta($item_id, $cart_data, $cart_item_key)
 {
     if (isset($cart_data['st_booking_data']) and !empty($cart_data['st_booking_data'])) {
         $st_booking_data = $cart_data['st_booking_data'];
         foreach ($st_booking_data as $key => $value) {
             wc_add_order_item_meta($item_id, '_st_' . $key, $value);
         }
     }
 }
开发者ID:HatchForce,项目名称:bachtraveller,代码行数:9,代码来源:class.woocommerce.php

示例2: order_item_meta

 public function order_item_meta($item_id, $values, $cart_item_key)
 {
     //  wc_add_order_item_meta( $item_id, "gift_wrap", 'Yes' );
     if (isset($values["wpb_cart_items"])) {
         wc_add_order_item_meta($item_id, "wpb_cart_items", $values["wpb_cart_items"]);
     }
 }
开发者ID:shirso,项目名称:wc-product-builder,代码行数:7,代码来源:class-product-cart.php

示例3: set

 function set($item_id, $values, $cart_item_key)
 {
     global $wpdb;
     global $DOPBSP;
     $reservation_data = $wpdb->get_row('SELECT * FROM ' . $DOPBSP->tables->woocommerce . ' WHERE variation_id=' . wc_get_order_item_meta($item_id, '_variation_id'));
     if ($reservation_data) {
         $reservation = json_decode($reservation_data->data);
         $reservation->currency = $reservation_data->currency;
         $reservation->item_id = $item_id;
         $calendar = $wpdb->get_row('SELECT * FROM ' . $DOPBSP->tables->calendars . ' WHERE id=' . $reservation_data->calendar_id);
         $settings = $wpdb->get_row('SELECT * FROM ' . $DOPBSP->tables->settings . ' WHERE calendar_id=' . $reservation_data->calendar_id);
         $DOPBSP->classes->translation->setTranslation($reservation_data->language, false);
         /*
          * Display details data.
          */
         wc_add_order_item_meta($item_id, $DOPBSP->text('RESERVATIONS_RESERVATION_DETAILS_TITLE'), $this->getDetails($reservation, $calendar, $settings));
         /*
          * Display extra data.
          */
         if ($settings->extra != 0) {
             wc_add_order_item_meta($item_id, $DOPBSP->text('EXTRAS_FRONT_END_TITLE'), $this->getExtras($reservation, $settings));
         }
         /*
          * Display discount data.
          */
         if ($settings->discount != 0) {
             wc_add_order_item_meta($item_id, $DOPBSP->text('DISCOUNTS_FRONT_END_TITLE'), $this->getDiscount($reservation, $settings));
         }
     }
 }
开发者ID:ConceptHaus,项目名称:jolie,代码行数:30,代码来源:class-woocommerce-order.php

示例4: add_order_item_meta

 /**
  * Add bundle info meta to order items.
  *
  * @param  int      $item_id      order item id
  * @param  array    $cart_item_values   cart item data
  * @return void
  */
 public function add_order_item_meta($item_id, $cart_item_values, $cart_item_key)
 {
     // add data to the product
     if (isset($cart_item_values['wc-boilerplate-extension-number'])) {
         wc_add_order_item_meta($item_id, '_wc-boilerplate-extension-number', $cart_item_values['wc-boilerplate-extension-number']);
     }
     if (isset($cart_item_values['wc-boilerplate-extension-textbox'])) {
         wc_add_order_item_meta($item_id, '_wc-boilerplate-extension-textbox', $cart_item_values['wc-boilerplate-extension-textbox']);
     }
 }
开发者ID:helgatheviking,项目名称:wc-extension-boilerplate,代码行数:17,代码来源:class-wc-extension-boilerplate-order.php

示例5: easy_booking_add_order_meta

 /**
  *
  * Adds booked dates to the order item
  *
  * @param int $item_id
  * @param array $values - 
  *
  **/
 public function easy_booking_add_order_meta($item_id, $values)
 {
     $start_text = !empty($this->options['easy_booking_start_date_text']) ? $this->options['easy_booking_start_date_text'] : __('Start', 'easy_booking');
     $end_text = !empty($this->options['easy_booking_end_date_text']) ? $this->options['easy_booking_end_date_text'] : __('End', 'easy_booking');
     if (!empty($values['_start_date'])) {
         wc_add_order_item_meta($item_id, $start_text, $values['_start_date']);
         wc_add_order_item_meta($item_id, '_ebs_start_display', $values['_start_date']);
     }
     if (!empty($values['_end_date'])) {
         wc_add_order_item_meta($item_id, $end_text, $values['_end_date']);
         wc_add_order_item_meta($item_id, '_ebs_end_display', $values['_end_date']);
     }
     if (!empty($values['_ebs_start'])) {
         wc_add_order_item_meta($item_id, '_ebs_start_format', $values['_ebs_start']);
     }
     if (!empty($values['_ebs_end'])) {
         wc_add_order_item_meta($item_id, '_ebs_end_format', $values['_ebs_end']);
     }
 }
开发者ID:noikiy,项目名称:woocommerce-easy-booking-system,代码行数:27,代码来源:class-wceb-checkout.php

示例6: order_item_meta

 public function order_item_meta($item_id, $cart_item)
 {
     if (isset($cart_item['wbm_product_cart']) && isset($cart_item['wbm_product_price']) && isset($cart_item['wbm_product_attributes'])) {
         $wbm_cart_array = $cart_item['wbm_product_attributes']["main"];
         $mainAttr = $wbm_cart_array["mainattr"];
         unset($wbm_cart_array["mainattr"]);
         $html = '';
         foreach ($wbm_cart_array as $key => $value) {
             $html .= '&nbsp;&nbsp;<strong>' . $value[0] . '</strong><br/>';
             if (isset($value["selectbox"]) && !empty($value["selectbox"])) {
                 foreach ($value["selectbox"] as $k => $v) {
                     $html .= '&nbsp;&nbsp;&nbsp;&nbsp;' . $v . '<br/>';
                 }
             }
             if (isset($value["dates"]) && !empty($value["dates"])) {
                 foreach ($value["dates"] as $m => $n) {
                     $html .= '&nbsp;&nbsp;&nbsp;&nbsp;' . $n . '<br/>';
                 }
             }
         }
         wc_add_order_item_meta($item_id, $mainAttr, $html);
     }
 }
开发者ID:shirso,项目名称:woo-booking-module,代码行数:23,代码来源:class-product-cart.php

示例7: add_vendor_to_order_item_meta

 public static function add_vendor_to_order_item_meta($item_id, $cart_item)
 {
     $vendor_id = $cart_item['data']->post->post_author;
     $sold_by_label = WC_Vendors::$pv_options->get_option('sold_by_label');
     $sold_by = WCV_Vendors::is_vendor($vendor_id) ? sprintf(WCV_Vendors::get_vendor_sold_by($vendor_id)) : get_bloginfo('name');
     wc_add_order_item_meta($item_id, apply_filters('wcvendors_sold_by_in_email', $sold_by_label), $sold_by);
 }
开发者ID:simplementNat,项目名称:wcvendors,代码行数:7,代码来源:class-vendor-shop.php

示例8: set_order_meta

 /**
  * Adds product description to order meta
  *  
  * @param int $order_id 
  * @param int $item_id  
  * @param object $product  
  * @param int $qty      
  * @param array $args     
  */
 public function set_order_meta($order_id, $item_id, $product, $qty, $args)
 {
     wc_add_order_item_meta($item_id, '_units', wc_gzd_get_gzd_product($product)->get_product_units_html());
     wc_add_order_item_meta($item_id, '_delivery_time', wc_gzd_get_gzd_product($product)->get_delivery_time_html());
     wc_add_order_item_meta($item_id, '_item_desc', wc_gzd_get_gzd_product($product)->get_mini_desc());
     wc_add_order_item_meta($item_id, '_unit_price', wc_gzd_get_gzd_product($product)->get_unit_html(false));
 }
开发者ID:ronzeiller,项目名称:woocommerce-germanized,代码行数:16,代码来源:class-wc-gzd-checkout.php

示例9: add_product_input_fields_to_order_item_meta

 /**
  * add_product_input_fields_to_order_item_meta.
  */
 public function add_product_input_fields_to_order_item_meta($item_id, $values, $cart_item_key)
 {
     $total_number = apply_filters('wcj_get_option_filter', 1, $this->get_value('wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $values['product_id'], 1));
     for ($i = 1; $i <= $total_number; $i++) {
         if (array_key_exists('wcj_product_input_fields_' . $this->scope . '_' . $i, $values)) {
             $type = $this->get_value('wcj_product_input_fields_type_' . $this->scope . '_' . $i, $values['product_id'], '');
             $input_field_value = $values['wcj_product_input_fields_' . $this->scope . '_' . $i];
             if ('file' === $type) {
                 $tmp_name = $input_field_value['tmp_name'];
                 $ext = pathinfo($input_field_value['name'], PATHINFO_EXTENSION);
                 $name = $item_id . '.' . $ext;
                 //$input_field_value['name'];
                 $upload_dir = wcj_get_wcj_uploads_dir('input_fields_uploads');
                 if (!file_exists($upload_dir)) {
                     mkdir($upload_dir, 0755, true);
                 }
                 //$upload_dir = ( wp_mkdir_p( $upload_dir['path'] ) ) ? $upload_dir['path'] : $upload_dir['basedir'];
                 $upload_dir_and_name = $upload_dir . '/' . $name;
                 //move_uploaded_file( $tmp_name, $upload_dir_and_name );
                 $file_data = file_get_contents($tmp_name);
                 file_put_contents($upload_dir_and_name, $file_data);
                 unlink($tmp_name);
                 //unset( $input_field_value['tmp_name'] );
                 $input_field_value['tmp_name'] = $upload_dir_and_name;
                 $input_field_value['wcj_type'] = 'file';
                 //$orig_file_name = $input_field_value['name'];
                 //wc_add_order_item_meta( $item_id, '_wcj_product_input_fields_' . $this->scope . '_' . $i . '_orig_file_name', $orig_file_name );
                 //$input_field_value = '<a href="' . add_query_arg( 'wcj_download_file', $name ) . '">' . $orig_file_name . '</a>';
                 //$input_field_value = $orig_file_name;
             }
             wc_add_order_item_meta($item_id, '_wcj_product_input_fields_' . $this->scope . '_' . $i, $input_field_value);
         }
     }
 }
开发者ID:yarwalker,项目名称:ecobyt,代码行数:37,代码来源:class-wcj-product-input-fields-abstract.php

示例10: create_vendor_order

 /**
  * Create a new vendor order programmatically
  *
  * Returns a new vendor_order object on success which can then be used to add additional data.
  *
  * @since 
  * @param array $args
  * @return WC_Order_Vendor|WP_Error
  */
 public static function create_vendor_order($args = array())
 {
     $default_args = array('vendor_id' => null, 'order_id' => 0, 'vendor_order_id' => 0, 'line_items' => array(), 'date' => current_time('mysql', 0));
     $args = wp_parse_args($args, $default_args);
     $vendor_order_data = array();
     if ($args['vendor_order_id'] > 0) {
         $updating = true;
         $vendor_order_data['ID'] = $args['vendor_order_id'];
     } else {
         $updating = false;
         $vendor_order_data['post_type'] = 'shop_order_vendor';
         $vendor_order_data['post_status'] = 'wc-completed';
         $vendor_order_data['ping_status'] = 'closed';
         $vendor_order_data['post_author'] = get_current_user_id();
         $vendor_order_data['post_password'] = uniqid('vendor_');
         // password = 20 char max! (uniqid = 13)
         $vendor_order_data['post_parent'] = absint($args['order_id']);
         $vendor_order_data['post_title'] = sprintf(__('Vendor Order &ndash; %s', 'woocommerce'), strftime(_x('%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce')));
         $vendor_order_data['post_date'] = $args['date'];
     }
     if ($updating) {
         $vendor_order_id = wp_update_post($vendor_order_data);
     } else {
         $vendor_order_id = wp_insert_post(apply_filters('woocommerce_new_vendor_order_data', $vendor_order_data), true);
     }
     if (is_wp_error($vendor_order_id)) {
         return $vendor_order_id;
     }
     if (!$updating) {
         // Get vendor order object
         $vendor_order = wc_get_order($vendor_order_id);
         $order = wc_get_order($args['order_id']);
         // Order currency is the same used for the parent order
         update_post_meta($vendor_order_id, '_order_currency', $order->get_order_currency());
         if (sizeof($args['line_items']) > 0) {
             $order_items = $order->get_items(array('line_item', 'fee', 'shipping'));
             foreach ($args['line_items'] as $vendor_order_item_id => $vendor_order_item) {
                 if (isset($order_items[$vendor_order_item_id])) {
                     if (empty($vendor_order_item['qty']) && empty($vendor_order_item['total']) && empty($vendor_order_item['tax'])) {
                         continue;
                     }
                     // Prevents errors when the order has no taxes
                     if (!isset($vendor_order_item['tax'])) {
                         $vendor_order_item['tax'] = array();
                     }
                     switch ($order_items[$vendor_order_item_id]['type']) {
                         case 'line_item':
                             $line_item_args = array('totals' => array('subtotal' => $vendor_order_item['subtotal'], 'total' => $vendor_order_item['total'], 'subtotal_tax' => $vendor_order_item['subtotal_tax'], 'tax' => $vendor_order_item['tax'], 'tax_data' => $vendor_order_item['tax_data']));
                             $new_item_id = $vendor_order->add_product($order->get_product_from_item($order_items[$vendor_order_item_id]), isset($vendor_order_item['qty']) ? $vendor_order_item['qty'] : 0, $line_item_args);
                             wc_add_order_item_meta($new_item_id, '_vendor_order_item_id', $vendor_order_item_id);
                             wc_add_order_item_meta($new_item_id, '_vendor_commission', $vendor_order_item['commission']);
                             break;
                         case 'shipping':
                             $shipping = new stdClass();
                             $shipping->label = $order_items[$vendor_order_item_id]['name'];
                             $shipping->id = $order_items[$vendor_order_item_id]['method_id'];
                             $shipping->cost = $vendor_order_item['total'];
                             $shipping->taxes = $vendor_order_item['tax'];
                             $new_item_id = $vendor_order->add_shipping($shipping);
                             wc_add_order_item_meta($new_item_id, '_vendor_order_item_id', $vendor_order_item_id);
                             break;
                         case 'fee':
                             $fee = new stdClass();
                             $fee->name = $order_items[$vendor_order_item_id]['name'];
                             $fee->tax_class = $order_items[$vendor_order_item_id]['tax_class'];
                             $fee->taxable = $fee->tax_class !== '0';
                             $fee->amount = $vendor_order_item['total'];
                             $fee->tax = array_sum($vendor_order_item['tax']);
                             $fee->tax_data = $vendor_order_item['tax'];
                             $new_item_id = $vendor_order->add_fee($fee);
                             wc_add_order_item_meta($new_item_id, '_vendor_order_item_id', $vendor_order_item_id);
                             break;
                     }
                 }
             }
             $vendor_order->update_taxes();
         }
         $vendor_order->calculate_totals(false);
         do_action('woocommerce_vendor_order_created', $vendor_order_id, $args);
     }
     // Clear transients
     wc_delete_shop_order_transients($args['order_id']);
     return new WC_Order_Vendor($vendor_order_id);
 }
开发者ID:stodorovic,项目名称:wcvendors,代码行数:93,代码来源:class-vendors.php

示例11: save_customized_item_meta

 function save_customized_item_meta($item_id, $values, $cart_item_key)
 {
     $variation_id = $values["variation_id"];
     if (isset($values["output"])) {
         if (isset($_SESSION["wpc_generated_data"][$variation_id][$cart_item_key])) {
             wc_add_order_item_meta($item_id, 'wpc_data', $_SESSION["wpc_generated_data"][$variation_id][$cart_item_key]);
             unset($_SESSION["wpc_generated_data"][$variation_id][$cart_item_key]);
         }
         if (empty($_SESSION["wpc_generated_data"][$variation_id])) {
             unset($_SESSION["wpc_generated_data"][$variation_id]);
         }
     } else {
         if (isset($_SESSION["wpc-uploaded-designs"][$cart_item_key])) {
             wc_add_order_item_meta($item_id, 'wpc_data_upl', $_SESSION["wpc-uploaded-designs"][$cart_item_key]);
             unset($_SESSION["wpc-uploaded-designs"][$cart_item_key]);
         }
     }
     if (isset($_SESSION["wpc_design_pricing_options"][$cart_item_key]) && !empty($_SESSION["wpc_design_pricing_options"][$cart_item_key])) {
         $wpc_design_pricing_options_data = $this->get_design_pricing_options_data($_SESSION["wpc_design_pricing_options"][$cart_item_key]);
         wc_add_order_item_meta($item_id, '_wpc_design_pricing_options', $wpc_design_pricing_options_data);
         unset($_SESSION["wpc_design_pricing_options"][$cart_item_key]);
     }
 }
开发者ID:Zovio,项目名称:woocommerce-products-designer,代码行数:23,代码来源:class-wpd-design.php

示例12: foreach

// Do the same kind of update for order_taxes - move to lines
// Reverse with UPDATE `wpwc_postmeta` SET meta_key = '_order_taxes' WHERE meta_key = '_order_taxes_old'
$order_tax_rows = $wpdb->get_results("\n\tSELECT * FROM {$wpdb->postmeta}\n\tWHERE meta_key = '_order_taxes'\n");
foreach ($order_tax_rows as $order_tax_row) {
    $order_taxes = (array) maybe_unserialize($order_tax_row->meta_value);
    if ($order_taxes) {
        foreach ($order_taxes as $order_tax) {
            if (!isset($order_tax['label']) || !isset($order_tax['cart_tax']) || !isset($order_tax['shipping_tax'])) {
                continue;
            }
            $item_id = wc_add_order_item($order_tax_row->post_id, array('order_item_name' => $order_tax['label'], 'order_item_type' => 'tax'));
            // Add line item meta
            if ($item_id) {
                wc_add_order_item_meta($item_id, 'compound', absint(isset($order_tax['compound']) ? $order_tax['compound'] : 0));
                wc_add_order_item_meta($item_id, 'tax_amount', wc_clean($order_tax['cart_tax']));
                wc_add_order_item_meta($item_id, 'shipping_tax_amount', wc_clean($order_tax['shipping_tax']));
            }
            // Delete from DB (rename)
            $wpdb->query($wpdb->prepare("\n\t\t\t\tUPDATE {$wpdb->postmeta}\n\t\t\t\tSET meta_key = '_order_taxes_old'\n\t\t\t\tWHERE meta_key = '_order_taxes'\n\t\t\t\tAND post_id = %d\n\t\t\t", $order_tax_row->post_id));
            unset($tax_amount);
        }
    }
}
// Grab the pre 2.0 Image options and use to populate the new image options settings,
// cleaning up afterwards like nice people do
foreach (array('catalog', 'single', 'thumbnail') as $value) {
    $old_settings = array_filter(array('width' => get_option('woocommerce_' . $value . '_image_width'), 'height' => get_option('woocommerce_' . $value . '_image_height'), 'crop' => get_option('woocommerce_' . $value . '_image_crop')));
    if (!empty($old_settings) && update_option('shop_' . $value . '_image_size', $old_settings)) {
        delete_option('woocommerce_' . $value . '_image_width');
        delete_option('woocommerce_' . $value . '_image_height');
        delete_option('woocommerce_' . $value . '_image_crop');
开发者ID:prosenjit-itobuz,项目名称:nutraperfect,代码行数:31,代码来源:woocommerce-update-2.0.php

示例13: dokan_create_sub_order_shipping

/**
 * Create shipping for a sub-order if neccessary
 *
 * @param WC_Order $parent_order
 * @param int $order_id
 * @param array $product_ids
 * @return type
 */
function dokan_create_sub_order_shipping($parent_order, $order_id, $seller_products)
{
    // take only the first shipping method
    $shipping_methods = $parent_order->get_shipping_methods();
    $shipping_method = is_array($shipping_methods) ? reset($shipping_methods) : array();
    // bail out if no shipping methods found
    if (!$shipping_method) {
        return;
    }
    $shipping_products = array();
    $packages = array();
    // emulate shopping cart for calculating the shipping method
    foreach ($seller_products as $product_item) {
        $product = get_product($product_item['product_id']);
        if ($product->needs_shipping()) {
            $shipping_products[] = array('product_id' => $product_item['product_id'], 'variation_id' => $product_item['variation_id'], 'variation' => '', 'quantity' => $product_item['qty'], 'data' => $product, 'line_total' => $product_item['line_total'], 'line_tax' => $product_item['line_tax'], 'line_subtotal' => $product_item['line_subtotal'], 'line_subtotal_tax' => $product_item['line_subtotal_tax']);
        }
    }
    if ($shipping_products) {
        $package = array('contents' => $shipping_products, 'contents_cost' => array_sum(wp_list_pluck($shipping_products, 'line_total')), 'applied_coupons' => array(), 'destination' => array('country' => $parent_order->shipping_country, 'state' => $parent_order->shipping_state, 'postcode' => $parent_order->shipping_postcode, 'city' => $parent_order->shipping_city, 'address' => $parent_order->shipping_address_1, 'address_2' => $parent_order->shipping_address_2));
        $wc_shipping = WC_Shipping::instance();
        $pack = $wc_shipping->calculate_shipping_for_package($package);
        if (array_key_exists($shipping_method['method_id'], $pack['rates'])) {
            $method = $pack['rates'][$shipping_method['method_id']];
            $cost = wc_format_decimal($method->cost);
            $item_id = wc_add_order_item($order_id, array('order_item_name' => $method->label, 'order_item_type' => 'shipping'));
            if ($item_id) {
                wc_add_order_item_meta($item_id, 'method_id', $method->id);
                wc_add_order_item_meta($item_id, 'cost', $cost);
            }
            return $cost;
        }
    }
    return 0;
}
开发者ID:amirkchetu,项目名称:dokan,代码行数:43,代码来源:wc-functions.php

示例14: migrate_switch_meta

 /**
  * The '_switched_subscription_key' and '_switched_subscription_new_order' post meta values are no longer used to relate orders
  * and switched subscriptions, instead, we need to set a '_subscription_switch' value on the switch order and depreacted the old
  * meta keys by prefixing them with '_wcs_migrated'.
  *
  * Subscriptions also sets a '_switched_subscription_item_id' value on the new line item of for the switched item and a item meta
  * value of '_switched_subscription_new_item_id' on the old line item on the subscription, but the old switching process didn't
  * change order items, it just created a new order with the new item, so we won't bother setting this as it is purely for record
  * keeping.
  *
  * @param WC_Subscription $new_subscription A subscription object
  * @param WC_Order $switch_order The original order used to purchase the subscription
  * @param int $subscription_item_id The order item ID of the item added to the subscription by self::add_product()
  * @return null
  * @since 2.0
  */
 private static function migrate_switch_meta($new_subscription, $switch_order, $subscription_item_id)
 {
     global $wpdb;
     // If the order doesn't contain a switch, we don't need to do anything
     if ('' == get_post_meta($switch_order->id, '_switched_subscription_key', true)) {
         return;
     }
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET `meta_key` = concat( '_wcs_migrated', `meta_key` )\n\t\t\tWHERE `post_id` = %d AND `meta_key` IN ('_switched_subscription_first_payment_timestamp','_switched_subscription_key')", $switch_order->id));
     // Select the orders which had the items which were switched by this order
     $previous_order_id = get_posts(array('post_type' => 'shop_order', 'post_status' => 'any', 'fields' => 'ids', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_switched_subscription_new_order', 'value' => $switch_order->id))));
     if (!empty($previous_order_id)) {
         $previous_order_id = $previous_order_id[0];
         $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET `meta_key` = concat( '_wcs_migrated', `meta_key` )\n\t\t\t\tWHERE `post_id` = %d AND `meta_key` = '_switched_subscription_new_order'", $previous_order_id));
         // Because self::get_subscriptions() orders by order ID, it's safe to use wcs_get_subscriptions_for_order() here because the subscription in the new format will have been created for the original order (because its ID will be < the switch order's ID)
         $old_subscriptions = wcs_get_subscriptions_for_order($previous_order_id);
         $old_subscription = array_shift($old_subscriptions);
         // there can be only one
         if (wcs_is_subscription($old_subscription)) {
             // Link the old subscription's ID to the switch order using the new switch meta key
             update_post_meta($switch_order->id, '_subscription_switch', $old_subscription->id);
             // Now store the new/old item IDs for record keeping
             foreach ($old_subscription->get_items() as $item_id => $item) {
                 wc_add_order_item_meta($item_id, '_switched_subscription_new_item_id', $subscription_item_id, true);
                 wc_add_order_item_meta($subscription_item_id, '_switched_subscription_item_id', $item_id, true);
             }
             WCS_Upgrade_Logger::add(sprintf('For subscription %d: migrated switch data for subscription %d purchased in order %d', $new_subscription->id, $old_subscription->id, $previous_order_id));
         }
     }
 }
开发者ID:slavic18,项目名称:cats,代码行数:45,代码来源:class-wcs-upgrade-2-0.php

示例15: add_fee

 /**
  * Add a fee to the order
  *
  * @param object $fee
  * @return int|bool Item ID or false
  */
 public function add_fee($fee)
 {
     $item_id = wc_add_order_item($this->id, array('order_item_name' => $fee->name, 'order_item_type' => 'fee'));
     if (!$item_id) {
         return false;
     }
     if ($fee->taxable) {
         wc_add_order_item_meta($item_id, '_tax_class', $fee->tax_class);
     } else {
         wc_add_order_item_meta($item_id, '_tax_class', '0');
     }
     wc_add_order_item_meta($item_id, '_line_total', wc_format_decimal($fee->amount));
     wc_add_order_item_meta($item_id, '_line_tax', wc_format_decimal($fee->tax));
     // Save tax data - Since 2.2
     $tax_data = array_map('wc_format_decimal', $fee->tax_data);
     wc_add_order_item_meta($item_id, '_line_tax_data', array('total' => $tax_data));
     do_action('woocommerce_order_add_fee', $this->id, $item_id, $fee);
     return $item_id;
 }
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:25,代码来源:abstract-wc-order.php


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