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

PHP wc_update_order_item_meta函数代码示例

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

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



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

示例1: save

 /**
  * Save properties specific to this order item.
  * @return int Item ID
  */
 public function save()
 {
     parent::save();
     if ($this->get_id()) {
         wc_update_order_item_meta($this->get_id(), '_tax_class', $this->get_tax_class());
         wc_update_order_item_meta($this->get_id(), '_tax_status', $this->get_tax_status());
         wc_update_order_item_meta($this->get_id(), '_line_total', $this->get_total());
         wc_update_order_item_meta($this->get_id(), '_line_tax', $this->get_total_tax());
         wc_update_order_item_meta($this->get_id(), '_line_tax_data', $this->get_taxes());
     }
     return $this->get_id();
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:16,代码来源:class-wc-order-item-fee.php


示例2: save_item_data

 /**
  * Saves an item's data to the database / item meta.
  * Ran after both create and update, so $item->get_id() will be set.
  *
  * @since 2.7.0
  * @param WC_Order_Item $item
  */
 public function save_item_data(&$item)
 {
     wc_update_order_item_meta($item->get_id(), 'method_id', $item->get_method_id('edit'));
     wc_update_order_item_meta($item->get_id(), 'cost', $item->get_total('edit'));
     wc_update_order_item_meta($item->get_id(), 'total_tax', $item->get_total_tax('edit'));
     wc_update_order_item_meta($item->get_id(), 'taxes', $item->get_taxes('edit'));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:14,代码来源:class-wc-order-item-shipping-data-store.php


示例3: add_downloadlinks

 /**
  * @param $links
  * @param $item_id
  */
 function add_downloadlinks($links, $item_id)
 {
     if (is_array($links)) {
         // add generated downloadlinks to item
         wc_update_order_item_meta($item_id, '_bx_downloadlinks', $links);
     }
 }
开发者ID:BooXtream,项目名称:BooXtream-WooCommerce,代码行数:11,代码来源:class-wc-booxtream-request.php


示例4: save_item_data

 /**
  * Saves an item's data to the database / item meta.
  * Ran after both create and update, so $item->get_id() will be set.
  *
  * @since 2.7.0
  * @param WC_Order_Item $item
  */
 public function save_item_data(&$item)
 {
     wc_update_order_item_meta($item->get_id(), '_tax_class', $item->get_tax_class('edit'));
     wc_update_order_item_meta($item->get_id(), '_tax_status', $item->get_tax_status('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_total', $item->get_total('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_tax', $item->get_total_tax('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_tax_data', $item->get_taxes('edit'));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:15,代码来源:class-wc-order-item-fee-data-store.php


示例5: save_item_data

 /**
  * Saves an item's data to the database / item meta.
  * Ran after both create and update, so $item->get_id() will be set.
  *
  * @since 2.7.0
  * @param WC_Order_Item $item
  */
 public function save_item_data(&$item)
 {
     wc_update_order_item_meta($item->get_id(), 'rate_id', $item->get_rate_id('edit'));
     wc_update_order_item_meta($item->get_id(), 'label', $item->get_label('edit'));
     wc_update_order_item_meta($item->get_id(), 'compound', $item->get_compound('edit'));
     wc_update_order_item_meta($item->get_id(), 'tax_amount', $item->get_tax_total('edit'));
     wc_update_order_item_meta($item->get_id(), 'shipping_tax_amount', $item->get_shipping_tax_total('edit'));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:15,代码来源:class-wc-order-item-tax-data-store.php


示例6: save

 /**
  * Save properties specific to this order item.
  * @return int Item ID
  */
 public function save()
 {
     parent::save();
     if ($this->get_id()) {
         wc_update_order_item_meta($this->get_id(), 'discount_amount', $this->get_discount());
         wc_update_order_item_meta($this->get_id(), 'discount_amount_tax', $this->get_discount_tax());
     }
     return $this->get_id();
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:13,代码来源:class-wc-order-item-coupon.php


示例7: save

 /**
  * Save properties specific to this order item.
  * @return int Item ID
  */
 public function save()
 {
     parent::save();
     if ($this->get_id()) {
         wc_update_order_item_meta($this->get_id(), 'method_id', $this->get_method_id());
         wc_update_order_item_meta($this->get_id(), 'cost', $this->get_total());
         wc_update_order_item_meta($this->get_id(), 'total_tax', $this->get_total_tax());
         wc_update_order_item_meta($this->get_id(), 'taxes', $this->get_taxes());
     }
     return $this->get_id();
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:15,代码来源:class-wc-order-item-shipping.php


示例8: save_item_data

 /**
  * Saves an item's data to the database / item meta.
  * Ran after both create and update, so $item->get_id() will be set.
  *
  * @since 2.7.0
  * @param WC_Order_Item $item
  */
 public function save_item_data(&$item)
 {
     wc_update_order_item_meta($item->get_id(), '_product_id', $item->get_product_id('edit'));
     wc_update_order_item_meta($item->get_id(), '_variation_id', $item->get_variation_id('edit'));
     wc_update_order_item_meta($item->get_id(), '_qty', $item->get_quantity('edit'));
     wc_update_order_item_meta($item->get_id(), '_tax_class', $item->get_tax_class('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_subtotal', $item->get_subtotal('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_subtotal_tax', $item->get_subtotal_tax('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_total', $item->get_total('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_tax', $item->get_total_tax('edit'));
     wc_update_order_item_meta($item->get_id(), '_line_tax_data', $item->get_taxes('edit'));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:19,代码来源:class-wc-order-item-product-store.php


示例9: save

 /**
  * Save properties specific to this order item.
  * @return int Item ID
  */
 public function save()
 {
     parent::save();
     if ($this->get_id()) {
         wc_update_order_item_meta($this->get_id(), 'rate_id', $this->get_rate_id());
         wc_update_order_item_meta($this->get_id(), 'label', $this->get_label());
         wc_update_order_item_meta($this->get_id(), 'compound', $this->get_compound());
         wc_update_order_item_meta($this->get_id(), 'tax_amount', $this->get_tax_total());
         wc_update_order_item_meta($this->get_id(), 'shipping_tax_amount', $this->get_shipping_tax_total());
     }
     return $this->get_id();
 }
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:16,代码来源:class-wc-order-item-tax.php


示例10: update_post_metadata

 /**
  * Apply shipping tax, fix order_tax
  * -
  * - filter has already passed $this->data['shipping_tax'] test
  * @param $null
  * @param $order_id
  * @param $meta_key
  * @param $meta_value
  * @param $prev_value
  * @return null
  */
 public function update_post_metadata($null, $order_id, $meta_key, $meta_value, $prev_value)
 {
     // we want last update to _order_shipping after $order->calculate_taxes()
     // set flag true on first pass
     if ($meta_key == '_order_shipping_tax') {
         $this->flag = true;
     }
     if ($meta_key != '_order_shipping' || !$this->flag) {
         return $null;
     }
     // update order meta
     $shipping_tax_total = isset($this->data['shipping_tax']) ? $this->data['shipping_tax'] : 0;
     update_post_meta($order_id, '_order_shipping_tax', wc_format_decimal($shipping_tax_total));
     // check each shipping tax line
     // if order item meta already exists, update the shipping_tax_amount
     // if order item meta not present, add the new tax
     // ... nasty :(
     // first get an assoc array of $rate_id => $item_id
     $tax_items = array();
     $order_tax = 0;
     $order = wc_get_order($order_id);
     foreach ($order->get_tax_totals() as $code => $tax) {
         $tax_items[$tax->rate_id] = $tax->id;
         $order_tax += $tax->amount;
     }
     // fix total_tax calc
     update_post_meta($order_id, '_order_tax', $order_tax);
     // now loop through the shipping_lines
     if (isset($shipping['shipping_lines'])) {
         foreach ($this->data['shipping_lines'] as $shipping) {
             if (isset($shipping['tax'])) {
                 foreach ($shipping['tax'] as $rate_id => $tax) {
                     if (isset($tax['total'])) {
                         if (array_key_exists($rate_id, $tax_items)) {
                             wc_update_order_item_meta($tax_items[$rate_id], 'shipping_tax_amount', wc_format_decimal($tax['total']));
                         } else {
                             $order->add_tax($rate_id, 0, $tax['total']);
                         }
                     }
                 }
             }
         }
     }
     return $null;
 }
开发者ID:rpidanny,项目名称:WooCommerce-POS,代码行数:56,代码来源:class-wc-pos-orders.php


示例11: save

 /**
  * Save properties specific to this order item.
  * @return int Item ID
  */
 public function save()
 {
     parent::save();
     if ($this->get_id()) {
         wc_update_order_item_meta($this->get_id(), '_product_id', $this->get_product_id());
         wc_update_order_item_meta($this->get_id(), '_variation_id', $this->get_variation_id());
         wc_update_order_item_meta($this->get_id(), '_qty', $this->get_quantity());
         wc_update_order_item_meta($this->get_id(), '_tax_class', $this->get_tax_class());
         wc_update_order_item_meta($this->get_id(), '_line_subtotal', $this->get_subtotal());
         wc_update_order_item_meta($this->get_id(), '_line_subtotal_tax', $this->get_subtotal_tax());
         wc_update_order_item_meta($this->get_id(), '_line_total', $this->get_total());
         wc_update_order_item_meta($this->get_id(), '_line_tax', $this->get_total_tax());
         wc_update_order_item_meta($this->get_id(), '_line_tax_data', $this->get_taxes());
     }
     return $this->get_id();
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:20,代码来源:class-wc-order-item-product.php


示例12: save_item_data

 /**
  * Saves an item's data to the database / item meta.
  * Ran after both create and update, so $item->get_id() will be set.
  *
  * @since 2.7.0
  * @param WC_Order_Item $item
  */
 public function save_item_data(&$item)
 {
     wc_update_order_item_meta($item->get_id(), 'discount_amount', $item->get_discount('edit'));
     wc_update_order_item_meta($item->get_id(), 'discount_amount_tax', $item->get_discount_tax('edit'));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:12,代码来源:class-wc-order-item-coupon-data-store.php


示例13: update_post_data

 /**
  * Perform data update
  *
  * @return JSON object with information about number of posts remaining, current update status
  */
 public static function update_post_data()
 {
     global $wpdb;
     // Number of posts to process at once
     $posts_per_page = 10;
     // Index of last processed post
     $last_post = $_POST['last_post'];
     // Page counters
     $total_pages = $last_post == 0 ? 0 : $_POST['total_pages'];
     $current_page = $last_post == 0 ? 1 : $_POST['current_page'];
     // On first run, determine $total_count/$total_pages
     if ($last_post == 0) {
         $total_count = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type = 'wootax_order'");
         if ($total_count == 0) {
             update_option('wootax_version', WT_VERSION);
             self::dismiss_update_message();
             die(json_encode(array('status' => 'done', 'message' => 'No more posts to update. Redirecting...', 'redirect' => get_admin_url('plugins.php'))));
         }
         $total_pages = ceil($total_count / $posts_per_page);
     }
     // Select posts from index $last_post to $posts_per_page for processing
     $posts = $wpdb->get_results("SELECT p.ID AS WTID, pm.meta_value AS WCID FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID WHERE p.post_type = 'wootax_order' AND pm.meta_key = '_wootax_wc_order_id' ORDER BY p.ID ASC LIMIT {$last_post}, {$posts_per_page}");
     if (count($posts) == 0) {
         update_option('wootax_version', WT_VERSION);
         self::dismiss_update_message();
         self::remove_order_posts();
         die(json_encode(array('status' => 'done', 'message' => 'No more posts to update. Redirecting...', 'redirect' => get_admin_url('plugins.php'))));
     }
     // Loop through posts and update
     foreach ($posts as $post) {
         $wt_order_id = $post->WTID;
         $wc_order_id = $post->WCID;
         // Transfer meta that doesn't need to be changed
         $direct_meta_keys = array('tax_total', 'shipping_tax_total', 'captured', 'refunded', 'customer_id', 'tax_item_id', 'exemption_applied');
         foreach ($direct_meta_keys as $key) {
             update_post_meta($wc_order_id, '_wootax_' . $key, get_post_meta($wt_order_id, '_wootax_' . $key, true));
         }
         // WooTax order item meta and mapping array structure was changed drastically in 4.2; update accordingly
         $lookup_data = get_post_meta($wt_order_id, '_wootax_lookup_data', true);
         $cart_taxes = get_post_meta($wt_order_id, '_wootax_cart_taxes', true);
         $new_mapping_array = array();
         $new_tc_ids = array();
         $identifiers = array();
         if (is_array($lookup_data)) {
             $wc_order = new WC_Order($wc_order_id);
             $order_items = $wc_order->get_items();
             $order_fees = $wc_order->get_fees();
             foreach ($lookup_data as $location_key => $items) {
                 if (!isset($new_mapping_array[$location_key])) {
                     $new_mapping_array[$location_key] = array();
                 }
                 foreach ($items as $index => $item) {
                     if (!is_array($item)) {
                         continue;
                     }
                     $tax_amount = isset($cart_taxes[$location_key][$index]) ? $cart_taxes[$location_key][$index] : 0;
                     $item_ident = $item['ItemID'];
                     if ($item_ident == 99999) {
                         $shipping_item_id = -1;
                         // Shipping
                         if (version_compare(WOOCOMMERCE_VERSION, '2.2', '<')) {
                             $shipping_item_id = WT_SHIPPING_ITEM;
                             update_post_meta($wc_order_id, '_wootax_first_found', $location_key);
                             update_post_meta($wc_order_id, '_wootax_shipping_index', $index);
                         } else {
                             $shipping_methods = $wc_order->get_items('shipping');
                             foreach ($shipping_methods as $item_id => $method) {
                                 if ($shipping_item_id == -1) {
                                     $shipping_item_id = $item_id;
                                     wc_update_order_item_meta($item_id, '_wootax_index', $index);
                                     wc_update_order_item_meta($item_id, '_wootax_tax_amount', $tax_amount);
                                     wc_update_order_item_meta($item_id, '_wootax_location_id', $location_key);
                                 }
                             }
                         }
                         if ($shipping_item_id != -1) {
                             $new_mapping_array[$location_key][$item_ident] = $index;
                             $identifiers[WT_SHIPPING_ITEM] = $item_ident;
                         }
                     } else {
                         if (in_array(get_post_type($item_ident), array('product', 'product-variation'))) {
                             // Cart item
                             $cart_item_id = -1;
                             if (get_post_type($item_ident) == 'product') {
                                 $product_id = $item_ident;
                                 $variation_id = '';
                             } else {
                                 if (get_post_type($item_ident) == 'product-variation') {
                                     $variation_id = $item_ident;
                                     $product_id = wp_get_post_parent_id($variation_id);
                                 }
                             }
                             foreach ($order_items as $item_id => $item_data) {
                                 if (!empty($item_data['variation_id']) && $item_data['variation_id'] == $variation_id || $item_data['product_id'] == $product_id) {
                                     $cart_item_id = $item_id;
//.........这里部分代码省略.........
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:101,代码来源:class-wc-wootax-upgrade.php


示例14: sa_restore_smart_coupon_amount

 /**
  * Function to Restore Smart Coupon Amount back, when an order which was created using this coupon, is refunded or cancelled, 
  *
  * @param int $order_id
  */
 public function sa_restore_smart_coupon_amount($order_id = 0)
 {
     if (empty($order_id)) {
         return;
     }
     $order = $this->get_order($order_id);
     $coupons = $order->get_items('coupon');
     if (!empty($coupons)) {
         foreach ($coupons as $item_id => $item) {
             if (empty($item['name'])) {
                 continue;
             }
             $coupon = new WC_Coupon($item['name']);
             if (empty($coupon->discount_type) || $coupon->discount_type != 'smart_coupon') {
                 continue;
             }
             $update = false;
             $coupon_amount = $coupon->coupon_amount;
             $usage_count = $coupon->usage_count;
             if (!empty($item['discount_amount'])) {
                 $coupon_amount += $item['discount_amount'];
                 $usage_count -= 1;
                 if ($usage_count < 0) {
                     $usage_count = 0;
                 }
                 $update = true;
             }
             if ($update) {
                 update_post_meta($coupon->id, 'coupon_amount', $coupon_amount);
                 update_post_meta($coupon->id, 'usage_count', $usage_count);
                 wc_update_order_item_meta($item_id, 'discount_amount', 0);
             }
         }
     }
 }
开发者ID:NerdyDillinger,项目名称:ovrride,代码行数:40,代码来源:woocommerce-smart-coupons.php


示例15: ajax_add_order_item_meta

 /**
  * Triggered when adding an item in the backend.
  *
  * If deposits are forced, set all meta data.
  */
 public function ajax_add_order_item_meta($item_id, $item)
 {
     if (WC_Deposits_Product_Manager::deposits_forced($item['product_id'])) {
         $product = wc_get_product(absint($item['variation_id'] ? $item['variation_id'] : $item['product_id']));
         woocommerce_add_order_item_meta($item_id, '_is_deposit', 'yes');
         woocommerce_add_order_item_meta($item_id, '_deposit_full_amount', $item['line_total']);
         woocommerce_add_order_item_meta($item_id, '_deposit_full_amount_ex_tax', $item['line_total']);
         if ('plan' === WC_Deposits_Product_Manager::get_deposit_type($item['product_id'])) {
             $plan_id = current(WC_Deposits_Plans_Manager::get_plan_ids_for_product($item['product_id']));
             woocommerce_add_order_item_meta($item_id, '_payment_plan', $plan_id);
         } else {
             $plan_id = 0;
         }
         // Change line item costs
         $deposit_amount = WC_Deposits_Product_Manager::get_deposit_amount($product, $plan_id, 'order', $item['line_total']);
         wc_update_order_item_meta($item_id, '_line_total', $deposit_amount);
         wc_update_order_item_meta($item_id, '_line_subtotal', $deposit_amount);
     }
 }
开发者ID:Veraxus,项目名称:wc-deposits-with-variations,代码行数:24,代码来源:class-wc-deposits-order-manager.php


示例16: woocommerce_update_order_item_meta

/**
 * @deprecated
 */
function woocommerce_update_order_item_meta($item_id, $meta_key, $meta_value, $prev_value = '')
{
    return wc_update_order_item_meta($item_id, $meta_key, $meta_value, $prev_value);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php


示例17: calculate_taxes

 /**
  * Calculate taxes for all line items and shipping, and store the totals and tax rows.
  *
  * Will use the base country unless customer addresses are set.
  *
  * @return bool success or fail.
  */
 public function calculate_taxes()
 {
     $tax_total = 0;
     $shipping_tax_total = 0;
     $taxes = array();
     $shipping_taxes = array();
     $tax_based_on = get_option('woocommerce_tax_based_on');
     // If is_vat_exempt is 'yes', or wc_tax_enabled is false, return and do nothing.
     if ('yes' === $this->is_vat_exempt || !wc_tax_enabled()) {
         return false;
     }
     if ('billing' === $tax_based_on) {
         $country = $this->billing_country;
         $state = $this->billing_state;
         $postcode = $this->billing_postcode;
         $city = $this->billing_city;
     } elseif ('shipping' === $tax_based_on) {
         $country = $this->shipping_country;
         $state = $this->shipping_state;
         $postcode = $this->shipping_postcode;
         $city = $this->shipping_city;
     }
     // Default to base
     if ('base' === $tax_based_on || empty($country)) {
         $default = wc_get_base_location();
         $country = $default['country'];
         $state = $default['state'];
         $postcode = '';
         $city = '';
     }
     // Get items
     foreach ($this->get_items(array('line_item', 'fee')) as $item_id => $item) {
         $product = $this->get_product_from_item($item);
         $line_total = isset($item['line_total']) ? $item['line_total'] : 0;
         $line_subtotal = isset($item['line_subtotal']) ? $item['line_subtotal'] : 0;
         $tax_class = $item['tax_class'];
         $item_tax_status = $product ? $product->get_tax_status() : 'taxable';
         if ('0' !== $tax_class && 'taxable' === $item_tax_status) {
             $tax_rates = WC_Tax::find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => $tax_class));
             $line_subtotal_taxes = WC_Tax::calc_tax($line_subtotal, $tax_rates, false);
             $line_taxes = WC_Tax::calc_tax($line_total, $tax_rates, false);
             $line_subtotal_tax = max(0, array_sum($line_subtotal_taxes));
             $line_tax = max(0, array_sum($line_taxes));
             $tax_total += $line_tax;
             wc_update_order_item_meta($item_id, '_line_subtotal_tax', wc_format_decimal($line_subtotal_tax));
             wc_update_order_item_meta($item_id, '_line_tax', wc_format_decimal($line_tax));
             wc_update_order_item_meta($item_id, '_line_tax_data', array('total' => $line_taxes, 'subtotal' => $line_subtotal_taxes));
             // Sum the item taxes
             foreach (array_keys($taxes + $line_taxes) as $key) {
                 $taxes[$key] = (isset($line_taxes[$key]) ? $line_taxes[$key] : 0) + (isset($taxes[$key]) ? $taxes[$key] : 0);
             }
         }
     }
     // Calc taxes for shipping
     foreach ($this->get_shipping_methods() as $item_id => $item) {
         $shipping_tax_class = get_option('woocommerce_shipping_tax_class');
         // Inherit tax class from items
         if ('' === $shipping_tax_class) {
             $tax_classes = WC_Tax::get_tax_classes();
             foreach ($tax_classes as $tax_class) {
                 $tax_class = sanitize_title($tax_class);
                 if (in_array($tax_class, $found_tax_classes)) {
                     $tax_rates = WC_Tax::find_shipping_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => $tax_class));
                     break;
                 }
             }
         } else {
             $tax_rates = WC_Tax::find_shipping_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => 'standard' === $shipping_tax_class ? '' : $shipping_tax_class));
         }
         $line_taxes = WC_Tax::calc_tax($item['cost'], $tax_rates, false);
         $line_tax = max(0, array_sum($line_taxes));
         $shipping_tax_total += $line_tax;
         wc_update_order_item_meta($item_id, '_line_tax', wc_format_decimal($line_tax));
         wc_update_order_item_meta($item_id, '_line_tax_data', array('total' => $line_taxes));
         // Sum the item taxes
         foreach (array_keys($shipping_taxes + $line_taxes) as $key) {
             $shipping_taxes[$key] = (isset($line_taxes[$key]) ? $line_taxes[$key] : 0) + (isset($shipping_taxes[$key]) ? $shipping_taxes[$key] : 0);
         }
     }
     // Save tax totals
     $this->set_total($shipping_tax_total, 'shipping_tax');
     $this->set_total($tax_total, 'tax');
     // Tax rows
     $this->remove_order_items('tax');
     // Now merge to keep tax rows
     foreach (array_keys($taxes + $shipping_taxes) as $tax_rate_id) {
         $this->add_tax($tax_rate_id, isset($taxes[$tax_rate_id]) ? $taxes[$tax_rate_id] : 0, isset($shipping_taxes[$tax_rate_id]) ? $shipping_taxes[$tax_rate_id] : 0);
     }
     return true;
 }
开发者ID:coderkevin,项目名称:woocommerce,代码行数:97,代码来源:abstract-wc-order.php


示例18: admin_update_pickup_point

 /**
  * @param array $shipping_items Order items to save
  */
 public function admin_update_pickup_point($shipping_items)
 {
     $shipping_methods = $shipping_items['shipping_method'];
     if ($shipping_methods) {
         foreach ($shipping_methods as $item_id => $shipping_method) {
             if (strpos($shipping_method, Fraktguiden_Helper::ID) !== false) {
                 $pickup_point_id = $shipping_items['_fraktguiden_pickup_point_id'][$item_id];
                 $packages = $shipping_items['_fraktguiden_packages'][$item_id];
                 if ($packages) {
                     wc_update_order_item_meta($item_id, '_fraktguiden_packages', json_decode(stripslashes($packages), true));
                 }
                 if (!empty($pickup_point_id)) {
                     $pickup_point_postcode = $shipping_items['_fraktguiden_pickup_point_postcode'][$item_id];
                     $pickup_point_info = $shipping_items['_fraktguiden_pickup_point_info_cached'][$item_id];
                     wc_update_order_item_meta($item_id, '_fraktguiden_pickup_point_id', $pickup_point_id);
                     wc_update_order_item_meta($item_id, '_fraktguiden_pickup_point_postcode', $pickup_point_postcode);
                     wc_update_order_item_meta($item_id, '_fraktguiden_pickup_point_info_cached', $pickup_point_info);
                 } else {
                     wc_delete_order_item_meta($item_id, '_fraktguiden_pickup_point_postcode');
                     wc_delete_order_item_meta($item_id, '_fraktguiden_pickup_point_id');
                     wc_delete_order_item_meta($item_id, '_fraktguiden_pickup_point_info_cached');
                 }
             } else {
                 wc_delete_order_item_meta($item_id, '_fraktguiden_pickup_point_postcode');
                 wc_delete_order_item_meta($item_id, '_fraktguiden_pickup_point_id');
                 wc_delete_order_item_meta($item_id, '_fraktguiden_pickup_point_info_cached');
             }
         }
     }
 }
开发者ID:drivdigital,项目名称:bring-fraktguiden-for-woocommerce,代码行数:33,代码来源:class-bring-wc-order-adapter.php


示例19: handle_sell_order_update

 function handle_sell_order_update($order, $postData)
 {
     global $user_ID;
     if (count($postData) > 0) {
         if ($order->has_status('completed')) {
             _e("This order is completed, you can not edit it.", ET_DOMAIN);
         } elseif (!isset($_POST['ce_update_order_nonce']) || !wp_verify_nonce($_POST['ce_update_order_nonce'], 'ce_update_order_nonce')) {
             _e('Sorry, your nonce did not verify.', ET_DOMAIN);
         } else {
             foreach ($postData['status'] as $item_id => $status) {
                 $result = wc_update_order_item_meta($item_id, 'status', $status);
             }
         }
     }
 }
开发者ID:linniepinski,项目名称:perssistant,代码行数:15,代码来源:ce_shop.php


示例20: meta_box_save

 public function meta_box_save($post_id)
 {
     if (!isset($_POST['wc_bookings_details_meta_box_nonce']) || !wp_verify_nonce($_POST['wc_bookings_details_meta_box_nonce'], 'wc_bookings_details_meta_box')) {
         return $post_id;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     if (!in_array($_POST['post_type'], $this->post_types)) {
         return $post_id;
     }
     global $wpdb, $post;
     // Save simple fields
     $booking_order_id = absint($_POST['_booking_order_id']);
     $booking_status = wc_clean($_POST['_booking_status']);
     $customer_id = absint($_POST['_booking_customer_id']);
     $product_id = wc_clean($_POST['product_or_resource_id']);
     $parent_id = absint($_POST['_booking_parent_id']);
     $all_day = isset($_POST['_booking_all_day']) ? '1' : '0';
     // Update post_parent and status via query to prevent endless loops
     $wpdb->update($wpdb->posts, array('post_parent' => $booking_order_id), array('ID' => $post_id));
     $wpdb->update($wpdb->posts, array('post_status' => $booking_status), array('ID' => $post_id));
     // Trigger actions manually
     $old_status = $post->post_status;
     do_action('woocommerce_booking_' . $booking_status, $post_id);
     do_action('woocommerce_booking_' . $old_status . '_to_' . $booking_status, $post_id);
     clean_post_cache($post_id);
     // Note in the order
     if ($booking_order_id && function_exists('wc_get_order') && ($order = wc_get_order($booking_order_id))) {
         $order->add_order_note(sprintf(__('Booking #%d status changed manually from "%s" to "%s', 'woocommerce-bookings'), $post_id, $old_status, $booking_status));
     }
     // Save product and resource
     if (strstr($product_id, '=>')) {
         list($product_id, $resource_id) = explode('=>', $product_id);
     } else {
         $resource_id = 0;
     }
     update_post_meta($post_id, '_booking_resource_id', $resource_id);
     update_post_meta($post_id, '_booking_product_id', $product_id);
     // Update meta
     update_post_meta($post_id, '_booking_customer_id', $customer_id);
     update_post_meta($post_id, '_booking_parent_id', $parent_id);
     update_post_meta($post_id, '_booking_all_day', $all_day);
     // Persons
     $saved_persons = get_post_meta($post_id, '_booking_persons', true);
     $product = wc_get_product($product_id);
     $person_types = $product->get_person_types();
     if (!empty($person_types) && is_array($person_types)) {
         $booking_persons = array();
         foreach ($person_types as $person_type) {
             if (!empty($_POST['_booking_person_' . $person_type->ID])) {
                 $booking_persons[$person_type->ID] = absint($_POST['_booking_person_' . $person_type->ID]);
             }
         }
         update_post_meta($post_id, '_booking_persons', $booking_persons);
     } else {
         if (empty($person_types) && !empty($saved_persons) && is_array($saved_persons)) {
             $booking_persons = array();
             foreach (array_keys($saved_persons) as $person_id) {
                 $booking_persons[$person_id] = absint($_POST['_booking_person_' . $person_id]);
             }
             update_post_meta($post_id, '_booking_persons', $booking_persons);
         }
     }
     // Update date
     if (empty($_POST['booking_date'])) {
         $date = current_time('timestamp');
     } else {
         $date = strtotime($_POST['booking_date'] . ' ' . (int) $_POST['booking_date_hour'] . ':' . (int) $_POST['booking_date_minute'] . ':00');
     }
     $date = date_i18n('Y-m-d H:i:s', $date);
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_date = %s, post_date_gmt = %s WHERE ID = %s", $date, get_gmt_from_date($date), $post_id));
     // Do date and time magic and save them in one field
     $start_date = explode('-', wc_clean($_POST['booking_start_date']));
     $end_date = explode('-', wc_clean($_POST['booking_end_date']));
     $start_time = explode(':', wc_clean($_POST['booking_start_time']));
     $end_time = explode(':', wc_clean($_POST['booking_end_time']));
     $start = mktime($start_time[0], $start_time[1], 0, $start_date[1], $start_date[2], $start_date[0]);
     $end = mktime($end_time[0], $end_time[1], 0, $end_date[1], $end_date[2], $end_date[0]);
     update_post_meta($post_id, '_booking_start', date('YmdHis', $start));
     update_post_meta($post_id, '_booking_end', date('YmdHis', $end));
     if ($order && $booking_order_id) {
         // Update order metas
         foreach ($order->get_items() as $item_id => $item) {
             if ('line_item' != $item['type'] || !in_array($product_id, $item['item_meta']['_product_id'])) {
                 continue;
             }
             $product = wc_get_product($product_id);
             $is_all_day = isset($_POST['_booking_all_day']) && $_POST['_booking_all_day'] == 'yes';
             // Update date
             if (metadata_exists('order_item', $item_id, __('Booking Date', 'woocommerce-bookings'))) {
                 $date = mktime(0, 0, 0, $start_date[1], $start_date[2], $start_date[0]);
                 wc_update_order_item_meta($item_id, __('Booking Date', 'woocommerce-bookings'), date_i18n(wc_date_format(), $date));
             }
             // Update time
             if (!$is_all_day) {
                 if (metadata_exists('order_item', $item_id, __('Booking Time', 'woocommerce-bookings'))) {
                     $time = mktime($start_time[0], $start_time[1], 0, $start_date[1], $start_date[2], $start_date[0]);
                     wc_update_order_item_meta($item_id, __('Booking Time', 'woocommerce-bookings'), date_i18n(wc_time_format(), $time));
                 }
//.........这里部分代码省略.........
开发者ID:baperrou,项目名称:pedal-bookings,代码行数:101,代码来源:class-wc-bookings-details-meta-box.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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