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


PHP woocommerce_add_order_item_meta函数代码示例

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


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

示例1: pp_add_order_item_meta

function pp_add_order_item_meta($item_id, $cart_item)
{
    global $woocommerce;
    if (!empty($cart_item['_w2p_set_option'])) {
        woocommerce_add_order_item_meta($item_id, '_w2p_set_option', $cart_item['_w2p_set_option']);
    }
}
开发者ID:pfurmel,项目名称:MVCgroupwp,代码行数:7,代码来源:pitchprint.php

示例2: add_order_item_meta

 /**
  * After ordering, add the data to the order line items.
  *
  * @access public
  * @param mixed $item_id
  * @param mixed $cart_item
  * @return void
  * @since 8.0.0
  */
 public function add_order_item_meta($item_id, $cart_item)
 {
     $length = get_post_meta($cart_item['product_id'], '_length', TRUE);
     $width = get_post_meta($cart_item['product_id'], '_width', TRUE);
     $height = get_post_meta($cart_item['product_id'], '_height', TRUE);
     $is_volumetrik_enabled = get_post_meta($cart_item['product_id'], $this->meta, TRUE);
     if ($is_volumetrik_enabled == 'yes' && !empty($length) && !empty($width) && !empty($height)) {
         woocommerce_add_order_item_meta($item_id, __('Dimension', 'agenwebsite'), sprintf('%u x %u x %u cm', $length, $width, $height));
     }
 }
开发者ID:vanbungkring,项目名称:24custom,代码行数:19,代码来源:shipping-volumetrik.php

示例3: save_called_credit_details_in_order_item_meta

 /**
  * Save entered credit value by customer in order item meta
  *
  * @param int $item_id
  * @param array $values associative array containing item's details
  */
 public function save_called_credit_details_in_order_item_meta($item_id, $values)
 {
     $coupon_titles = get_post_meta($values['product_id'], '_coupon_title', true);
     if ($this->is_coupon_amount_pick_from_product_price($coupon_titles) && isset($values['data']->price) && $values['data']->price > 0) {
         woocommerce_add_order_item_meta($item_id, 'sc_called_credit', $values['data']->price);
     }
 }
开发者ID:NerdyDillinger,项目名称:ovrride,代码行数:13,代码来源:woocommerce-smart-coupons.php

示例4: woocommerce_add_line_tax

/**
 * woocommerce_add_line_tax function.
 *
 * @access public
 * @return void
 */
function woocommerce_add_line_tax()
{
    global $woocommerce, $wpdb;
    check_ajax_referer('calc-totals', 'security');
    $order_id = absint($_POST['order_id']);
    $order = new WC_Order($order_id);
    // Get tax rates
    $rates = $wpdb->get_results("SELECT tax_rate_id, tax_rate_country, tax_rate_state, tax_rate_name, tax_rate_priority FROM {$wpdb->prefix}woocommerce_tax_rates ORDER BY tax_rate_name");
    $tax_codes = array();
    foreach ($rates as $rate) {
        $code = array();
        $code[] = $rate->tax_rate_country;
        $code[] = $rate->tax_rate_state;
        $code[] = $rate->tax_rate_name ? sanitize_title($rate->tax_rate_name) : 'TAX';
        $code[] = absint($rate->tax_rate_priority);
        $tax_codes[$rate->tax_rate_id] = strtoupper(implode('-', array_filter($code)));
    }
    // Add line item
    $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => '', 'order_item_type' => 'tax'));
    // Add line item meta
    if ($item_id) {
        woocommerce_add_order_item_meta($item_id, 'rate_id', '');
        woocommerce_add_order_item_meta($item_id, 'label', '');
        woocommerce_add_order_item_meta($item_id, 'compound', '');
        woocommerce_add_order_item_meta($item_id, 'tax_amount', '');
        woocommerce_add_order_item_meta($item_id, 'shipping_tax_amount', '');
    }
    include 'admin/post-types/writepanels/order-tax-html.php';
    // Quit out
    die;
}
开发者ID:rongandat,项目名称:sallumeh,代码行数:37,代码来源:woocommerce-ajax.php

示例5: order_item_meta_2

 /**
  * Save sold by text in database
  *
  * @param item_id, cart_item
  * @return void 
  */
 function order_item_meta_2($item_id, $cart_item)
 {
     global $WCMp;
     if ($WCMp->vendor_caps->vendor_frontend_settings('sold_by_cart_and_checkout')) {
         $general_cap = isset($this->frontend_cap['sold_by_text']) ? $this->frontend_cap['sold_by_text'] : '';
         if (!$general_cap) {
             $general_cap = 'Sold By';
         }
         $vendor = get_wcmp_product_vendors($cart_item['product_id']);
         if ($vendor) {
             woocommerce_add_order_item_meta($item_id, $general_cap, $vendor->user_data->display_name);
             woocommerce_add_order_item_meta($item_id, '_vendor_id', $vendor->id);
         }
     }
 }
开发者ID:itsunus,项目名称:wstore,代码行数:21,代码来源:class-wcmp-capabilities.php

示例6: save_vendor_settings

 public function save_vendor_settings()
 {
     global $woocommerce;
     $user_id = get_current_user_id();
     if (!empty($_GET['wc_pv_mark_shipped'])) {
         $shop_name = WCV_Vendors::get_vendor_shop_name($user_id);
         $order_id = $_GET['wc_pv_mark_shipped'];
         $shippers = (array) get_post_meta($order_id, 'wc_pv_shipped', true);
         $order = new WC_Order($order_id);
         // If not in the shippers array mark as shipped otherwise do nothing.
         if (!in_array($user_id, $shippers)) {
             $shippers[] = $user_id;
             $mails = $woocommerce->mailer()->get_emails();
             if (!empty($mails)) {
                 $mails['WC_Email_Notify_Shipped']->trigger($order_id, $user_id);
             }
             do_action('wcvendors_vendor_ship', $order_id, $user_id);
             wc_add_notice(__('Order marked shipped.', 'wcvendors'), 'success');
             $order->add_order_note(apply_filters('wcvendors_vendor_shipped_note', __($shop_name . ' has marked as shipped. ', 'wcvendors')), $user_id);
         } elseif (false != ($key = array_search($user_id, $shippers))) {
             unset($shippers[$key]);
             // Remove user from the shippers array
         }
         update_post_meta($order_id, 'wc_pv_shipped', $shippers);
         return;
     }
     if (isset($_POST['update_tracking'])) {
         $order_id = (int) $_POST['order_id'];
         $product_id = (int) $_POST['product_id'];
         $tracking_provider = woocommerce_clean($_POST['tracking_provider']);
         $custom_tracking_provider = woocommerce_clean($_POST['custom_tracking_provider_name']);
         $custom_tracking_link = woocommerce_clean($_POST['custom_tracking_url']);
         $tracking_number = woocommerce_clean($_POST['tracking_number']);
         $date_shipped = woocommerce_clean(strtotime($_POST['date_shipped']));
         $order = new WC_Order($order_id);
         $products = $order->get_items();
         foreach ($products as $key => $value) {
             if ($value['product_id'] == $product_id || $value['variation_id'] == $product_id) {
                 $order_item_id = $key;
                 break;
             }
         }
         if ($order_item_id) {
             woocommerce_delete_order_item_meta($order_item_id, __('Tracking number', 'wcvendors'));
             woocommerce_add_order_item_meta($order_item_id, __('Tracking number', 'wcvendors'), $tracking_number);
             $message = __('Success. Your tracking number has been updated.', 'wcvendors');
             wc_add_notice($message, 'success');
             // Update order data
             update_post_meta($order_id, '_tracking_provider', $tracking_provider);
             update_post_meta($order_id, '_custom_tracking_provider', $custom_tracking_provider);
             update_post_meta($order_id, '_tracking_number', $tracking_number);
             update_post_meta($order_id, '_custom_tracking_link', $custom_tracking_link);
             update_post_meta($order_id, '_date_shipped', $date_shipped);
         }
     }
     if (empty($_POST['vendor_application_submit'])) {
         return false;
     }
     if (isset($_POST['wc-product-vendor-nonce'])) {
         if (!wp_verify_nonce($_POST['wc-product-vendor-nonce'], 'save-shop-settings')) {
             return false;
         }
         if (isset($_POST['pv_paypal'])) {
             if (!is_email($_POST['pv_paypal'])) {
                 wc_add_notice(__('Your PayPal address is not a valid email address.', 'wcvendors'), 'error');
             } else {
                 update_user_meta($user_id, 'pv_paypal', $_POST['pv_paypal']);
             }
         }
         if (!empty($_POST['pv_shop_name'])) {
             $users = get_users(array('meta_key' => 'pv_shop_slug', 'meta_value' => sanitize_title($_POST['pv_shop_name'])));
             if (!empty($users) && $users[0]->ID != $user_id) {
                 wc_add_notice(__('That shop name is already taken. Your shop name must be unique.', 'wcvendors'), 'error');
             } else {
                 update_user_meta($user_id, 'pv_shop_name', $_POST['pv_shop_name']);
                 update_user_meta($user_id, 'pv_shop_slug', sanitize_title($_POST['pv_shop_name']));
             }
         }
         if (isset($_POST['pv_shop_description'])) {
             update_user_meta($user_id, 'pv_shop_description', $_POST['pv_shop_description']);
         }
         if (isset($_POST['pv_seller_info'])) {
             update_user_meta($user_id, 'pv_seller_info', $_POST['pv_seller_info']);
         }
         do_action('wcvendors_shop_settings_saved', $user_id);
         if (!wc_notice_count()) {
             wc_add_notice(__('Settings saved.', 'wcvendors'), 'success');
         }
     }
 }
开发者ID:oleggen,项目名称:wcvendors,代码行数:90,代码来源:class-vendor-dashboard.php

示例7: booking_order_box

        function booking_order_box()
        {
            global $woocommerce, $wpdb;
            check_ajax_referer('order-item', 'security');
            $meta_id_next = '';
            $meta_id = '';
            $meta_id = woocommerce_add_order_item_meta(absint($_POST['order_item_id']), __('Name', 'woocommerce'), __('Value', 'woocommerce'));
            //print_r($meta_ids);
            //echo $meta_id; die();
            /*$meta_query = $check_query = "SELECT MAX(meta_id) AS meta_id FROM `".$wpdb->prefix."woocommerce_order_itemmeta`
            				WHERE order_item_id ='".$_POST['order_item_id']."'
            				";
            		$meta_results = $wpdb->get_results($meta_query);
            		$meta_id = $meta_results[0]->meta_id;*/
            $bookings_added = woocommerce_get_order_item_meta($_POST['order_item_id'], get_option("book.date-label"), true);
            if ($bookings_added == '') {
                //print_r("ehre".$bookings_added);die();
                if ($meta_id) {
                    $check_query = "SELECT meta_value AS product_id FROM `" . $wpdb->prefix . "woocommerce_order_itemmeta`\n\t\t\t\t\t\tWHERE meta_key ='_product_id'\n\t\t\t\t\t\tAND order_item_id ='" . $_POST['order_item_id'] . "'\n\t\t\t\t\t\t";
                    $results_check = $wpdb->get_results($check_query);
                    $product_id = $results_check[0]->product_id;
                    //print_r($product_id);
                    $prod_id = get_post_meta($product_id, '_icl_lang_duplicate_of', true);
                    if ($prod_id == '' && $prod_id == null) {
                        //	$duplicate_of = $cart_item['product_id'];
                        $post_time = get_post($product_id);
                        $id_query = "SELECT ID FROM `" . $wpdb->prefix . "posts` WHERE post_date = '" . $post_time->post_date . "' ORDER BY ID LIMIT 1";
                        $results_post_id = $wpdb->get_results($id_query);
                        if (isset($results_post_id)) {
                            $prod_id = $results_post_id[0]->ID;
                        } else {
                            $prod_id = $product_id;
                        }
                    }
                    $cart_item_key = $_POST['order_item_id'];
                    $product_settings = get_post_meta($prod_id, 'woocommerce_booking_settings', true);
                    $i = 0;
                    //echo "PROD<pre>";print_r($product_settings);echo "</pre>";
                    echo '<input type="hidden" id="order_item_ids"  name="order_item_ids" value="' . $_POST['order_item_id'] . '"/>';
                    if (isset($product_settings['booking_enable_multiple_day']) && $product_settings['booking_enable_multiple_day'] == 'on' && (isset($product_settings['booking_fixed_block_enable']) && $product_settings['booking_fixed_block_enable'] == 'yes')) {
                        $results = $this->get_fixed_blocks($prod_id);
                        //print_r($results);die();
                        if (count($results) > 0) {
                            echo '<tr data-meta_id="' . $meta_id . '"><td><input type="text" name="meta_key[' . $meta_id . ']" value="Select Period" /></td><td><select name="meta_value[' . $meta_id . ']" id="admin_block_option_' . $_POST['order_item_id'] . '">';
                            foreach ($results as $key => $value) {
                                echo '<option id = ' . $value->start_day . '&' . $value->number_of_days . '&' . $value->price . ' value="' . $value->block_name . '">' . $value->block_name . '</option>';
                            }
                            echo '</select></td><td width="1%"><button class="remove_order_item_meta button">&times;</button></td></tr>';
                            $meta_id_start = $meta_id + 1;
                            $meta_id_end = $meta_id_start + 1;
                            echo '<input type="hidden" id="meta_id_start"  name="meta_id_start" value="' . $meta_id_start . '"/>';
                            echo '<input type="hidden" id="meta_id_end"  name="meta_id_end" value="' . $meta_id_end . '"/>';
                            ?>
						<script type="text/javascript">	
						var order_item_id = jQuery("#order_item_ids").val();
						jQuery("#admin_block_option_"+order_item_id).change(function()
						{
							//alert();
							if ( jQuery("#admin_block_option_"+order_item_id).val() != "" )
							{
								var passed_id = jQuery(this).children(":selected").attr("id");
								var exploded_id = passed_id.split('&');
								console.log(exploded_id);
								var meta_id_start = jQuery("#meta_id_start").val();
								var meta_id_end = jQuery("#meta_id_end").val();
								jQuery("#admin_block_option_start_day_"+order_item_id).val(exploded_id[0]);
								jQuery("#admin_block_option_number_of_day_"+order_item_id).val(exploded_id[1]);
								jQuery("#admin_block_option_price_"+order_item_id).val(exploded_id[2]);
								jQuery("#wapbk_admin_hidden_date_"+order_item_id).val("");
								jQuery("#wapbk_admin_hidden_date_checkout_"+order_item_id).val("");
								//jQuery("#show_time_slot").html("");
								jQuery("#admin_booking_calender_"+ meta_id_start).datepicker("setDate");
								jQuery("#admin_booking_calender_checkout_" + meta_id_end).datepicker("setDate");
							}
						});
	
	
						</script>
	
						<?php 
                            if (count($results) >= 0) {
                                $sd = $results[0]->start_day;
                                $nd = $results[0]->number_of_days;
                                $pd = $results[0]->price;
                            }
                            echo ' <input type="hidden" id="admin_block_option_enabled_' . $_POST['order_item_id'] . '"  name="admin_block_option_enabled_' . $_POST['order_item_id'] . '" value="on"/> 

						<input type="hidden" id="admin_block_option_start_day_' . $_POST['order_item_id'] . '"  name="admin_block_option_start_day_' . $_POST['order_item_id'] . '" value="' . $sd . '"/> 
						
						<input type="hidden" id="admin_block_option_number_of_day_' . $_POST['order_item_id'] . '"  name="admin_block_option_number_of_day_' . $_POST['order_item_id'] . '" value="' . $nd . '"/>
					
						<input type="hidden" id="admin_block_option_price_' . $_POST['order_item_id'] . '"name="admin_block_option_price_' . $_POST['order_item_id'] . '" value="' . $pd . '"/>';
                        } else {
                            $number_of_fixed_price_blocks = 0;
                            echo ' <input type="hidden" id="admin_block_option_enabled_' . $_POST['order_item_id'] . '"  name="admin_block_option_enabled_' . $_POST['order_item_id'] . '" value="off"/>
						
						<input type="hidden" id="admin_block_option_start_day_' . $_POST['order_item_id'] . '"  name="admin_block_option_start_day_' . $_POST['order_item_id'] . '" value=""/> 
						
						<input type="hidden" id="admin_block_option_number_of_day_' . $_POST['order_item_id'] . '"  name="admin_block_option_number_of_day_' . $_POST['order_item_id'] . '" value=""/>
						
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:Refine-woocommerce-booking,代码行数:101,代码来源:admin-bookings.php

示例8: woocommerce_etsyi_submenu_page_callback


//.........这里部分代码省略.........
                    foreach ($country_data as $cdata) {
                        $countries_name[$cdata['countries_name']] = $cdata;
                    }
                    if ($orders = $oscdb->get_results("SELECT * FROM orders ORDER BY orders_id", ARRAY_A)) {
                        foreach ($orders as $order) {
                            $existing_order = get_posts(array('post_type' => 'shop_order', 'posts_per_page' => 1, 'post_status' => 'any', 'meta_query' => array(array('key' => 'osc_id', 'value' => $order['orders_id']))));
                            if (empty($existing_order)) {
                                $totals = array();
                                if ($total_query = $oscdb->get_results("SELECT * FROM orders_total WHERE orders_id='" . $order['orders_id'] . "'", ARRAY_A)) {
                                    foreach ($total_query as $t) {
                                        $totals[$t['class']] = $t;
                                    }
                                }
                                $order_key = 'order_' . wp_generate_password(13);
                                $data = array('post_type' => 'shop_order', 'post_date' => $order['date_purchased'], 'post_author' => $customer_id[$order['customers_id']], 'post_password' => $order_key, 'post_title' => 'Order &ndash; ' . date("M d, Y @ h:i A", strtotime($order['date_purchased'])), 'post_status' => 'publish');
                                $order_id = wp_insert_post($data);
                                $billing_namebits = explode(' ', $order['billing_name']);
                                $billing_firstname = $billing_namebits[0];
                                $billing_lastname = trim(str_replace($billing_namebits[0], '', $order['billing_name']));
                                $shipping_namebits = explode(' ', $order['delivery_name']);
                                $shipping_firstname = $shipping_namebits[0];
                                $shipping_lastname = trim(str_replace($shipping_namebits[0], '', $order['delivery_name']));
                                $meta_data = array('_billing_address_1' => $order['billing_street_address'], '_billing_address_2' => $order['billing_suburb'], '_wpas_done_all' => 1, '_billing_country' => $countries_name[$order['billing_country']]['countries_iso_code_2'], '_billing_first_name' => $billing_firstname, '_billing_last_name' => $billing_lastname, '_billing_company' => $order['billing_company'], '_billing_city' => $order['billing_city'], '_billing_state' => $order['billing_state'], '_billing_postcode' => $order['billing_postcode'], '_billing_phone' => $order['customers_telephone'], '_billing_email' => $order['customers_email_address'], '_shipping_country' => $countries_name[$order['delivery_country']]['countries_iso_code_2'], '_shipping_first_name' => $shipping_firstname, '_shipping_last_name' => $shipping_lastname, '_shipping_company' => $order['delivery_company'], '_shipping_address_1' => $order['delivery_street_address'], '_shipping_address_2' => $order['delivery_suburb'], '_shipping_city' => $order['delivery_city'], '_shipping_state' => $order['delivery_state'], '_shipping_postcode' => $order['delivery_postcode'], '_shipping_method_title' => $totals['ot_shipping']['title'], '_payment_method_title' => $order['payment_method'], '_order_shipping' => $totals['ot_shipping']['value'], '_order_discount' => $totals['ot_coupon']['value'] + $totals['ot_discount']['value'], '_order_tax' => $totals['ot_tax']['value'], '_order_shipping_tax' => 0, '_order_total' => $totals['ot_total']['value'], '_order_key' => $order_key, '_customer_user' => $customer_id[$order['customers_id']], '_order_currency' => $order['currency'], '_prices_include_tax' => 'no', 'osc_id' => $order['orders_id']);
                                foreach ($meta_data as $k => $v) {
                                    update_post_meta($order_id, $k, $v);
                                }
                                $order_import_counter++;
                                if ($order_products = $oscdb->get_results("SELECT * FROM orders_products WHERE orders_id='" . $order['orders_id'] . "'", ARRAY_A)) {
                                    foreach ($order_products as $product) {
                                        $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => $product['products_name'], 'order_item_type' => 'line_item'));
                                        if ($item_id) {
                                            $item_meta = array('_qty' => $product['products_quantity'], '_product_id' => $product_id[$product['products_id']], '_line_subtotal' => $product['final_price'] * $product['products_quantity'], '_line_total' => $product['final_price'] * $product['products_quantity']);
                                            foreach ($item_meta as $k => $v) {
                                                woocommerce_add_order_item_meta($item_id, $k, $v);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if ($_POST['dtype']['pages'] == 1) {
                    $page_import_counter = 0;
                    if ($information_table = $oscdb->get_results("SHOW TABLES LIKE 'information'", ARRAY_A)) {
                        if ($information_pages = $oscdb->get_results("SELECT * FROM information WHERE language_id=1", ARRAY_A)) {
                            foreach ($information_pages as $information) {
                                $existing_page = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type='page' AND LOWER(post_title)='" . strtolower(esc_sql($information['information_title'])) . "'", ARRAY_A);
                                if (!$existing_page) {
                                    $existing_page = get_posts(array('post_type' => 'page', 'posts_per_page' => 1, 'post_status' => 'any', 'meta_query' => array(array('key' => 'osc_id', 'value' => $information['information_id']))));
                                    if (!$existing_page) {
                                        $data = array('post_type' => 'page', 'post_title' => $information['information_title'], 'post_content' => $information['information_description'], 'post_status' => 'publish');
                                        $page_id = wp_insert_post($data);
                                        update_post_meta($page_id, 'osc_id', $information['information_id']);
                                        $page_import_counter++;
                                    }
                                }
                            }
                        }
                    } else {
                        echo '<p class="notice">The information (pages) table does not exist in this osCommerce installation.</p>';
                    }
                }
                $success = true;
            } else {
                echo '<p class="notice">Could not connect to the osCommerce database</p>';
开发者ID:Korri,项目名称:woocommerce-etsy-importer,代码行数:67,代码来源:woocommerce-etsy-importer.php

示例9: output

 /**
  * Output the form
  */
 public function output()
 {
     global $woocommerce;
     $this->errors = array();
     $step = 1;
     try {
         if (!empty($_POST) && !check_admin_referer('create_booking_notification')) {
             throw new Exception(__('Error - please try again', 'woocommerce-bookings'));
         }
         if (!empty($_POST['create_booking'])) {
             $customer_id = absint($_POST['customer_id']);
             $bookable_product_id = absint($_POST['bookable_product_id']);
             $create_order = isset($_POST['create_order']) ? 1 : 0;
             if (!$bookable_product_id) {
                 throw new Exception(__('Please choose a bookable product', 'woocommerce-bookings'));
             }
             $step++;
             $product = get_product($bookable_product_id);
             $booking_form = new WC_Booking_Form($product);
         } elseif (!empty($_POST['create_booking_2'])) {
             $customer_id = absint($_POST['customer_id']);
             $bookable_product_id = absint($_POST['bookable_product_id']);
             $create_order = absint($_POST['create_order']);
             $product = get_product($bookable_product_id);
             $booking_form = new WC_Booking_Form($product);
             $booking_data = $booking_form->get_posted_data($_POST);
             $booking_cost = number_format($booking_form->calculate_booking_cost($_POST), 2, '.', '');
             // Data to go into the booking
             $new_booking_data = array('product_id' => $product->id, 'resource_id' => isset($booking_data['_resource_id']) ? $booking_data['_resource_id'] : '', 'persons' => $booking_data['_persons'], 'cost' => $booking_cost, 'start_date' => $booking_data['_start_date'], 'end_date' => $booking_data['_end_date'], 'all_day' => $booking_data['_all_day'] ? 1 : 0);
             // Create order
             if ($create_order) {
                 $order_id = $this->create_order($booking_cost, $customer_id);
                 if (!$order_id) {
                     throw new Exception(__('Error: Could not create order', 'woocommerce-bookings'));
                 }
                 $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => $product->get_title(), 'order_item_type' => 'line_item'));
                 if (!$item_id) {
                     throw new Exception(__('Error: Could not create item', 'woocommerce-bookings'));
                 }
                 // Add line item meta
                 woocommerce_add_order_item_meta($item_id, '_qty', 1);
                 woocommerce_add_order_item_meta($item_id, '_tax_class', $product->get_tax_class());
                 woocommerce_add_order_item_meta($item_id, '_product_id', $product->id);
                 woocommerce_add_order_item_meta($item_id, '_variation_id', '');
                 woocommerce_add_order_item_meta($item_id, '_line_subtotal', $booking_cost);
                 woocommerce_add_order_item_meta($item_id, '_line_total', $booking_cost);
                 woocommerce_add_order_item_meta($item_id, '_line_tax', 0);
                 woocommerce_add_order_item_meta($item_id, '_line_subtotal_tax', 0);
                 // We have an item id
                 $new_booking_data['order_item_id'] = $item_id;
                 // Add line item data
                 foreach ($booking_data as $key => $value) {
                     if (strpos($key, '_') !== 0) {
                         woocommerce_add_order_item_meta($item_id, get_wc_booking_data_label($key, $product), $value);
                     }
                 }
             }
             // Create the booking itself
             $new_booking = get_wc_booking($new_booking_data);
             $new_booking->create($create_order ? 'unpaid' : 'pending');
             wp_safe_redirect(admin_url('post.php?post=' . ($create_order ? $order_id : $new_booking->id) . '&action=edit'));
             exit;
         }
     } catch (Exception $e) {
         $this->errors[] = $e->getMessage();
     }
     switch ($step) {
         case 1:
             include 'views/html-create-booking-page.php';
             break;
         case 2:
             include 'views/html-create-booking-page-2.php';
             break;
     }
 }
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:78,代码来源:class-wc-bookings-create.php

示例10: tshirt_designer_add_order_item_meta

function tshirt_designer_add_order_item_meta($item_id, $cart_item)
{
    //order completed page. & admin
    if (!empty($cart_item['tshirt_designer_front_img']) || !empty($cart_item['tshirt_designer_back_img'])) {
        woocommerce_add_order_item_meta($item_id, 'tshirt_designer_front_img', $cart_item['tshirt_designer_front_img']);
        woocommerce_add_order_item_meta($item_id, 'tshirt_designer_back_img', $cart_item['tshirt_designer_back_img']);
    }
}
开发者ID:riddbengkok,项目名称:tshirt-designer,代码行数:8,代码来源:tshirt-designer-functions.php

示例11: add_order_item_meta

 function add_order_item_meta($item_id, $values)
 {
     if ($values['sample']) {
         woocommerce_add_order_item_meta($item_id, 'product type', 'sample');
     }
 }
开发者ID:Kennikvik,项目名称:woocommerce-sample,代码行数:6,代码来源:woocommerce-sample.php

示例12: ajax_update_recurring_tax

 /**
  * Update recurring line taxes via AJAX
  * @see WC_Subscriptions_Order::calculate_recurring_line_taxes()
  * 
  * @since 4.4
  * @return JSON object with updated tax data
  */
 public static function ajax_update_recurring_tax()
 {
     global $wpdb;
     $woo_22_plus = version_compare(WOOCOMMERCE_VERSION, '2.2', '>=');
     check_ajax_referer('woocommerce-subscriptions', 'security');
     $order_id = absint($_POST['order_id']);
     $country = strtoupper(esc_attr($_POST['country']));
     // Step out of the way if the customer is not located in the US
     if ($country != 'US') {
         return;
     }
     $shipping = $_POST['shipping'];
     $line_subtotal = isset($_POST['line_subtotal']) ? esc_attr($_POST['line_subtotal']) : 0;
     $line_total = isset($_POST['line_total']) ? esc_attr($_POST['line_total']) : 0;
     // Set up WC_WooTax_Order object
     $order = self::get_order($order_id);
     // We only need to instantiate a WC_Tax object if we are using WooCommerce < 2.3
     if (!$woo_22_plus) {
         $tax = new WC_Tax();
     }
     $taxes = $shipping_taxes = array();
     $return = array();
     $item_data = array();
     $type_array = array();
     $product_id = '';
     if (isset($_POST['order_item_id'])) {
         $product_id = woocommerce_get_order_item_meta($_POST['order_item_id'], '_product_id');
     } elseif (isset($_POST['product_id'])) {
         $product_id = esc_attr($_POST['product_id']);
     }
     if (!empty($product_id) && WC_Subscriptions_Product::is_subscription($product_id)) {
         // Get product details
         $product = WC_Subscriptions::get_product($product_id);
         // Add product to items array
         $tic = get_post_meta($product->id, 'wootax_tic', true);
         $item_info = array('Index' => '', 'ItemID' => isset($_POST['order_item_id']) ? $_POST['order_item_id'] : $product_id, 'Qty' => 1, 'Price' => $line_subtotal > 0 ? $line_subtotal : $product->get_price(), 'Type' => 'cart');
         if (!empty($tic) && $tic) {
             $item_info['TIC'] = $tic;
         }
         $item_data[] = $item_info;
         $type_array[$_POST['order_item_id']] = 'cart';
         // Add shipping to items array
         if ($shipping > 0) {
             $item_data[] = array('Index' => '', 'ItemID' => WT_SHIPPING_ITEM, 'TIC' => WT_SHIPPING_TIC, 'Qty' => 1, 'Price' => $shipping, 'Type' => 'shipping');
             $type_array[WT_SHIPPING_ITEM] = 'shipping';
         }
         // Issue Lookup request
         $res = $order->do_lookup($item_data, $type_array, true);
         if (is_array($res)) {
             $return['recurring_shipping_tax'] = 0;
             $return['recurring_line_subtotal_tax'] = 0;
             $return['recurring_line_tax'] = 0;
             foreach ($res as $item) {
                 $item_id = $item->ItemID;
                 $item_tax = $item->TaxAmount;
                 if ($item_id == WT_SHIPPING_ITEM) {
                     $return['recurring_shipping_tax'] += $item_tax;
                 } else {
                     $return['recurring_line_subtotal_tax'] += $item_tax;
                     $return['recurring_line_tax'] += $item_tax;
                 }
             }
             $taxes[WT_RATE_ID] = $return['recurring_line_tax'];
             $shipping_taxes[WT_RATE_ID] = $return['recurring_shipping_tax'];
             // Get tax rates
             $tax_codes = array(WT_RATE_ID => apply_filters('wootax_rate_code', 'WOOTAX-RATE-DO-NOT-REMOVE'));
             // Remove old tax rows
             $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = 'recurring_tax' )", $order_id));
             $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = 'recurring_tax'", $order_id));
             // Now merge to keep tax rows
             ob_start();
             foreach (array_keys($taxes + $shipping_taxes) as $key) {
                 $item = array();
                 $item['rate_id'] = $key;
                 $item['name'] = $tax_codes[$key];
                 $item['label'] = $woo_22_plus ? WC_Tax::get_rate_label($key) : $tax->get_rate_label($key);
                 $item['compound'] = $woo_22_plus ? WC_Tax::is_compound($key) : $tax->is_compound($key) ? 1 : 0;
                 $item['tax_amount'] = wc_round_tax_total(isset($taxes[$key]) ? $taxes[$key] : 0);
                 $item['shipping_tax_amount'] = wc_round_tax_total(isset($shipping_taxes[$key]) ? $shipping_taxes[$key] : 0);
                 if (!$item['label']) {
                     $item['label'] = WC()->countries->tax_or_vat();
                 }
                 // Add line item
                 $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => $item['name'], 'order_item_type' => 'recurring_tax'));
                 // Add line item meta
                 if ($item_id) {
                     woocommerce_add_order_item_meta($item_id, 'rate_id', $item['rate_id']);
                     woocommerce_add_order_item_meta($item_id, 'label', $item['label']);
                     woocommerce_add_order_item_meta($item_id, 'compound', $item['compound']);
                     woocommerce_add_order_item_meta($item_id, 'tax_amount', $item['tax_amount']);
                     woocommerce_add_order_item_meta($item_id, 'shipping_tax_amount', $item['shipping_tax_amount']);
                 }
                 include plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/admin/post-types/writepanels/order-tax-html.php';
//.........这里部分代码省略.........
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:101,代码来源:class-wt-orders.php

示例13: order_item_meta

 /**
  * order_item_meta function.
  *
  * @param mixed $item_id
  * @param mixed $values
  */
 public function order_item_meta($item_id, $values)
 {
     if (!empty($values['food'])) {
         $product = $values['data'];
         // Add summary of details to line item
         foreach ($values['food'] as $key => $value) {
             if (strpos($key, '_') !== 0) {
                 if (is_array($value)) {
                     foreach ($value as $data) {
                         woocommerce_add_order_item_meta($item_id, get_takeaway_food_data_label($key, $product), $data);
                     }
                 } else {
                     woocommerce_add_order_item_meta($item_id, get_takeaway_food_data_label($key, $product), $value);
                 }
             }
         }
     }
 }
开发者ID:ankitparsanaa,项目名称:foodapp,代码行数:24,代码来源:class-takeaway-food-cart.php

示例14: wdm_add_values_to_order_item_meta

 function wdm_add_values_to_order_item_meta($item_id, $values)
 {
     global $woocommerce, $wpdb;
     $user_custom_values = $values['wdm_user_custom_data_value'];
     $pdf_processing_status = 0;
     $pdf_processing_description = 'Waiting for execution of cron-job';
     if (!empty($user_custom_values)) {
         woocommerce_add_order_item_meta($item_id, 'wdm_user_custom_data', $user_custom_values);
         woocommerce_add_order_item_meta($item_id, 'pdf_processing_status', $pdf_processing_status);
         woocommerce_add_order_item_meta($item_id, 'pdf_processing_description', $pdf_processing_description);
     }
 }
开发者ID:shwetadubey,项目名称:upfit,代码行数:12,代码来源:functions.php

示例15: upgrade_database_to_1_2


//.........这里部分代码省略.........
             // Doing it wrong: updated Subs *after* updating WooCommerce, need to store in WC2.0 tax structure
             $index = 0;
             $new_order_taxes = $order->get_taxes();
             foreach ($new_order_taxes as $item_id => $order_tax) {
                 $index = $index + 1;
                 if (!isset($order_taxes[$index]['label']) || !isset($order_taxes[$index]['cart_tax']) || !isset($order_taxes[$index]['shipping_tax'])) {
                     continue;
                 }
                 // Add line item meta
                 if ($item_id) {
                     woocommerce_update_order_item_meta($item_id, 'compound', absint(isset($order_taxes[$index]['compound']) ? $order_taxes[$index]['compound'] : 0));
                     woocommerce_update_order_item_meta($item_id, 'tax_amount', woocommerce_clean($order_taxes[$index]['cart_tax']));
                     woocommerce_update_order_item_meta($item_id, 'shipping_tax_amount', woocommerce_clean($order_taxes[$index]['shipping_tax']));
                 }
             }
         }
         /* Upgrade each order item to use new Item Meta schema */
         $order_subscription_periods = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_periods', array());
         $order_subscription_intervals = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_intervals', array());
         $order_subscription_lengths = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_lengths', array());
         $order_subscription_trial_lengths = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_trial_lengths', array());
         $order_items = $order->get_items();
         foreach ($order_items as $index => $order_item) {
             $product_id = WC_Subscriptions_Order::get_items_product_id($order_item);
             $item_meta = new WC_Order_Item_Meta($order_item['item_meta']);
             $subscription_interval = isset($order_subscription_intervals[$product_id]) ? $order_subscription_intervals[$product_id] : 1;
             $subscription_length = isset($order_subscription_lengths[$product_id]) ? $order_subscription_lengths[$product_id] : 0;
             $subscription_trial_length = isset($order_subscription_trial_lengths[$product_id]) ? $order_subscription_trial_lengths[$product_id] : 0;
             $subscription_sign_up_fee = WC_Subscriptions_Order::get_meta($order, '_cart_contents_sign_up_fee_total', 0);
             if ($sign_up_fee_total > 0) {
                 // Discounted price * Quantity
                 $sign_up_fee_line_total = WC_Subscriptions_Order::get_meta($order, '_cart_contents_sign_up_fee_total', 0);
                 $sign_up_fee_line_tax = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_tax_total', 0);
                 // Base price * Quantity
                 $sign_up_fee_line_subtotal = WC_Subscriptions_Order::get_meta($order, '_cart_contents_sign_up_fee_total', 0) + WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_cart', 0);
                 $sign_up_fee_propotion = $sign_up_fee_line_total > 0 ? $sign_up_fee_line_subtotal / $sign_up_fee_line_total : 0;
                 $sign_up_fee_line_subtotal_tax = WC_Subscriptions_Manager::get_amount_from_proportion(WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_tax_total', 0), $sign_up_fee_propotion);
                 if ($has_trial) {
                     // Set line item totals equal to sign up fee totals
                     $order_item['line_subtotal'] = $sign_up_fee_line_subtotal;
                     $order_item['line_subtotal_tax'] = $sign_up_fee_line_subtotal_tax;
                     $order_item['line_total'] = $sign_up_fee_line_total;
                     $order_item['line_tax'] = $sign_up_fee_line_tax;
                 } else {
                     // No trial period, sign up fees need to be added to order totals
                     $order_item['line_subtotal'] += $sign_up_fee_line_subtotal;
                     $order_item['line_subtotal_tax'] += $sign_up_fee_line_subtotal_tax;
                     $order_item['line_total'] += $sign_up_fee_line_total;
                     $order_item['line_tax'] += $sign_up_fee_line_tax;
                 }
             }
             // Upgrading with WC 1.x
             if (method_exists($item_meta, 'add')) {
                 $item_meta->add('_subscription_period', $order_subscription_periods[$product_id]);
                 $item_meta->add('_subscription_interval', $subscription_interval);
                 $item_meta->add('_subscription_length', $subscription_length);
                 $item_meta->add('_subscription_trial_length', $subscription_trial_length);
                 $item_meta->add('_subscription_recurring_amount', $order_item['line_subtotal']);
                 // WC_Subscriptions_Product::get_price() would return a price without filters applied
                 $item_meta->add('_subscription_sign_up_fee', $subscription_sign_up_fee);
                 // Set recurring amounts for the item
                 $item_meta->add('_recurring_line_total', $order_item['line_total']);
                 $item_meta->add('_recurring_line_tax', $order_item['line_tax']);
                 $item_meta->add('_recurring_line_subtotal', $order_item['line_subtotal']);
                 $item_meta->add('_recurring_line_subtotal_tax', $order_item['line_subtotal_tax']);
                 $order_item['item_meta'] = $item_meta->meta;
                 $order_items[$index] = $order_item;
             } else {
                 // Ignoring all advice, upgrading 4 months after version 1.2 was released, and doing it with WC 2.0 installed
                 woocommerce_add_order_item_meta($index, '_subscription_period', $order_subscription_periods[$product_id]);
                 woocommerce_add_order_item_meta($index, '_subscription_interval', $subscription_interval);
                 woocommerce_add_order_item_meta($index, '_subscription_length', $subscription_length);
                 woocommerce_add_order_item_meta($index, '_subscription_trial_length', $subscription_trial_length);
                 woocommerce_add_order_item_meta($index, '_subscription_trial_period', $order_subscription_periods[$product_id]);
                 woocommerce_add_order_item_meta($index, '_subscription_recurring_amount', $order_item['line_subtotal']);
                 woocommerce_add_order_item_meta($index, '_subscription_sign_up_fee', $subscription_sign_up_fee);
                 // Calculated recurring amounts for the item
                 woocommerce_add_order_item_meta($index, '_recurring_line_total', $order_item['line_total']);
                 woocommerce_add_order_item_meta($index, '_recurring_line_tax', $order_item['line_tax']);
                 woocommerce_add_order_item_meta($index, '_recurring_line_subtotal', $order_item['line_subtotal']);
                 woocommerce_add_order_item_meta($index, '_recurring_line_subtotal_tax', $order_item['line_subtotal_tax']);
                 if ($sign_up_fee_total > 0) {
                     // Order totals have changed
                     woocommerce_update_order_item_meta($index, '_line_subtotal', woocommerce_format_decimal($order_item['line_subtotal']));
                     woocommerce_update_order_item_meta($index, '_line_subtotal_tax', woocommerce_format_decimal($order_item['line_subtotal_tax']));
                     woocommerce_update_order_item_meta($index, '_line_total', woocommerce_format_decimal($order_item['line_total']));
                     woocommerce_update_order_item_meta($index, '_line_tax', woocommerce_format_decimal($order_item['line_tax']));
                 }
             }
         }
         // Save the new meta on the order items for WC 1.x (the API functions already saved the data for WC2.x)
         if (false == self::$is_wc_version_2) {
             update_post_meta($order_id, '_order_items', $order_items);
         }
         $upgraded_orders[] = $order_id;
         update_option('wcs_1_2_upgraded_order_ids', $upgraded_orders);
     }
     // Remove the lock on upgrading
     delete_transient('wc_subscriptions_is_upgrading');
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:101,代码来源:class-wc-subscriptions-upgrader.php


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