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

PHP wc_get_order_item_meta函数代码示例

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

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



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

示例1: 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


示例2: sv_wc_pip_document_table_row_cells

/**
 * Filter the document table row cells to add custom column data
 *
 * @param string $table_row_cells The table row cells.
 * @param string $type WC_PIP_Document type
 * @param string $item_id Item id
 * @param array $item Item data
 * @param \WC_Product $product Product object
 * @param \WC_Order $order Order object
 * @return array The filtered table row cells.
 */
function sv_wc_pip_document_table_row_cells($table_row_cells, $document_type, $item_id, $item, $product, $order)
{
    // set custom column content for invoices
    if ('invoice' === $document_type) {
        $table_row_cells['warranty'] = wc_get_order_item_meta($item_id, '_warranty');
    } elseif ('packing-list' === $document_type || 'pick-list' === $document_type) {
        // display the value of the `_warehouse_location` order meta if it exists
        $table_row_cells['warehouse_location'] = $order->warehouse_location;
    }
    return $table_row_cells;
}
开发者ID:skyverge,项目名称:wc-plugins-snippets,代码行数:22,代码来源:custom-columns-warranty-warehouse.php


示例3: process_items

 /**
  * @param $order_id
  */
 public function process_items($order_id)
 {
     $order = new WC_Order($order_id);
     $items = $order->get_items(array('line_item'));
     // check general BooXtream conditions
     $accountkey = $this->settings->get_accountkey();
     if (!is_null($accountkey)) {
         foreach ($items as $item_id => $item) {
             $downloadlinks = wc_get_order_item_meta($item_id, '_bx_downloadlinks', true);
             if (!is_array($downloadlinks) && 'yes' === get_post_meta($item['product_id'], '_bx_booxtreamable', true)) {
                 $this->request_downloadlinks($item['product_id'], $order_id, $item_id);
                 // use this for actual data
             }
         }
     }
     return null;
 }
开发者ID:BooXtream,项目名称:BooXtream-WooCommerce,代码行数:20,代码来源:class-wc-booxtream-order.php


示例4: custom_order_details_page_info

 /**
  * Custom Title In Order View Page
  * @since 1.0
  */
 public function custom_order_details_page_info($order)
 {
     $is_donation = wc_get_order_item_meta($order->id, '_is_donation');
     if ($is_donation === true) {
         echo '<p><strong>' . get_option('wc_quick_donation_project_section_title') . ' :</strong>' . wc_get_order_item_meta($order->id, '_project_details') . '</p>';
     }
 }
开发者ID:reti-senza-frontiere,项目名称:WP-Plugins,代码行数:11,代码来源:woocommerce-quick-donation.php


示例5: get_packages_for_order_item

 /**
  * @param $item_id
  * @return array
  */
 public function get_packages_for_order_item($item_id)
 {
     return wc_get_order_item_meta($item_id, '_fraktguiden_packages', true);
 }
开发者ID:drivdigital,项目名称:bring-fraktguiden-for-woocommerce,代码行数:8,代码来源:class-bring-wc-order-adapter.php


示例6: woo_vou_codes_replace

 /**
  * Voucher Code Shortcode
  * Handles to replace the voucher code in purchase note
  * 
  * @package WooCommerce - PDF Vouchers
  * @since 1.6
  */
 function woo_vou_codes_replace($atts, $content)
 {
     global $woo_vou_order_item, $woo_vou_item_id;
     //Get prefix
     $prefix = WOO_VOU_META_PREFIX;
     // If order item is not empty
     if (!empty($woo_vou_order_item)) {
         //Get voucher codes
         $codes = wc_get_order_item_meta($woo_vou_item_id, $prefix . 'codes');
         $content .= $codes;
     }
     return $content;
 }
开发者ID:flasomm,项目名称:Montkailash,代码行数:20,代码来源:class-woo-vou-shortcodes.php


示例7: afterOrderItemMeta

 /**
  * Print appointment details inside order items in the backend.
  *
  * @param $item_id
  */
 public function afterOrderItemMeta($item_id)
 {
     $data = wc_get_order_item_meta($item_id, 'bookly');
     if ($data) {
         $other_data = $this->getItemData(array(), array('bookly' => $data));
         echo $other_data[0]['name'] . '<br/>' . nl2br($other_data[0]['value']);
     }
 }
开发者ID:patrickcurl,项目名称:monks,代码行数:13,代码来源:AB_WooCommerceController.php


示例8: woocommerce_get_order_item_meta

/**
 * @deprecated
 */
function woocommerce_get_order_item_meta($item_id, $key, $single = true)
{
    return wc_get_order_item_meta($item_id, $key, $single);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php


示例9: filter_qty

 /**
  * @param $line_items
  * @return mixed
  */
 private function filter_qty($line_items)
 {
     foreach ($line_items as &$item) {
         $qty = wc_get_order_item_meta($item['id'], '_qty');
         $item['quantity'] = wc_stock_amount($qty);
     }
     return $line_items;
 }
开发者ID:rpidanny,项目名称:WooCommerce-POS,代码行数:12,代码来源:class-wc-pos-orders.php


示例10: render_column_content

 /**
  * Display the values for the listable columns
  *
  * @since 1.0
  * @param string $column the column name
  */
 public function render_column_content($column)
 {
     global $post, $wpdb;
     foreach (wc_checkout_add_ons()->get_add_ons($post->ID) as $add_on) {
         if ($column == $add_on->get_key()) {
             $query = $wpdb->prepare("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\twoi.order_item_id\n\t\t\t\t\tFROM {$wpdb->prefix}woocommerce_order_itemmeta woim\n\t\t\t\t\tRIGHT JOIN {$wpdb->prefix}woocommerce_order_items woi ON woim.order_item_id = woi.order_item_id\n\t\t\t\t\tWHERE 1=1\n\t\t\t\t\t\tAND woi.order_id = %d\n\t\t\t\t\t\tAND woim.meta_key = '_wc_checkout_add_on_id'\n\t\t\t\t\t\tAND woim.meta_value = %d\n\t\t\t\t\t", $post->ID, $add_on->id);
             $item_id = $wpdb->get_var($query);
             if ($item_id) {
                 switch ($add_on->type) {
                     case 'checkbox':
                         echo wc_get_order_item_meta($item_id, '_wc_checkout_add_on_value', true) ? '&#x2713;' : '';
                         break;
                     case 'file':
                         $file_ids = explode(',', wc_get_order_item_meta($item_id, '_wc_checkout_add_on_value', true));
                         $files_count = count($file_ids);
                         $file_labels = array();
                         echo '<a href="#" class="wc-checkout-add-ons-files-toggle">' . sprintf(_n('%d file', '%d files', $files_count, WC_Checkout_Add_Ons::TEXT_DOMAIN), $files_count) . '</a>';
                         echo '<ul class="wc-checkout-add-ons-files">';
                         foreach ($file_ids as $key => $file_id) {
                             if ($url = get_edit_post_link($file_id)) {
                                 echo '<li><a href="' . esc_url($url) . '">' . esc_html(get_the_title($file_id)) . '</a></li>';
                             } else {
                                 echo '<li>' . __('(File has been removed)', WC_Checkout_Add_Ons::TEXT_DOMAIN) . '</li>';
                             }
                         }
                         echo '</ul>';
                         break;
                     case 'text':
                     case 'textarea':
                         $label = wc_get_order_item_meta($item_id, '_wc_checkout_add_on_label', true);
                         echo $add_on->truncate_label($label);
                         break;
                     default:
                         $label = wc_get_order_item_meta($item_id, '_wc_checkout_add_on_label', true);
                         echo is_array($label) ? implode(', ', $label) : $label;
                 }
             }
             break;
         }
     }
 }
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:47,代码来源:class-wc-checkout-add-ons-shop-order-cpt.php


示例11: woo_vou_process_product_pdf

/**
 * Generate PDF for Voucher
 *
 * Handles to Generate PDF on run time when
 * user will execute the url which is sent to
 * user email with purchase receipt
 *
 * @package WooCommerce - PDF Vouchers
 * @since   1.0.0
 */
function woo_vou_process_product_pdf($productid, $orderid, $item_id = '', $orderdvoucodes = array(), $pdf_args = array())
{
    $prefix = WOO_VOU_META_PREFIX;
    global $current_user, $woo_vou_model;
    //model class
    $model = $woo_vou_model;
    // If pdf argument is not array then make it array
    $pdf_args = !is_array($pdf_args) ? (array) $pdf_args : $pdf_args;
    // Taking voucher key
    if (!empty($pdf_args['pdf_vou_key'])) {
        $pdf_vou_key = $pdf_args['pdf_vou_key'];
    } else {
        $pdf_vou_key = isset($_GET['key']) ? $_GET['key'] : '';
    }
    if (!empty($productid) && !empty($orderid)) {
        // Check product id & order id are not empty
        //get all voucher details from order meta
        $allorderdata = $model->woo_vou_get_all_ordered_data($orderid);
        // Creating order object for order details
        $woo_order = new WC_Order($orderid);
        $woo_order_details = $woo_order;
        $items = $woo_order_details->get_items();
        foreach ($items as $key => $item) {
            $qty = $items[$key]['qty'];
        }
        // Getting product name
        $woo_product_details = $model->woo_vou_get_product_details($orderid, $items);
        // get product
        $product = wc_get_product($productid);
        // if product type is variable then $productid will contain variation id
        $variation_id = $productid;
        // check if product type is variable then we need to take parent id of variation id
        if ($product->is_type('variation') || $product->is_type('variable')) {
            // productid is variation id in case of variable product so we need to take actual product id
            $woo_variation = new WC_Product_Variation($productid);
            $productid = !empty($woo_variation->id) ? $woo_variation->id : $variation_id;
        }
        $product = wc_get_product($productid);
        $duree = get_the_terms($productid, 'pa_duree');
        $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $productid);
        $attachments = get_posts($args);
        if ($attachments) {
            foreach ($attachments as $attachment) {
                $image = wp_get_attachment_image($attachment->ID, 'full');
            }
        }
        // Getting order details
        $buyer_email = $woo_order_details->billing_email;
        $buyer_fname = $woo_order_details->billing_first_name;
        $buyer_lname = $woo_order_details->billing_last_name;
        $buyer_fullname = $buyer_fname . ' ' . $buyer_lname;
        $productname = isset($woo_product_details[$variation_id]) ? $woo_product_details[$variation_id]['product_name'] : '';
        //Added in version 2.3.7 for sold indivdual bug
        $item_key = $item_id;
        if (empty($item_key)) {
            $item_key = isset($woo_product_details[$variation_id]) ? $woo_product_details[$variation_id]['item_key'] : '';
        }
        $variation_data = $model->woo_vou_get_variation_data($woo_order, $item_key);
        $productname = $productname . $variation_data;
        //Get recipient fields
        $recipient_data = $model->woo_vou_get_recipient_data_using_item_key($woo_order, $item_key);
        $productprice = !empty($woo_product_details[$variation_id]['product_formated_price']) ? $woo_product_details[$variation_id]['product_formated_price'] : '';
        //Get voucher codes
        $voucher_codes = wc_get_order_item_meta($item_id, $prefix . 'codes');
        //get all voucher details from order meta
        $allvoucherdata = isset($allorderdata[$productid]) ? $allorderdata[$productid] : array();
        //how to use the voucher details
        $howtouse = isset($allvoucherdata['redeem']) ? $allvoucherdata['redeem'] : '';
        //start date
        $start_date = isset($allvoucherdata['start_date']) ? $allvoucherdata['start_date'] : '';
        //expiry data
        $exp_date = isset($allvoucherdata['exp_date']) ? $allvoucherdata['exp_date'] : '';
        //vou order date
        $orderdate = get_the_time('Y-m-d', $orderid);
        if (!empty($orderdate)) {
            $orderdate = $model->woo_vou_get_date_format($orderdate);
        }
        //vou logo
        $voulogo = isset($allvoucherdata['vendor_logo']) ? $allvoucherdata['vendor_logo'] : '';
        $voulogo = isset($voulogo['src']) && !empty($voulogo['src']) ? $voulogo['src'] : '';
        //vendor logo
        $voulogohtml = '';
        if (!empty($voulogo)) {
            $voulogohtml = '<img src="' . $voulogo . '" alt="" />';
        }
        //site logo
        $vousitelogohtml = '';
        $vou_site_url = get_option('vou_site_logo');
        if (!empty($vou_site_url)) {
            $vousitelogohtml = '<img src="' . $vou_site_url . '" alt="" />';
//.........这里部分代码省略.........
开发者ID:flasomm,项目名称:Montkailash,代码行数:101,代码来源:woo-vou-pdf-process.php


示例12: handle_download

 public function handle_download($query)
 {
     //gets the global query var object
     global $wp_query;
     if ($wp_query->get('bx-download')) {
         $item_id = $wp_query->get('bx-item-id');
         $download_id = $wp_query->get('bx-download-id');
         $bx_links = wc_get_order_item_meta($item_id, '_bx_downloadlinks');
         if (is_array($bx_links)) {
             if ($download_id === wc_get_order_item_meta($item_id, '_bx_epub_link')) {
                 $link = $bx_links['epub'];
             } elseif ($download_id === wc_get_order_item_meta($item_id, '_bx_mobi_link')) {
                 $link = $bx_links['mobi'];
             }
             header('Location: ' . $link);
             exit;
         } else {
             //gets the front page id set in options
             $page_id = get_option('woocommerce_download_processing_page_id');
             if (false === $page_id) {
                 echo '<h1>' . __('Your download is not ready yet', 'woocommerce_booxtream') . '</h1>';
                 echo '<p>' . __('We are currently processing your download, please try again in a few seconds', 'woocommerce_booxtream') . '</p>';
                 exit;
             }
             if (!$query->is_main_query()) {
                 return;
             }
             $query->set('post_type', 'page');
             $query->set('p', $page_id);
             //we remove the actions hooked on the '__after_loop' (post navigation)
             remove_all_actions('__after_loop');
             return $query;
         }
     }
 }
开发者ID:BooXtream,项目名称:BooXtream-WooCommerce,代码行数:35,代码来源:icontact-woocommerce-booxtream.php


示例13: woo_vou_my_pdf_vouchers_download_link

 /**
  * Adding Hooks
  *
  * Adding proper hoocks for the discount codes
  *
  * @package WooCommerce - PDF Vouchers
  * @since   2.3.1
  */
 public function woo_vou_my_pdf_vouchers_download_link($downloads = array())
 {
     //get prefix
     $prefix = WOO_VOU_META_PREFIX;
     if (is_user_logged_in()) {
         //If user is logged in
         //Get user ID
         $user_id = get_current_user_id();
         //Get User Order Arguments
         $args = array('numberposts' => -1, 'meta_key' => '_customer_user', 'meta_value' => $user_id, 'post_type' => WOO_VOU_MAIN_SHOP_POST_TYPE, 'post_status' => array('wc-completed'), 'meta_query' => array(array('key' => $prefix . 'meta_order_details', 'compare' => 'EXISTS')));
         //user orders
         $user_orders = get_posts($args);
         if (!empty($user_orders)) {
             //If orders are not empty
             foreach ($user_orders as $user_order) {
                 //Get order ID
                 $order_id = isset($user_order->ID) ? $user_order->ID : '';
                 if (!empty($order_id)) {
                     //Order it not empty
                     global $vou_order;
                     //Set global order ID
                     $vou_order = $order_id;
                     //Get cart details
                     $cart_details = new Wc_Order($order_id);
                     $order_items = $cart_details->get_items();
                     $order_date = isset($cart_details->order_date) ? $cart_details->order_date : '';
                     $order_date = date('d-m-y', strtotime($order_date));
                     if (!empty($order_items)) {
                         // Check cart details are not empty
                         foreach ($order_items as $item_id => $product_data) {
                             //Get product from Item ( It is required otherwise multipdf voucher link not work )
                             $_product = apply_filters('woocommerce_order_item_product', $cart_details->get_product_from_item($product_data), $product_data);
                             if (!$_product) {
                                 //If product deleted
                                 $download_file_data = array();
                             } else {
                                 //Get download files
                                 $download_file_data = $cart_details->get_item_downloads($product_data);
                             }
                             //Get voucher codes
                             $codes = wc_get_order_item_meta($item_id, $prefix . 'codes');
                             if (!empty($download_file_data) && !empty($codes)) {
                                 //If download exist and code is not empty
                                 foreach ($download_file_data as $key => $download_file) {
                                     //check download key is voucher key or not
                                     $check_key = strpos($key, 'woo_vou_pdf_');
                                     //get voucher number
                                     $voucher_number = str_replace('woo_vou_pdf_', '', $key);
                                     if (empty($voucher_number)) {
                                         //If empty voucher number
                                         $voucher_number = 1;
                                     }
                                     if (!empty($download_file) && $check_key !== false) {
                                         //Get download URL
                                         $download_url = $download_file['download_url'];
                                         //add arguments array
                                         $add_arguments = array('item_id' => $item_id);
                                         //PDF Download URL
                                         $download_url = add_query_arg($add_arguments, $download_url);
                                         //get product name
                                         $product_name = isset($_product->post->post_title) ? $_product->post->post_title : '';
                                         //Download file arguments
                                         $download_args = array('download_url' => $download_url, 'download_name' => $product_name . ' - ' . $download_file['name'] . ' ' . $voucher_number . ' ( ' . $order_date . ' )', 'downloads_remaining' => '');
                                         //append voucher download to downloads array
                                         $downloads[] = $download_args;
                                     }
                                 }
                             }
                         }
                     }
                     //reset global order ID
                     $vou_order = 0;
                 }
             }
         }
     }
     return $downloads;
 }
开发者ID:flasomm,项目名称:Montkailash,代码行数:86,代码来源:class-woo-vou-public.php


示例14: refund_transaction

 /**
  * Refund a transaction
  *
  * @param $order_id
  * @param $refund_id
  *
  * @return bool
  */
 public function refund_transaction($order_id, $refund_id)
 {
     // Get the Taxamo transaction key
     $transaction_key = get_post_meta($order_id, 'taxamo_transaction_key', true);
     // Get refund
     $refund = wc_get_order($refund_id);
     // Get refund line items
     $refund_items = $refund->get_items(array('line_item', 'shipping'));
     // Check & loop
     if (count($refund_items) > 0) {
         foreach ($refund_items as $refund_item) {
             // Get the line key
             $line_key = wc_get_order_item_meta($refund_item['refunded_item_id'], self::OIM_LINE_KEY, true);
             // Only do the refund when the line item exists
             if ('' !== $line_key) {
                 // Get correct amount
                 $amount = abs(isset($refund_item['line_total']) ? $refund_item['line_total'] : (isset($refund_item['cost']) ? $refund_item['cost'] : 0));
                 // Only continue if amount > 0
                 if ($amount > 0) {
                     // Create refund request
                     $refund_request = new WC_TA_Request_Refund($transaction_key, $line_key, $amount);
                     // Do the rquest
                     $refund_request->do_request();
                 }
             }
         }
     }
     // Refund done
     return true;
 }
开发者ID:narendra-addweb,项目名称:MyImmoPix,代码行数:38,代码来源:class-wc-ta-taxamo-manager.php


示例15: recalculate_order

 public function recalculate_order($order_id)
 {
     $order_currency = get_post_meta($order_id, '_order_currency', true);
     //lets avoid recalculation for order which is already in
     if ($order_currency == $this->default_currency or empty($order_currency)) {
         return;
     }
     //***
     $currencies = $this->get_currencies();
     $_woocs_order_rate = get_post_meta($order_id, '_woocs_order_rate', true);
     if (empty($_woocs_order_rate)) {
         $_woocs_order_rate = $currencies[$order_currency]['rate'];
     }
     //***
     update_post_meta($order_id, '_woocs_order_currency', $this->default_currency);
     update_post_meta($order_id, '_order_currency', $this->default_currency);
     update_post_meta($order_id, '_woocs_order_base_currency', $this->default_currency);
     wc_update_order_item_meta($order_id, '_woocs_order_base_currency', $this->default_currency);
     update_post_meta($order_id, '_woocs_order_rate', 1);
     wc_update_order_item_meta($order_id, '_woocs_order_rate', 1);
     update_post_meta($order_id, '_woocs_order_currency_changed_mannualy', time());
     wc_add_order_item_meta($order_id, '_woocs_order_currency_changed_mannualy', time(), true);
     //***
     $_order_shipping = get_post_meta($order_id, '_order_shipping', true);
     update_post_meta($order_id, '_order_shipping', $this->back_convert($_order_shipping, $_woocs_order_rate));
     $_order_total = get_post_meta($order_id, '_order_total', true);
     update_post_meta($order_id, '_order_total', $this->back_convert($_order_total, $_woocs_order_rate));
     $_refund_amount = get_post_meta($order_id, '_refund_amount', true);
     update_post_meta($order_id, '_refund_amount', $this->back_convert($_refund_amount, $_woocs_order_rate));
     $_cart_discount_tax = get_post_meta($order_id, '_cart_discount_tax', true);
     update_post_meta($order_id, '_cart_discount_tax', $this->back_convert($_cart_discount_tax, $_woocs_order_rate));
     $_order_tax = get_post_meta($order_id, '_order_tax', true);
     update_post_meta($order_id, '_order_tax', $this->back_convert($_order_tax, $_woocs_order_rate));
     $_order_shipping_tax = get_post_meta($order_id, '_order_shipping_tax', true);
     update_post_meta($order_id, '_order_shipping_tax', $this->back_convert($_order_shipping_tax, $_woocs_order_rate));
     $_cart_discount = get_post_meta($order_id, '_cart_discount', true);
     update_post_meta($order_id, '_cart_discount', $this->back_convert($_cart_discount, $_woocs_order_rate));
     //***
     global $wpdb;
     $get_items_sql = $wpdb->prepare("SELECT order_item_id,order_item_type FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d ", $order_id);
     $line_items = $wpdb->get_results($get_items_sql, ARRAY_N);
     if (!empty($line_items) and is_array($line_items)) {
         foreach ($line_items as $v) {
             $order_item_id = $v[0];
             $order_item_type = $v[1];
             switch ($order_item_type) {
                 case 'line_item':
                     $amount = wc_get_order_item_meta($order_item_id, '_line_subtotal', true);
                     wc_update_order_item_meta($order_item_id, '_line_subtotal', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $amount = wc_get_order_item_meta($order_item_id, '_line_total', true);
                     wc_update_order_item_meta($order_item_id, '_line_total', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $amount = wc_get_order_item_meta($order_item_id, '_line_subtotal_tax', true);
                     wc_update_order_item_meta($order_item_id, '_line_subtotal_tax', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $amount = wc_get_order_item_meta($order_item_id, '_line_tax', true);
                     wc_update_order_item_meta($order_item_id, '_line_tax', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $_line_tax_data = wc_get_order_item_meta($order_item_id, '_line_tax_data', true);
                     if (!empty($_line_tax_data) and is_array($_line_tax_data)) {
                         foreach ($_line_tax_data as $key => $values) {
                             if (!empty($values)) {
                                 if (is_array($values)) {
                                     foreach ($values as $k => $value) {
                                         if (is_numeric($value)) {
                                             $_line_tax_data[$key][$k] = $this->back_convert($value, $_woocs_order_rate, 2);
                                         }
                                     }
                                 } else {
                                     if (is_numeric($values)) {
                                         $_line_tax_data[$key] = $this->back_convert($values, $_woocs_order_rate, 2);
                                     }
                                 }
                             }
                         }
                     }
                     wc_update_order_item_meta($order_item_id, '_line_tax_data', $_line_tax_data);
                     break;
                 case 'shipping':
                     $amount = wc_get_order_item_meta($order_item_id, 'cost', true);
                     wc_update_order_item_meta($order_item_id, 'cost', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $taxes = wc_get_order_item_meta($order_item_id, 'taxes', true);
                     if (!empty($taxes) and is_array($taxes)) {
                         foreach ($taxes as $key => $values) {
                             if (!empty($values)) {
                                 if (is_array($values)) {
                                     foreach ($values as $k => $value) {
                                         if (is_numeric($value)) {
                                             $taxes[$key][$k] = $this->back_convert($value, $_woocs_order_rate, 2);
                                         }
                                     }
                                 } else {
                                     if (is_numeric($values)) {
                                         $taxes[$key] = $this->back_convert($values, $_woocs_order_rate, 2);
                                     }
                                 }
                             }
                         }
                     }
                     wc_update_order_item_meta($order_item_id, 'taxes', $taxes);
                     break;
                 case 'tax':
                     $amount = wc_get_order_item_meta($order_item_id, 'tax_amount', true);
//.........这里部分代码省略.........
开发者ID:benkhlifafahmi,项目名称:woocomerce-currency-switcher-fix,代码行数:101,代码来源:index.php


示例16: easy_booking_update_order_product

 /**
  *
  * Update order item product when changing booking dates
  *
  * @param int $order_id
  * @param array $posted - Order content
  *
  **/
 public function easy_booking_update_order_product($order_id, $posted)
 {
     $order = new WC_Order($order_id);
     $items = $order->get_items();
     if ($items) {
         foreach ($items as $item_id => $item) {
             $product = $order->get_product_from_item($item);
             if (!$product) {
                 continue;
             }
             $start = wc_get_order_item_meta($item_id, '_ebs_start_format');
             $end = wc_get_order_item_meta($item_id, '_ebs_end_format');
             $product_id = wc_get_order_item_meta($item_id, '_product_id');
             $variation_id = wc_get_order_item_meta($item_id, '_variation_id');
             $id = empty($variation_id) ? $product_id : $variation_id;
             // Is product bookable ?
             $is_bookable = get_post_meta($id, '_booking_option', true);
             if (!empty($start) && !empty($end) || isset($is_bookable) && $is_bookable === 'yes') {
                 if (class_exists('WC_Session')) {
                     $session_data = WC()->session->get_session_data();
                     $order_booking_session = !empty($session_data['order_booking_' . $item_id]) ? WC()->session->get('order_booking_' . $item_id) : '';
                 } else {
                     $order_booking_session = '';
                 }
                 $item_tax_class = $posted['order_item_tax_class'][$item_id];
                 $order_item['quantity'] = wc_get_order_item_meta($item_id, '_qty');
                 if (!empty($order_booking_session)) {
                     $start = $order_booking_session['start'];
                     $end = $order_booking_session['end'];
                     $start_date = $order_booking_session['start_date'];
                     $end_date = $order_booking_session['end_date'];
                     if ($order_booking_session['new_price']) {
                         $new_price = $order_booking_session['new_price'];
                         $subtotal_price = $new_price['subtotal'];
                         $total_price = $new_price['total'];
                     }
                     if (!empty($item_tax_class)) {
                         $tax_subtotal = isset($new_price['tax_subtotal']) ? $new_price['tax_subtotal'] : '';
                         $tax_total = isset($new_price['tax_total']) ? $new_price['tax_total'] : '';
                     }
                     wc_update_order_item_meta($item_id, '_ebs_start_format', $start);
                     wc_update_order_item_meta($item_id, '_ebs_end_format', $end);
                     wc_update_order_item_meta($item_id, '_ebs_start_display', $start_date);
                     wc_update_order_item_meta($item_id, '_ebs_end_display', $end_date);
                     WC()->session->set('order_booking_' . $item_id, '');
                 } else {
                     $order_item['tax_class'] = $item_tax_class;
                     $coupons = $order->get_used_coupons();
                     $item_prices = $this->easy_booking_get_booking_price($product, $item_id, $start, $end, $order_item, $coupons);
                     if ($item_prices) {
                         $subtotal_price = $item_prices['subtotal'];
                         $total_price = $item_prices['total'];
                     }
                     if (!empty($item_tax_class)) {
                         $tax_subtotal = isset($new_price['tax_subtotal']) ? $new_price['tax_subtotal'] : '';
                         $tax_total = isset($new_price['tax_total']) ? $new_price['tax_total'] : '';
                     }
                 }
                 // Update totals
                 if (isset($subtotal_price)) {
                     wc_update_order_item_meta($item_id, '_line_subtotal', wc_format_decimal($subtotal_price));
                 }
                 if (isset($total_price)) {
                     wc_update_order_item_meta($item_id, '_line_total', wc_format_decimal($total_price));
                 }
                 if (!empty($tax_subtotal)) {
                     wc_update_order_item_meta($item_id, '_line_subtotal_tax', wc_format_decimal($tax_subtotal));
                 }
                 if (!empty($tax_total)) {
                     wc_update_order_item_meta($item_id, '_line_tax', wc_format_decimal($tax_total));
                 }
                 if (!empty($tax_subtotal) && !empty($tax_total)) {
                     wc_update_order_item_meta($item_id, '_line_tax_data', array('total' => $tax_total, 'subtotal' => $tax_subtotal));
                 }
                 do_action('easy_booking_update_order_product', $order, $item_id, $order_item);
             }
         }
     }
 }
开发者ID:noikiy,项目名称:woocommerce-easy-booking-system,代码行数:87,代码来源:class-wceb-order.php


示例17: set_line_item

 /**
  * Create or update a line item
  *
  * @since 2.2
  * @param \WC_Order $order
  * @param array $item line item data
  * @param string $action 'create' to add line item or 'update' to update it
  * @throws WC_API_Exception invalid data, server error
  */
 protected function set_line_item($order, $item, $action)
 {
     $creating = 'create' === $action;
     // product is always required
     if (!isset($item['product_id'])) {
         throw new WC_API_Exception('woocommerce_api_invalid_product_id', __('Product ID is required', 'woocommerce'), 400);
     }
     // when updating, ensure product ID provided matches
     if ('update' === $action) {
         $item_product_id = wc_get_order_item_meta($item['id'], '_product_id');
         $item_variation_id = wc_get_order_item_meta($item['id'], '_variation_id');
         if ($item['product_id'] != $item_product_id && $item['product_id'] != $item_variation_id) {
             throw new WC_API_Exception('woocommerce_api_invalid_product_id', __('Product ID provided does not match this line item', 'woocommerce'), 400);
         }
     }
     $product = wc_get_product($item['product_id']);
     // must be a valid WC_Product
     if (!is_object($product)) {
         throw new WC_API_Exception('woocommerce_api_invalid_product', __('Product is invalid', 'woocommerce'), 400);
     }
     // quantity must be positive float
     if (isset($item['quantity']) && floatval($item['quantity']) <= 0) {
         throw new WC_API_Exception('woocommerce_api_invalid_product_quantity', __('Product quantity must be a positive float', 'woocommerce'), 400);
     }
     // quantity is required when creating
     if ($creating && !isset($item['quantity'])) {
         throw new WC_API_Exception('woocommerce_api_invalid_product_quantity', __('Product quantity is required', 'woocommerce'), 400);
     }
     $item_args = array();
     // quantity
     if (isset($item['quantity'])) {
         $item_args['qty'] = $item['quantity'];
     }
     // variations must each have a key & value
     if (isset($item['variations']) && is_array($item['variations'])) {
         foreach ($item['variations'] as $key => $value) {
             if (!$key || !$value) {
                 throw new WC_API_Exception('woocommerce_api_invalid_product_variation', __('The product variation is invalid', 'woocommerce'), 400);
             }
         }
         $item_args['variation'] = $item['variations'];
     }
     // total
     if (isset($item['total'])) {
         $item_args['totals']['total'] = floatval($item['total']);
     }
     // total tax
     if (isset($item['total_tax'])) {
         $item_args['totals']['tax'] = floatval($item['total_tax']);
     }
     // subtotal
     if (isset($item['subtotal'])) {
         $item_args['totals']['subtotal'] = floatval($item['subtotal']);
     }
     // subtotal tax
     if (isset($item['subtotal_tax'])) {
         $item_args['totals']['subtotal_tax'] = floatval($item['subtotal_tax']);
     }
     if ($creating) {
         $item_id = $order->add_product($product, $item_args['qty'], $item_args);
         if (!$item_id) {
             throw new WC_API_Exception('woocommerce_cannot_create_line_item', __('Cannot create line item, try again', 'woocommerce'), 500);
         }
     } else {
         $item_id = $order->update_product($item['id'], $product, $item_args);
         if (!$item_id) {
             throw new WC_API_Exception('woocommerce_cannot_update_line_item', __('Cannot update line item, try again', 'woocommerce'), 500);
         }
     }
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:79,代码来源:class-wc-api-orders.php


示例18: compile_ticket_info_images

 public static function compile_ticket_info_images($current, $oiid, $order_id)
 {
     // do not process this unless the ticket information has been loaded
     if (!is_object($current) || is_wp_error($current)) {
         return $current;
     }
     // create the list of pairs to calculate
     $pairs = array('image_id_left' => self::$options->{'qsot-ticket-image-shown'}, 'image_id_right' => self::$options->{'qsot-ticket-image-shown-right'});
     // calculate each pair
     foreach ($pairs as $key => $setting) {
         switch ($setting) {
             default:
             case 'event':
                 if (isset($current->event, $current->event->image_id)) {
                     $current->{$key} = $current->event->image_id;
                 }
                 break;
             case 'product':
                 $product = wc_get_product(wc_get_order_item_meta($oiid, '_product_id', true));
                 if (is_object($product)) {
                     $current->{$key} = get_post_thumbnail_id($product->id);
                 }
                 break;
             case 'venue':
                 if (isset($current->venue, $current->venue->image_id)) {
                     $current->{$key} = $current->venue->image_id;
                 }
                 break;
             case 'none':
                 $current->{$key} = 0;
                 break;
         }
     }
     return $current;
 }
开发者ID:Jayriq,项目名称:opentickets-community,代码行数:35,代码来源:ticket.class.php


示例19: apply_filters

该文章已有0人参与评论

请发表评论

全部评论

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