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

PHP wc_add_order_item_meta函数代码示例

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

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: wdm_add_values_to_order_item_meta

function wdm_add_values_to_order_item_meta($item_id, $values, $key )
{
    global $woocommerce,$wpdb;
    
    if ( isset( $values['cierre'] ) && !empty( $values['cierre']) )
        wc_add_order_item_meta( $item_id ,'cierre', $values['cierre'] ); 

    if ( isset( $values['rango'] ) && !empty( $values['rango']) )
        wc_add_order_item_meta( $item_id ,'rango', $values['rango'] );

    if ( isset( $values['id_modelo'] ) && !empty( $values['id_modelo']) )
        wc_add_order_item_meta( $item_id ,'id_modelo', $values['id_modelo'] );

    if ( isset( $values['modelo'] ) && !empty( $values['modelo']) )
        wc_add_order_item_meta( $item_id ,'modelo', $values['modelo'] );

    if ( isset( $values['configurations'] ) && !empty( $values['configurations']) )
        wc_add_order_item_meta( $item_id ,'configurations', $values['configurations'] );
  }
开发者ID:JDarkGreen,项目名称:wpmaletek,代码行数:19,代码来源:functions.php


示例17: dokan_create_seller_order

/**
 * Creates a sub order
 *
 * @param int $parent_order
 * @param int $seller_id
 * @param array $seller_products
 */
function dokan_create_seller_order($parent_order, $seller_id, $seller_products)
{
    $order_data = apply_filters('woocommerce_new_order_data', array('post_type' => 'shop_order', 'post_title' => sprintf(__('Order &ndash; %s', 'woocommerce'), strftime(_x('%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce'))), 'post_status' => 'wc-pending', 'ping_status' => 'closed', 'post_excerpt' => isset($posted['order_comments']) ? $posted['order_comments'] : '', 'post_author' => $seller_id, 'post_parent' => $parent_order->id, 'post_password' => uniqid('order_')));
    $order_id = wp_insert_post($order_data);
    if ($order_id && !is_wp_error($order_id)) {
        $order_total = $order_tax = 0;
        $product_ids = array();
        do_action('woocommerce_new_order', $order_id);
        // now insert line items
        foreach ($seller_products as $item) {
            $order_total += (double) $item['line_total'];
            $order_tax += (double) $item['line_tax'];
            $product_ids[] = $item['product_id'];
            $item_id = wc_add_order_item($order_id, array('order_item_name' => $item['name'], 'order_item_type' => 'line_item'));
            if ($item_id) {
                wc_add_order_item_meta($item_id, '_qty', $item['qty']);
                wc_add_order_item_meta($item_id, '_tax_class', $item['tax_class']);
                wc_add_order_item_meta($item_id, '_product_id', $item['product_id']);
                wc_add_order_item_meta($item_id, '_line_subtotal', $item['line_subtotal']);
                wc_add_order_item_meta($item_id, '_line_total', $item['line_total']);
                wc_add_order_item_meta($item_id, '_line_tax', $item['line_tax']);
                wc_add_order_item_meta($item_id, '_line_subtotal_tax', $item['line_subtotal_tax']);
            }
        }
        // foreach
        $bill_ship = array('_billing_country', '_billing_first_name', '_billing_last_name', '_billing_company', '_billing_address_1', '_billing_address_2', '_billing_city', '_billing_state', '_billing_postcode', '_billing_email', '_billing_phone', '_shipping_country', '_shipping_first_name', '_shipping_last_name', '_shipping_company', '_shipping_address_1', '_shipping_address_2', '_shipping_city', '_shipping_state', '_shipping_postcode');
        // save billing and shipping address
        foreach ($bill_ship as $val) {
            $order_key = ltrim($val, '_');
            update_post_meta($order_id, $val, $parent_order->{$order_key});
        }
        // calculate the total
        $order_in_total = $order_total + $shipping_cost + $order_tax;
        // set order meta
        update_post_meta($order_id, '_payment_method', $parent_order->payment_method);
        update_post_meta($order_id, '_payment_method_title', $parent_order->payment_method_title);
        update_post_meta($order_id, '_order_shipping', woocommerce_format_decimal($shipping_cost));
        update_post_meta($order_id, '_cart_discount', '0');
        update_post_meta($order_id, '_order_tax', woocommerce_format_decimal($order_tax));
        update_post_meta($order_id, '_order_shipping_tax', '0');
        update_post_meta($order_id, '_order_total', woocommerce_format_decimal($order_in_total));
        update_post_meta($order_id, '_order_key', apply_filters('woocommerce_generate_order_key', uniqid('order_')));
        update_post_meta($order_id, '_customer_user', $parent_order->customer_user);
        update_post_meta($order_id, '_order_currency', get_post_meta($parent_order->id, '_order_currency', true));
        update_post_meta($order_id, '_prices_include_tax', $parent_order->prices_include_tax);
        update_post_meta($order_id, '_customer_ip_address', get_post_meta($parent_order->id, '_customer_ip_address', true));
        update_post_meta($order_id, '_customer_user_agent', get_post_meta($parent_order->id, '_customer_user_agent', true));
        do_action('dokan_checkout_update_order_meta', $order_id, $seller_id);
    }
    // if order
}
开发者ID:nuwe1,项目名称:dokan-lite,代码行数:58,代码来源:wc-functions.php


示例18: wcmp_checkout_order_processed

 /**
  * WCMp Calculate shipping for order
  *
  * @support flat rate per item 
  * @param int $order_id
  * @param object $order_posted
  * @return void
  */
 function wcmp_checkout_order_processed($order_id, $order_posted)
 {
     global $wpdb, $WCMp;
     $order = new WC_Order($order_id);
     if ($order->has_shipping_method('flat_rate')) {
         $woocommerce_flat_rate_settings = get_option('woocommerce_flat_rate_settings');
         $line_items = $order->get_items('line_item');
         if ($woocommerce_flat_rate_settings['enabled'] == 'yes') {
             if (version_compare(WC_VERSION, '2.5.0', '>=')) {
                 if ($woocommerce_flat_rate_settings['type'] == 'class') {
                     if (!empty($line_items)) {
                         foreach ($line_items as $item_id => $item) {
                             $wc_flat_rate = new WC_Shipping_Flat_Rate();
                             $product = $order->get_product_from_item($item);
                             $shipping_class = $product->get_shipping_class_id();
                             $class_cost_string = $shipping_class ? $wc_flat_rate->get_option('class_cost_' . $shipping_class, '') : $wc_flat_rate->get_option('no_class_cost', '');
                             $cost_item_id = $this->evaluate_flat_shipping_cost($class_cost_string, array('qty' => $item['qty'], 'cost' => $order->get_line_subtotal($item)));
                             $flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'flat_shipping_per_item', true);
                             if (!$flat_shipping_per_item_val) {
                                 wc_add_order_item_meta($item_id, 'flat_shipping_per_item', round($cost_item_id, 2));
                             }
                         }
                     }
                 }
             } else {
                 if (version_compare(WC_VERSION, '2.4.0', '>')) {
                     if ($woocommerce_flat_rate_settings['type'] == 'class') {
                         if (!empty($line_items)) {
                             foreach ($line_items as $item_id => $item) {
                                 $wc_flat_rate = new WC_Shipping_Flat_Rate();
                                 $product = $order->get_product_from_item($item);
                                 $shipping_class = $product->get_shipping_class();
                                 $class_cost_string = $shipping_class ? $wc_flat_rate->get_option('class_cost_' . $shipping_class, '') : $wc_flat_rate->get_option('no_class_cost', '');
                                 $cost_item_id = $this->evaluate_flat_shipping_cost($class_cost_string, array('qty' => $item['qty'], 'cost' => $order->get_line_subtotal($item)));
                                 $flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'flat_shipping_per_item', true);
                                 if (!$flat_shipping_per_item_val) {
                                     wc_add_order_item_meta($item_id, 'flat_shipping_per_item', round($cost_item_id, 2));
                                 }
                             }
                         }
                     }
                 } else {
                     $woocommerce_flat_rate_settings_cost = $woocommerce_flat_rate_settings['cost'];
                     $woocommerce_flat_rate_settings_fee = $woocommerce_flat_rate_settings['fee'];
                     $woocommerce_flat_rates = get_option('woocommerce_flat_rates');
                     if ($woocommerce_flat_rate_settings['type'] == 'item') {
                         if (!empty($line_items)) {
                             foreach ($line_items as $item_id => $item) {
                                 $fee = $cost = 0;
                                 $_product = $order->get_product_from_item($item);
                                 $shipping_class = $_product->get_shipping_class();
                                 if (isset($woocommerce_flat_rates[$shipping_class])) {
                                     $cost = $woocommerce_flat_rates[$shipping_class]['cost'];
                                     $fee = $this->get_fee($woocommerce_flat_rates[$shipping_class]['fee'], $_product->get_price());
                                 } elseif ($woocommerce_flat_rate_settings_cost !== '') {
                                     $cost = $woocommerce_flat_rate_settings_cost;
                                     $fee = $this->get_fee($woocommerce_flat_rate_settings_fee, $_product->get_price());
                                     $matched = true;
                                 }
                                 $cost_item_id = ($cost + $fee) * $item['qty'];
                                 $flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'flat_shipping_per_item', true);
                                 if (!$flat_shipping_per_item_val) {
                                     wc_add_order_item_meta($item_id, 'flat_shipping_per_item', round($cost_item_id, 2));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($order->has_shipping_method('international_delivery')) {
         $woocommerce_international_delivery_settings = get_option('woocommerce_international_delivery_settings');
         $line_items = $order->get_items('line_item');
         if ($woocommerce_international_delivery_settings['enabled'] == 'yes') {
             if (version_compare(WC_VERSION, '2.5.0', '>=')) {
                 if ($woocommerce_international_delivery_settings['type'] == 'class') {
                     if (!empty($line_items)) {
                         $item_id = false;
                         foreach ($line_items as $item_id => $item) {
                             $wc_international_flat_rate = new WC_Shipping_International_Delivery();
                             $product = $order->get_product_from_item($item);
                             $shipping_class = $product->get_shipping_class_id();
                             $class_cost_string = $shipping_class ? $wc_international_flat_rate->get_option('class_cost_' . $shipping_class, '') : $wc_international_flat_rate->get_option('no_class_cost', '');
                             $cost_item_id = $this->evaluate_flat_shipping_cost($class_cost_string, array('qty' => $item['qty'], 'cost' => $order->get_line_subtotal($item)));
                             $international_flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'international_flat_shipping_per_item', true);
                             if (!$international_flat_shipping_per_item_val) {
                                 wc_add_order_item_meta($item_id, 'international_flat_shipping_per_item', $cost_item_id);
                             }
                         }
                     }
                 }
//.........这里部分代码省略.........
开发者ID:qhuit,项目名称:UrbanPekor,代码行数:101,代码来源:class-wcmp-frontend.php


示例19: add_order_item_meta


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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