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


PHP WC_Order::get_line_subtotal方法代码示例

本文整理汇总了PHP中WC_Order::get_line_subtotal方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_line_subtotal方法的具体用法?PHP WC_Order::get_line_subtotal怎么用?PHP WC_Order::get_line_subtotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Order的用法示例。


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

示例1: woo_vou_get_formatted_product_price

 /**
  * Gets Order product Price in voucher code
  * 
  * @package WooCommerce - PDF Vouchers
  * @since 1.1.0
  */
 public function woo_vou_get_formatted_product_price($orderid, $item, $tax_display = '')
 {
     //Get prefix
     $prefix = WOO_VOU_META_PREFIX;
     //Get Order
     $woo_order = new WC_Order($orderid);
     if (!$tax_display) {
         $tax_display = $woo_order->tax_display_cart;
     }
     if (!isset($item['line_subtotal']) || !isset($item['line_subtotal_tax'])) {
         return '';
     }
     //get multipdf option in ordermeta
     $multiple_pdf = get_post_meta($orderid, $prefix . 'multiple_pdf', true);
     //Get Item quantity
     $item_qty = isset($item['qty']) ? $item['qty'] : '';
     if ('excl' == $tax_display) {
         $ex_tax_label = $woo_order->prices_include_tax ? 1 : 0;
         $line_subtotal = $woo_order->get_line_subtotal($item);
         if ($multiple_pdf == 'yes' && !empty($item_qty)) {
             $line_subtotal = $line_subtotal / $item_qty;
         }
         $subtotal = wc_price($line_subtotal, array('ex_tax_label' => $ex_tax_label, 'currency' => $woo_order->get_order_currency()));
     } else {
         $line_subtotal = $woo_order->get_line_subtotal($item, true);
         if ($multiple_pdf == 'yes' && !empty($item_qty)) {
             $line_subtotal = $line_subtotal / $item_qty;
         }
         $subtotal = wc_price($line_subtotal, array('currency' => $woo_order->get_order_currency()));
     }
     return apply_filters('woo_vou_get_formatted_product_price', $subtotal, $orderid, $item, $tax_display);
 }
开发者ID:flasomm,项目名称:Montkailash,代码行数:38,代码来源:class-woo-vou-model.php

示例2: foreach

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

示例3: get_order_data

 /**
  * Get the order data for the given ID.
  *
  * @since  2.5.0
  * @param  WC_Order $order The order instance
  * @return array
  */
 protected function get_order_data($order)
 {
     $order_post = get_post($order->id);
     $dp = wc_get_price_decimals();
     $order_data = array('id' => $order->id, 'order_number' => $order->get_order_number(), 'created_at' => $this->format_datetime($order_post->post_date_gmt), 'updated_at' => $this->format_datetime($order_post->post_modified_gmt), 'completed_at' => $this->format_datetime($order->completed_date, true), 'status' => $order->get_status(), 'currency' => $order->get_order_currency(), 'total' => wc_format_decimal($order->get_total(), $dp), 'subtotal' => wc_format_decimal($order->get_subtotal(), $dp), 'total_line_items_quantity' => $order->get_item_count(), 'total_tax' => wc_format_decimal($order->get_total_tax(), $dp), 'total_shipping' => wc_format_decimal($order->get_total_shipping(), $dp), 'cart_tax' => wc_format_decimal($order->get_cart_tax(), $dp), 'shipping_tax' => wc_format_decimal($order->get_shipping_tax(), $dp), 'total_discount' => wc_format_decimal($order->get_total_discount(), $dp), 'shipping_methods' => $order->get_shipping_method(), 'payment_details' => array('method_id' => $order->payment_method, 'method_title' => $order->payment_method_title, 'paid' => isset($order->paid_date)), 'billing_address' => array('first_name' => $order->billing_first_name, 'last_name' => $order->billing_last_name, 'company' => $order->billing_company, 'address_1' => $order->billing_address_1, 'address_2' => $order->billing_address_2, 'city' => $order->billing_city, 'state' => $order->billing_state, 'postcode' => $order->billing_postcode, 'country' => $order->billing_country, 'email' => $order->billing_email, 'phone' => $order->billing_phone), 'shipping_address' => array('first_name' => $order->shipping_first_name, 'last_name' => $order->shipping_last_name, 'company' => $order->shipping_company, 'address_1' => $order->shipping_address_1, 'address_2' => $order->shipping_address_2, 'city' => $order->shipping_city, 'state' => $order->shipping_state, 'postcode' => $order->shipping_postcode, 'country' => $order->shipping_country), 'note' => $order->customer_note, 'customer_ip' => $order->customer_ip_address, 'customer_user_agent' => $order->customer_user_agent, 'customer_id' => $order->get_user_id(), 'view_order_url' => $order->get_view_order_url(), 'line_items' => array(), 'shipping_lines' => array(), 'tax_lines' => array(), 'fee_lines' => array(), 'coupon_lines' => array());
     // add line items
     foreach ($order->get_items() as $item_id => $item) {
         $product = $order->get_product_from_item($item);
         $product_id = null;
         $product_sku = null;
         // Check if the product exists.
         if (is_object($product)) {
             $product_id = isset($product->variation_id) ? $product->variation_id : $product->id;
             $product_sku = $product->get_sku();
         }
         $meta = new WC_Order_Item_Meta($item, $product);
         $item_meta = array();
         foreach ($meta->get_formatted(null) as $meta_key => $formatted_meta) {
             $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
         }
         $order_data['line_items'][] = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item, false, false), $dp), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], $dp), 'total' => wc_format_decimal($order->get_line_total($item, false, false), $dp), 'total_tax' => wc_format_decimal($item['line_tax'], $dp), 'price' => wc_format_decimal($order->get_item_total($item, false, false), $dp), 'quantity' => wc_stock_amount($item['qty']), 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : null, 'name' => $item['name'], 'product_id' => $product_id, 'sku' => $product_sku, 'meta' => $item_meta);
     }
     // Add shipping.
     foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) {
         $order_data['shipping_lines'][] = array('id' => $shipping_item_id, 'method_id' => $shipping_item['method_id'], 'method_title' => $shipping_item['name'], 'total' => wc_format_decimal($shipping_item['cost'], $dp));
     }
     // Add taxes.
     foreach ($order->get_tax_totals() as $tax_code => $tax) {
         $order_data['tax_lines'][] = array('id' => $tax->id, 'rate_id' => $tax->rate_id, 'code' => $tax_code, 'title' => $tax->label, 'total' => wc_format_decimal($tax->amount, $dp), 'compound' => (bool) $tax->is_compound);
     }
     // Add fees.
     foreach ($order->get_fees() as $fee_item_id => $fee_item) {
         $order_data['fee_lines'][] = array('id' => $fee_item_id, 'title' => $fee_item['name'], 'tax_class' => !empty($fee_item['tax_class']) ? $fee_item['tax_class'] : null, 'total' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'total_tax' => wc_format_decimal($order->get_line_tax($fee_item), $dp));
     }
     // Add coupons.
     foreach ($order->get_items('coupon') as $coupon_item_id => $coupon_item) {
         $order_data['coupon_lines'][] = array('id' => $coupon_item_id, 'code' => $coupon_item['name'], 'amount' => wc_format_decimal($coupon_item['discount_amount'], $dp));
     }
     $order_data = apply_filters('woocommerce_cli_order_data', $order_data);
     return $this->flatten_array($order_data);
 }
开发者ID:jgcopple,项目名称:drgaryschwantz,代码行数:48,代码来源:class-wc-cli-order.php

示例4: generate_dokuonecheckout_form

        /**
         * Generate form
         *
         * @param mixed $order_id
         * @return string
         */
        public function generate_dokuonecheckout_form($order_id)
        {
            global $woocommerce;
            global $wpdb;
            static $basket;
            $order = new WC_Order($order_id);
            $counter = 0;
            foreach ($order->get_items() as $item) {
                $BASKET = $basket . $item['name'] . ',' . $order->get_item_subtotal($item) . ',' . $item['qty'] . ',' . $order->get_line_subtotal($item) . ';';
            }
            $BASKET = "";
            // Order Items
            if (sizeof($order->get_items()) > 0) {
                foreach ($order->get_items() as $item) {
                    $BASKET .= str_replace(",", "", $item['name']) . "," . number_format($order->get_item_subtotal($item), 2, '.', '') . "," . $item['qty'] . "," . number_format($order->get_item_subtotal($item) * $item['qty'], 2, '.', '') . ";";
                }
            }
            // Shipping Fee
            if ($order->order_shipping > 0) {
                $BASKET .= "Shipping Fee," . number_format($order->order_shipping, 2, '.', '') . ",1," . number_format($order->order_shipping, 2, '.', '') . ";";
            }
            // Tax
            if ($order->get_total_tax() > 0) {
                $BASKET .= "Tax," . $order->get_total_tax() . ",1," . $order->get_total_tax() . ";";
            }
            // Fees
            if (sizeof($order->get_fees()) > 0) {
                $fee_counter = 0;
                foreach ($order->get_fees() as $item) {
                    $fee_counter++;
                    $BASKET .= "Fee Item," . $item['line_total'] . ",1," . $item['line_total'] . ";";
                }
            }
            $BASKET = preg_replace("/([^a-zA-Z0-9.\\-,=:;&% ]+)/", " ", $BASKET);
            $MALL_ID = trim($this->mall_id);
            $SHARED_KEY = trim($this->shared_key);
            $CHAIN = trim($this->chain);
            $URL = $this->url;
            $CURRENCY = 360;
            $TRANSIDMERCHANT = $order_id;
            $NAME = trim($order->billing_first_name . " " . $order->billing_last_name);
            $EMAIL = trim($order->billing_email);
            $ADDRESS = trim($order->billing_address_1 . " " . $order->billing_address_2);
            $CITY = trim($order->billing_city);
            $ZIPCODE = trim($order->billing_postcode);
            $STATE = trim($order->billing_city);
            $REQUEST_DATETIME = date("YmdHis");
            $IP_ADDRESS = $this->getipaddress();
            $PROCESS_DATETIME = date("Y-m-d H:i:s");
            $PROCESS_TYPE = "REQUEST";
            $AMOUNT = number_format($order->order_total, 2, '.', '');
            $PHONE = trim($order->billing_phone);
            $PAYMENT_CHANNEL = "";
            $SESSION_ID = COOKIEHASH;
            $WORDS = sha1(trim($AMOUNT) . trim($MALL_ID) . trim($SHARED_KEY) . trim($TRANSIDMERCHANT));
            $dokuonecheckout_args = array('MALLID' => $MALL_ID, 'CHAINMERCHANT' => $CHAIN, 'AMOUNT' => $AMOUNT, 'PURCHASEAMOUNT' => $AMOUNT, 'TRANSIDMERCHANT' => $TRANSIDMERCHANT, 'WORDS' => $WORDS, 'REQUESTDATETIME' => $REQUEST_DATETIME, 'CURRENCY' => $CURRENCY, 'PURCHASECURRENCY' => $CURRENCY, 'SESSIONID' => $SESSION_ID, 'PAYMENTCHANNEL' => $PAYMENT_CHANNEL, 'NAME' => $NAME, 'EMAIL' => $EMAIL, 'HOMEPHONE' => $PHONE, 'MOBILEPHONE' => $PHONE, 'BASKET' => $BASKET, 'ADDRESS' => $ADDRESS, 'CITY' => $CITY, 'STATE' => $STATE, 'ZIPCODE' => $ZIPCODE);
            $trx['ip_address'] = $IP_ADDRESS;
            $trx['process_type'] = $PROCESS_TYPE;
            $trx['process_datetime'] = $PROCESS_DATETIME;
            $trx['transidmerchant'] = $TRANSIDMERCHANT;
            $trx['amount'] = $AMOUNT;
            $trx['session_id'] = $SESSION_ID;
            $trx['words'] = $WORDS;
            $trx['message'] = "Transaction request start";
            # Insert transaction request to table dokuonecheckout
            $this->add_dokuonecheckout($trx);
            // Form
            $dokuonecheckout_args_array = array();
            foreach ($dokuonecheckout_args as $key => $value) {
                $dokuonecheckout_args_array[] = "<input type='hidden' name='{$key}' value='{$value}' />";
            }
            return '<form action="' . $URL . '" method="post" id="dokuonecheckout_payment_form">' . implode(" \r\n", $dokuonecheckout_args_array) . '<input type="submit" class="button-alt" id="submit_dokuonecheckout_payment_form" value="' . __('Pay via DOKU', 'woocommerce') . '" />
										<!--
										<a class="button cancel" href="' . $order->get_cancel_order_url() . '">' . __('Cancel order &amp; restore cart', 'woocommerce') . '</a>
										-->

										<script type="text/javascript">
										jQuery(function(){
										jQuery("body").block(
										{
												message: "<img src=\\"' . $woocommerce->plugin_url() . '/assets/images/ajax-loader.gif\\" alt=\\"Redirecting...\\" style=\\"float:left; margin-right: 10px;\\" />' . __('Thank you for your order. We are now redirecting you to dokuonecheckout to make payment.', 'woocommerce') . '",
												overlayCSS:
										{
										background: "#fff",
										opacity: 0.6
										},
										css: {
													padding:        20,
													textAlign:      "center",
													color:          "#555",
													border:         "3px solid #aaa",
													backgroundColor:"#fff",
													cursor:         "wait",
													lineHeight:     "32px"
//.........这里部分代码省略.........
开发者ID:jnpkr,项目名称:woocommerce-doku-plugin,代码行数:101,代码来源:dokuonecheckout.php

示例5: custom_process

 public function custom_process($order_id)
 {
     $order = new WC_Order($order_id);
     $items = $order->get_items();
     $index = 1;
     // for each order item
     foreach ($items as $item) {
         $tixids = array();
         $eid = get_post_meta($item['product_id'], '_eventid', true);
         // Make sure these are indeed ticket sales
         //$terms = wp_get_post_terms($item['product_id'], 'product_cat', array('fields'=>'names'));
         // Check if these order items are event ticket items
         if (!empty($eid)) {
             // get order post meta array
             $order_meta = get_post_custom($order_id, true);
             $user_id_ = $order_meta['_customer_user'][0];
             // Specify order type only for ticket sale
             if ($index == 1) {
                 update_post_meta($order_id, '_order_type', 'evotix');
             }
             // get repeat interval for order item
             $item_meta = !empty($item['Event-Time']) ? $item['Event-Time'] : false;
             if ($item_meta) {
                 $ri__ = explode('[RI', $item_meta);
                 $ri_ = explode(']', $ri__[1]);
                 $ri = $ri_[0];
             } else {
                 $ri = 0;
             }
             // Get customer information
             if ($user_id_ == 0) {
                 // checkout without creating account
                 $_user = array('name' => $order_meta['_billing_first_name'][0] . ' ' . $order_meta['_billing_last_name'][0], 'email' => $order_meta['_billing_email'][0]);
             } else {
                 //$myuser_id = $order->user_id;
                 $usermeta = get_user_meta($user_id_);
                 $_user = array('name' => $usermeta['first_name'][0] . ' ' . $usermeta['last_name'][0], 'email' => $usermeta['billing_email'][0]);
             }
             // create new event ticket post
             if ($created_tix_id = $this->create_post()) {
                 $ticket_ids = $ticket_ids_ = array();
                 // variation product
                 if (!empty($item['variation_id'])) {
                     $_product = new WC_Product_Variation($item['variation_id']);
                     $hh = $_product->get_variation_attributes();
                     foreach ($hh as $f => $v) {
                         $type = $v;
                     }
                 } else {
                     $type = 'Normal';
                 }
                 // ticket ID(s)
                 $tid = $created_tix_id . '-' . $order_id . '-' . (!empty($item['variation_id']) ? $item['variation_id'] : $item['product_id']);
                 if ($item['qty'] > 1) {
                     $_tid = '';
                     $str = 'A';
                     for ($x = 0; $x < $item['qty']; $x++) {
                         // each ticket in item
                         $strng = $x == 0 ? $str : ++$str;
                         $ticket_ids[$tid . $strng] = 'check-in';
                         $ticket_ids_[] = $tid . $strng;
                     }
                 } else {
                     // just one ticket
                     $ticket_ids[$tid] = 'check-in';
                     $ticket_ids_[] = $tid;
                 }
                 // save ticket data
                 $this->create_custom_fields($created_tix_id, 'name', $_user['name']);
                 $this->create_custom_fields($created_tix_id, 'email', $_user['email']);
                 $this->create_custom_fields($created_tix_id, 'qty', $item['qty']);
                 $this->create_custom_fields($created_tix_id, 'cost', $order->get_line_subtotal($item));
                 $this->create_custom_fields($created_tix_id, 'type', $type);
                 $this->create_custom_fields($created_tix_id, 'ticket_ids', $ticket_ids);
                 $this->create_custom_fields($created_tix_id, 'wcid', $item['product_id']);
                 $this->create_custom_fields($created_tix_id, 'tix_status', 'none');
                 $this->create_custom_fields($created_tix_id, 'status', 'check-in');
                 $this->create_custom_fields($created_tix_id, '_eventid', $eid);
                 $this->create_custom_fields($created_tix_id, '_orderid', $order_id);
                 $this->create_custom_fields($created_tix_id, '_customerid', $user_id_);
                 $this->create_custom_fields($created_tix_id, 'repeat_interval', $ri);
                 // save event ticket id to order id
                 $tixids = get_post_meta($order_id, '_tixids', true);
                 if (is_array($tixids)) {
                     // if previously saved tixid array
                     $tixids_ = array_merge($tixids, $ticket_ids_);
                 } else {
                     // empty of saved as string
                     $tixids_ = $ticket_ids_;
                 }
                 // save ticket ids as array
                 update_post_meta($order_id, '_tixids', $tixids_);
                 // update product capacity if repeat interval capacity is set
                 // seperately per individual repeat interval
                 $emeta = get_post_meta($eid);
                 if (evo_check_yn($emeta, '_manage_repeat_cap') && evo_check_yn($emeta, 'evcal_repeat') && !empty($emeta['repeat_intervals']) && !empty($emeta['ri_capacity'])) {
                     // repeat capacity values for this event
                     $ri_capacity = unserialize($emeta['ri_capacity'][0]);
                     // repeat capacity for this repeat  interval
                     $capacity_for_this_event = $ri_capacity[$ri];
//.........这里部分代码省略.........
开发者ID:sabdev1,项目名称:ljcdevsab,代码行数:101,代码来源:class-ticket.php

示例6: post_invoice

 /**
  * Translate WooCommerce order into coinsimple invoice and POST invoice to coinsimple.com.
  *
  * @access public
  * @todo determine how to handle order statuses in this function.
  * @param string $order_id rendezvous token that identifies a WooCommerce order.
  * @param $reply passed by reference, returned if successful.
  * @return boolean true if successful or false if unsuccessful.
  */
 public function post_invoice($order_id, &$reply)
 {
     $wc_order = new WC_Order($order_id);
     $invoice = new \CoinSimple\Invoice();
     $invoice->setName($wc_order->billing_first_name . ' ' . $wc_order->billing_last_name);
     $invoice->setEmail($wc_order->billing_email);
     $invoice->setCurrency(strtolower(get_woocommerce_currency()));
     // create line items
     $wc_items = $wc_order->get_items();
     foreach ($wc_items as $wc_item) {
         if (get_option('woocommerce_prices_include_tax') === 'yes') {
             $line_total = $wc_order->get_line_subtotal($wc_item, true, true);
         } else {
             $line_total = $wc_order->get_line_subtotal($wc_item, false, true);
         }
         $item = array("description" => $wc_item['name'], "quantity" => floatval($wc_item['qty']), "price" => round($line_total / $wc_item['qty'], 2));
         $invoice->addItem($item);
     }
     $invoice->setNotes($this->get_option("notes"));
     //tax
     if ($wc_order->get_total_tax() != 0 && get_option('woocommerce_prices_include_tax') !== 'yes') {
         $tax = 0;
         foreach ($wc_order->get_tax_totals() as $value) {
             $tax += $value->amount;
         }
         $tax = round($tax, 2);
         $invoice->addItem(array("description" => "Sales tax", "quantity" => 1, "price" => $tax));
     }
     // shipping
     if ($wc_order->get_total_shipping() != 0) {
         $shipping = $wc_order->get_total_shipping();
         if (get_option('woocommerce_prices_include_tax') === 'yes') {
             $shipping += $wc_order->get_shipping_tax();
         }
         $invoice->addItem(array("description" => "Shipping and handling", "quantity" => 1, "price" => round($shipping, 2)));
     }
     // coupens
     if ($wc_order->get_total_discount() != 0) {
         $invoice->addItem(array("description" => "Discounts", "quantity" => 1, "price" => -round($wc_order->get_total_discount(), 2)));
     }
     // settings part
     $invoice->setCallbackUrl(add_query_arg('wc-api', 'wc_coinsimple', home_url('/')));
     $invoice->setCustom(array("order_id" => $wc_order->id, "order_key" => $wc_order->order_key));
     if ($this->get_option("redirect_url") != "") {
         $invoice->setRedirectUrl($this->get_option("redirect_url"));
     }
     $business = new \CoinSimple\Business($this->get_option("business_id"), $this->get_option('api_key'));
     $res = $business->sendInvoice($invoice);
     if ($res->status == "ok") {
         $reply = $res;
         return true;
     } else {
         return false;
     }
 }
开发者ID:kedamaian,项目名称:coinsimple-woocommerce,代码行数:64,代码来源:wc_coinsimple.php


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