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


PHP WC_Order::get_shipping_tax方法代码示例

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


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

示例1: array

                 //Begränsa längd
                 $product_description = mb_substr($product_description, 0, 149);
             }
             $item_price = number_format($order->get_item_total($item, true) * 100, 0, '', '');
             $cart[] = array('ArticleNumber' => $reference, 'ArticleName' => strip_tags($item_name), 'Description' => $product_description, 'Quantity' => intval($item['qty'] * 100), 'Price' => (int) $item_price, 'VAT' => intval($item_tax_percentage . '00'));
             $totalAmount += $item_price * (int) $item['qty'];
         }
         // End if qty
     }
     // End foreach
 }
 // End if sizeof get_items()
 // We manually calculate the tax percentage here
 if ($order->get_total_shipping() > 0) {
     // Calculate tax percentage
     $shipping_tax_percentage = round($order->get_shipping_tax() / $order->get_total_shipping(), 2) * 100;
 } else {
     $shipping_tax_percentage = 00;
 }
 $shipping_price = number_format(($order->get_total_shipping() + $order->get_shipping_tax()) * 100, 0, '', '');
 $cart[] = array('ArticleNumber' => '999', 'ArticleName' => $order->get_shipping_method(), 'Description' => $order->get_shipping_method(), 'Quantity' => 100, 'Price' => intval($shipping_price), 'VAT' => intval($shipping_tax_percentage . '00'));
 $totalAmount += $shipping_price;
 //Create postData
 $create['MerchantKey'] = $merchantid;
 $create['Checksum'] = SHA1($totalAmount * 100 . $sharedSecret);
 $create['Token'] = strtoupper($storedGet['token']);
 foreach ($cart as $item) {
     $create['Articles'][] = $item;
 }
 // Setup cURL
 $ch = curl_init($updateCheckoutAPI);
开发者ID:Hygglig,项目名称:New_Hygglig_WooCommerce,代码行数:31,代码来源:hygglig-order-update.php

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

示例3: process_payment

 /**
  * Process the payment and return the result
  *
  * @access public
  * @param int $order_id
  * @return array
  */
 public function process_payment($order_id)
 {
     $this->init_mijireh();
     $mj_order = new Mijireh_Order();
     $wc_order = new WC_Order($order_id);
     // Avoid rounding issues altogether by sending the order as one lump
     if (get_option('woocommerce_prices_include_tax') == 'yes') {
         // Don't pass items - Pass 1 item for the order items overall
         $item_names = array();
         if (sizeof($wc_order->get_items()) > 0) {
             foreach ($wc_order->get_items() as $item) {
                 if ($item['qty']) {
                     $item_names[] = $item['name'] . ' x ' . $item['qty'];
                 }
             }
         }
         $mj_order->add_item(sprintf(__('Order %s', 'woocommerce'), $wc_order->get_order_number()) . " - " . implode(', ', $item_names), number_format($wc_order->get_total() - round($wc_order->get_total_shipping() + $wc_order->get_shipping_tax(), 2) + $wc_order->get_order_discount(), 2, '.', ''), 1);
         if ($wc_order->get_total_shipping() + $wc_order->get_shipping_tax() > 0) {
             $mj_order->shipping = number_format($wc_order->get_total_shipping() + $wc_order->get_shipping_tax(), 2, '.', '');
         }
         $mj_order->show_tax = false;
         // No issues when prices exclude tax
     } else {
         // add items to order
         $items = $wc_order->get_items();
         foreach ($items as $item) {
             $product = $wc_order->get_product_from_item($item);
             $mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, false, true), $item['qty'], $product->get_sku());
         }
         // Handle fees
         $items = $wc_order->get_fees();
         foreach ($items as $item) {
             $mj_order->add_item($item['name'], number_format($item['line_total'], 2, '.', ','), 1, '');
         }
         $mj_order->shipping = round($wc_order->get_total_shipping(), 2);
         $mj_order->tax = $wc_order->get_total_tax();
     }
     // set order totals
     $mj_order->total = $wc_order->get_total();
     $mj_order->discount = $wc_order->get_total_discount();
     // add billing address to order
     $billing = new Mijireh_Address();
     $billing->first_name = $wc_order->billing_first_name;
     $billing->last_name = $wc_order->billing_last_name;
     $billing->street = $wc_order->billing_address_1;
     $billing->apt_suite = $wc_order->billing_address_2;
     $billing->city = $wc_order->billing_city;
     $billing->state_province = $wc_order->billing_state;
     $billing->zip_code = $wc_order->billing_postcode;
     $billing->country = $wc_order->billing_country;
     $billing->company = $wc_order->billing_company;
     $billing->phone = $wc_order->billing_phone;
     if ($billing->validate()) {
         $mj_order->set_billing_address($billing);
     }
     // add shipping address to order
     $shipping = new Mijireh_Address();
     $shipping->first_name = $wc_order->shipping_first_name;
     $shipping->last_name = $wc_order->shipping_last_name;
     $shipping->street = $wc_order->shipping_address_1;
     $shipping->apt_suite = $wc_order->shipping_address_2;
     $shipping->city = $wc_order->shipping_city;
     $shipping->state_province = $wc_order->shipping_state;
     $shipping->zip_code = $wc_order->shipping_postcode;
     $shipping->country = $wc_order->shipping_country;
     $shipping->company = $wc_order->shipping_company;
     if ($shipping->validate()) {
         $mj_order->set_shipping_address($shipping);
     }
     // set order name
     $mj_order->first_name = $wc_order->billing_first_name;
     $mj_order->last_name = $wc_order->billing_last_name;
     $mj_order->email = $wc_order->billing_email;
     // add meta data to identify woocommerce order
     $mj_order->add_meta_data('wc_order_id', $order_id);
     // Set URL for mijireh payment notificatoin - use WC API
     $mj_order->return_url = WC()->api_request_url('WC_Gateway_Mijireh');
     // Identify woocommerce
     $mj_order->partner_id = 'woo';
     try {
         $mj_order->create();
         $result = array('result' => 'success', 'redirect' => $mj_order->checkout_url);
         return $result;
     } catch (Mijireh_Exception $e) {
         wc_add_notice(__('Mijireh error:', 'woocommerce') . $e->getMessage() . print_r($mj_order, true), 'error');
     }
 }
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:94,代码来源:class-wc-gateway-mijireh.php

示例4:

 /**
  * Test: get_shipping_tax
  */
 function test_get_shipping_tax()
 {
     $object = new WC_Order();
     $object->set_shipping_tax(5);
     $this->assertEquals(5, $object->get_shipping_tax());
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:9,代码来源:crud.php

示例5: process_payment

 /**
  * Process the payment and return the result
  *
  * @access public
  * @param int $order_id
  * @return array
  */
 public function process_payment($order_id)
 {
     global $woocommerce;
     $this->init_mijireh();
     $mj_order = new Mijireh_Order();
     $wc_order = new WC_Order($order_id);
     // add items to order
     $items = $wc_order->get_items();
     foreach ($items as $item) {
         $product = $wc_order->get_product_from_item($item);
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             $mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, true, false), $item['qty'], $product->get_sku());
         } else {
             $mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, false, false), $item['qty'], $product->get_sku());
         }
     }
     // Handle fees
     $items = $wc_order->get_fees();
     foreach ($items as $item) {
         $mj_order->add_item($item['name'], $item['line_total'], 1, '');
     }
     // add billing address to order
     $billing = new Mijireh_Address();
     $billing->first_name = $wc_order->billing_first_name;
     $billing->last_name = $wc_order->billing_last_name;
     $billing->street = $wc_order->billing_address_1;
     $billing->apt_suite = $wc_order->billing_address_2;
     $billing->city = $wc_order->billing_city;
     $billing->state_province = $wc_order->billing_state;
     $billing->zip_code = $wc_order->billing_postcode;
     $billing->country = $wc_order->billing_country;
     $billing->company = $wc_order->billing_company;
     $billing->phone = $wc_order->billing_phone;
     if ($billing->validate()) {
         $mj_order->set_billing_address($billing);
     }
     // add shipping address to order
     $shipping = new Mijireh_Address();
     $shipping->first_name = $wc_order->shipping_first_name;
     $shipping->last_name = $wc_order->shipping_last_name;
     $shipping->street = $wc_order->shipping_address_1;
     $shipping->apt_suite = $wc_order->shipping_address_2;
     $shipping->city = $wc_order->shipping_city;
     $shipping->state_province = $wc_order->shipping_state;
     $shipping->zip_code = $wc_order->shipping_postcode;
     $shipping->country = $wc_order->shipping_country;
     $shipping->company = $wc_order->shipping_company;
     if ($shipping->validate()) {
         $mj_order->set_shipping_address($shipping);
     }
     // set order name
     $mj_order->first_name = $wc_order->billing_first_name;
     $mj_order->last_name = $wc_order->billing_last_name;
     $mj_order->email = $wc_order->billing_email;
     // set order totals
     $mj_order->total = $wc_order->get_order_total();
     $mj_order->discount = $wc_order->get_total_discount();
     if (get_option('woocommerce_prices_include_tax') == 'yes') {
         $mj_order->shipping = $wc_order->get_shipping() + $wc_order->get_shipping_tax();
         $mj_order->show_tax = false;
     } else {
         $mj_order->shipping = $wc_order->get_shipping();
         $mj_order->tax = $wc_order->get_total_tax();
     }
     // add meta data to identify woocommerce order
     $mj_order->add_meta_data('wc_order_id', $order_id);
     // Set URL for mijireh payment notificatoin - use WC API
     $mj_order->return_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'WC_Gateway_Mijireh', home_url('/')));
     // Identify woocommerce
     $mj_order->partner_id = 'woo';
     try {
         $mj_order->create();
         $result = array('result' => 'success', 'redirect' => $mj_order->checkout_url);
         return $result;
     } catch (Mijireh_Exception $e) {
         $woocommerce->add_error(__('Mijireh error:', 'woocommerce') . $e->getMessage());
     }
 }
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:85,代码来源:class-wc-gateway-mijireh.php

示例6: ConfirmPayment


//.........这里部分代码省略.........
              */
             if (get_option('woocommerce_prices_include_tax') == 'yes') {
                 $product_price = $order->get_item_subtotal($values, true, false);
             } else {
                 $product_price = $order->get_item_subtotal($values, false, true);
             }
             $Item = array('name' => $values['name'], 'desc' => '', 'amt' => $product_price, 'number' => $sku, 'qty' => $qty, 'taxamt' => '', 'itemurl' => '', 'itemcategory' => '', 'itemweightvalue' => '', 'itemweightunit' => '', 'itemheightvalue' => '', 'itemheightunit' => '', 'itemwidthvalue' => '', 'itemwidthunit' => '', 'itemlengthvalue' => '', 'itemlengthunit' => '', 'ebayitemnumber' => '', 'ebayitemauctiontxnid' => '', 'ebayitemorderid' => '', 'ebayitemcartid' => '');
             array_push($PaymentOrderItems, $Item);
             $ITEMAMT += $product_price * $values['qty'];
         }
         /**
          * Add custom Woo cart fees as line items
          */
         foreach (WC()->cart->get_fees() as $fee) {
             $Item = array('name' => $fee->name, 'desc' => '', 'amt' => number_format($fee->amount, 2, '.', ''), 'number' => $fee->id, 'qty' => 1, 'taxamt' => '', 'itemurl' => '', 'itemcategory' => '', 'itemweightvalue' => '', 'itemweightunit' => '', 'itemheightvalue' => '', 'itemheightunit' => '', 'itemwidthvalue' => '', 'itemwidthunit' => '', 'itemlengthvalue' => '', 'itemlengthunit' => '', 'ebayitemnumber' => '', 'ebayitemauctiontxnid' => '', 'ebayitemorderid' => '', 'ebayitemcartid' => '');
             /**
              * The gift wrap amount actually has its own parameter in
              * DECP, so we don't want to include it as one of the line
              * items.
              */
             if ($Item['number'] != 'gift-wrap') {
                 array_push($PaymentOrderItems, $Item);
                 $ITEMAMT += $fee->amount * $Item['qty'];
             }
             $ctr++;
         }
         /*
          * Get discounts
          */
         if ($order->get_cart_discount() > 0) {
             foreach (WC()->cart->get_coupons('cart') as $code => $coupon) {
                 $Item = array('name' => 'Cart Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
                 array_push($PaymentOrderItems, $Item);
             }
             $ITEMAMT -= $order->get_cart_discount();
         }
         if ($order->get_order_discount() > 0) {
             foreach (WC()->cart->get_coupons('order') as $code => $coupon) {
                 $Item = array('name' => 'Order Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
                 array_push($PaymentOrderItems, $Item);
             }
             $ITEMAMT -= $order->get_order_discount();
         }
         /*
          * Set shipping and tax values.
          */
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             $shipping = $order->get_total_shipping() + $order->get_shipping_tax();
             $tax = 0;
         } else {
             $shipping = $order->get_total_shipping();
             $tax = $order->get_total_tax();
         }
         /*
          * Now that we have all items and subtotals
          * we can fill in necessary values.
          */
         $Payment['itemamt'] = number_format($ITEMAMT, 2, '.', '');
         // Required if you specify itemized L_AMT fields. Sum of cost of all items in this order.
         /*
          * Set tax
          */
         if ($tax > 0) {
             $Payment['taxamt'] = number_format($tax, 2, '.', '');
             // Required if you specify itemized L_TAXAMT fields.  Sum of all tax items in this order.
         }
         /*
          * Set shipping
          */
         if ($shipping > 0) {
             $Payment['shippingamt'] = number_format($shipping, 2, '.', '');
             // Total shipping costs for this order.  If you specify SHIPPINGAMT you mut also specify a value for ITEMAMT.
         }
     }
     $Payment['order_items'] = $PaymentOrderItems;
     array_push($Payments, $Payment);
     $UserSelectedOptions = array('shippingcalculationmode' => '', 'insuranceoptionselected' => '', 'shippingoptionisdefault' => '', 'shippingoptionamount' => '', 'shippingoptionname' => '');
     $PayPalRequestData = array('DECPFields' => $DECPFields, 'Payments' => $Payments);
     // Pass data into class for processing with PayPal and load the response array into $PayPalResult
     $PayPalResult = $PayPal->DoExpressCheckoutPayment($PayPalRequestData);
     /*
      * Log API result
      */
     $this->add_log('Test Mode: ' . $this->testmode);
     $this->add_log('Endpoint: ' . $this->API_Endpoint);
     $PayPalRequest = isset($PayPalResult['RAWREQUEST']) ? $PayPalResult['RAWREQUEST'] : '';
     $PayPalResponse = isset($PayPalResult['RAWRESPONSE']) ? $PayPalResult['RAWRESPONSE'] : '';
     $this->add_log('Request: ' . print_r($PayPal->NVPToArray($PayPal->MaskAPIResult($PayPalRequest)), true));
     $this->add_log('Response: ' . print_r($PayPal->NVPToArray($PayPal->MaskAPIResult($PayPalResponse)), true));
     /*
      * Error handling
      */
     if ($PayPal->APICallSuccessful($PayPalResult['ACK'])) {
         $this->remove_session('TOKEN');
     }
     /*
      * Return the class library result array.
      */
     return $PayPalResult;
 }
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:101,代码来源:wc-gateway-paypal-express-angelleye.php

示例7: PayULiveUpdate

 /**
  * Generate the payu button link
  * 
  * @access public
  * @param mixed $order_id
  * @return string
  *
  * docs: http://docs.woothemes.com/wc-apidocs/class-WC_Order.html
  */
 function generate_payu_form($order_id)
 {
     $order = new WC_Order($order_id);
     if ('yes' == $this->debug) {
         $this->log->add('payu', 'Generating payment form for order ' . $order->get_order_number() . '. Notify URL: ' . $this->notify_url);
     }
     require_once 'includes/payu.class.php';
     $config = $this->get_payu_config($order->get_order_currency());
     $lu = new PayULiveUpdate($config);
     if ($this->debug == 'yes') {
         $lu->logger = true;
         $lu->log_path = WC_LOG_DIR;
     }
     // általános megrendelési adatok
     $lu->setField("ORDER_REF", $order->id . '-' . time());
     $lu->setField("ORDER_DATE", date("Y-m-d H:i:s"));
     $lu->setField("PRICES_CURRENCY", $order->get_order_currency());
     $lu->setField("ORDER_PRICE_TYPE", "GROSS");
     $lu->setField("PAY_METHOD", "CCVISAMC");
     $lu->setField("DISCOUNT", round($order->get_total_discount(), 2));
     $lu->setField("ORDER_TIMEOUT", "300");
     $lu->setField("ORDER_SHIPPING", round($order->get_total_shipping() + $order->get_shipping_tax(), 2));
     $lu->setField("LANGUAGE", strtoupper(substr(get_locale(), 0, 2)));
     // átirányítás, adatok feldogozása
     $lu->setField("BACK_REF", esc_url(add_query_arg(array('callback' => 'BACKREF'), $this->notify_url)));
     $lu->setField("TIMEOUT_URL", esc_url(add_query_arg(array('callback' => 'TIMEOUT'), $this->notify_url)));
     // számlázási adatok
     $lu->setField("BILL_FNAME", $order->billing_first_name);
     $lu->setField("BILL_LNAME", $order->billing_last_name);
     $lu->setField("BILL_COMPANY", $order->billing_company);
     $lu->setField("BILL_EMAIL", $order->billing_email);
     $lu->setField("BILL_PHONE", $this->payu_data_validation($order->billing_phone));
     $lu->setField("BILL_ADDRESS", $this->payu_data_validation($order->billing_address_1));
     $lu->setField("BILL_ADDRESS2", $order->billing_address_2);
     $lu->setField("BILL_ZIPCODE", $this->payu_data_validation($order->billing_postcode));
     $lu->setField("BILL_CITY", $this->payu_data_validation($order->billing_city));
     $lu->setField("BILL_STATE", $this->payu_data_validation($order->billing_state));
     $lu->setField("BILL_COUNTRYCODE", $this->payu_data_validation($order->billing_country));
     // szállítási adatok
     $lu->setField("DELIVERY_FNAME", $this->payu_data_validation($order->shipping_first_name));
     $lu->setField("DELIVERY_LNAME", $this->payu_data_validation($order->shipping_last_name));
     $lu->setField("DELIVERY_EMAIL", $order->billing_email);
     $lu->setField("DELIVERY_PHONE", $this->payu_data_validation($order->billing_phone));
     $lu->setField("DELIVERY_ADDRESS", $this->payu_data_validation($order->shipping_address_1));
     $lu->setField("DELIVERY_ADDRESS2", $order->shipping_address_2);
     $lu->setField("DELIVERY_ZIPCODE", $this->payu_data_validation($order->shipping_postcode));
     $lu->setField("DELIVERY_CITY", $this->payu_data_validation($order->shipping_city));
     $lu->setField("DELIVERY_STATE", $this->payu_data_validation($order->shipping_state));
     $lu->setField("DELIVERY_COUNTRYCODE", $this->payu_data_validation($order->shipping_country));
     // termékek meghatározása
     foreach ($order->get_items() as $product) {
         $lu->addProduct(array('name' => $this->payu_str_replace($product['name']), 'group' => 1, 'code' => $this->payu_set_product_code($product), 'info' => '-', 'price' => round(($product['line_subtotal'] + $product['line_subtotal_tax']) / $product['qty'], 2), 'qty' => $product['qty'], 'vat' => 0));
     }
     $display = $lu->createHtmlForm('payu_payment_form', 'button', __('Please click the button below to pay with PayU', 'wc-payu'));
     return $display;
 }
开发者ID:donpapa26,项目名称:bakancslistad,代码行数:65,代码来源:gateway-payu.php

示例8: do_reference_transaction

 /**
  * Charge a payment against a reference token
  *
  * @link https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECReferenceTxns/#id094UM0DA0HS
  * @link https://developer.paypal.com/docs/classic/api/merchant/DoReferenceTransaction_API_Operation_NVP/
  *
  * @param string $reference_id the ID of a refrence object, e.g. billing agreement ID.
  * @param WC_Order $order order object
  * @param array $args {
  *     @type string 'payment_type'         (Optional) Specifies type of PayPal payment you require for the billing agreement. It is one of the following values. 'Any' or 'InstantOnly'. Echeck is not supported for DoReferenceTransaction requests.
  *     @type string 'payment_action'       How you want to obtain payment. It is one of the following values: 'Authorization' - this payment is a basic authorization subject to settlement with PayPal Authorization and Capture; or 'Sale' - This is a final sale for which you are requesting payment.
  *     @type string 'return_fraud_filters' (Optional) Flag to indicate whether you want the results returned by Fraud Management Filters. By default, you do not receive this information.
  * }
  * @since 2.0
  */
 public function do_reference_transaction($reference_id, $order, $args = array())
 {
     $defaults = array('amount' => $order->get_total(), 'payment_type' => 'Any', 'payment_action' => 'Sale', 'return_fraud_filters' => 1, 'notify_url' => WC()->api_request_url('WC_Gateway_Paypal'), 'invoice_number' => wcs_str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number', 'woocommerce-subscriptions'))), 'custom' => json_encode(array('order_id' => $order->id, 'order_key' => $order->order_key)));
     $args = wp_parse_args($args, $defaults);
     $this->set_method('DoReferenceTransaction');
     // set base params
     $this->add_parameters(array('REFERENCEID' => $reference_id, 'BUTTONSOURCE' => 'WooThemes_Cart', 'RETURNFMFDETAILS' => $args['return_fraud_filters'], 'AMT' => $order->get_total(), 'CURRENCYCODE' => $order->get_order_currency(), 'INVNUM' => $args['invoice_number'], 'PAYMENTACTION' => $args['payment_action'], 'NOTIFYURL' => $args['notify_url'], 'CUSTOM' => $args['custom']));
     $order_subtotal = $i = 0;
     $order_items = array();
     // add line items
     foreach ($order->get_items() as $item) {
         $order_items[] = array('NAME' => wcs_get_paypal_item_name($item['name']), 'AMT' => $order->get_item_subtotal($item), 'QTY' => !empty($item['qty']) ? absint($item['qty']) : 1);
         $order_subtotal += $item['line_total'];
     }
     // add fees
     foreach ($order->get_fees() as $fee) {
         $order_items[] = array('NAME' => wcs_get_paypal_item_name($fee['name']), 'AMT' => $fee['line_total'], 'QTY' => 1);
         $order_subtotal += $fee['line_total'];
     }
     // WC 2.3+, no after-tax discounts
     if ($order->get_total_discount() > 0) {
         $order_items[] = array('NAME' => __('Total Discount', 'woocommerce-subscriptions'), 'QTY' => 1, 'AMT' => -$order->get_total_discount());
     }
     if ($order->prices_include_tax) {
         $item_names = array();
         foreach ($order_items as $item) {
             $item_names[] = sprintf('%s x %s', $item['NAME'], $item['QTY']);
         }
         // add a single item for the entire order
         $this->add_line_item_parameters(array('NAME' => sprintf(__('%s - Order', 'woocommerce-subscriptions'), get_option('blogname')), 'DESC' => wcs_get_paypal_item_name(implode(', ', $item_names)), 'AMT' => $order_subtotal + $order->get_cart_tax(), 'QTY' => 1), 0);
         // add order-level parameters - do not send the TAXAMT due to rounding errors
         $this->add_payment_parameters(array('ITEMAMT' => $order_subtotal + $order->get_cart_tax(), 'SHIPPINGAMT' => $order->get_total_shipping() + $order->get_shipping_tax()));
     } else {
         // add individual order items
         foreach ($order_items as $item) {
             $this->add_line_item_parameters($item, $i++);
         }
         // add order-level parameters
         $this->add_payment_parameters(array('ITEMAMT' => $order_subtotal, 'SHIPPINGAMT' => $order->get_total_shipping(), 'TAXAMT' => $order->get_total_tax()));
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:56,代码来源:class-wcs-paypal-reference-transaction-api-request.php

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

示例10: sendCustomerInvoice


//.........这里部分代码省略.........
																				</tr>';
    }
    $invoice_mail_content .= '																		
																	</tbody>
																	<tfoot style="text-align: left;">
																		<tr>
																			<th scope="row" colspan="2">
																				<font align="left">Cart Subtotal:</font>
																			</th>
																			<td>
																				<font align="left">
																					<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_subtotal()) . '</span>
																				</font>
																			</td>
																		</tr>';
    if ($wooCommerceOrderObject->get_total_discount() > 0.0) {
        $invoice_mail_content .= '<tr>
																			<th scope="row" colspan="2">
																				<font align="left">Discount:</font>
																			</th>
																			<td>
																				<font align="left">
																					<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_total_discount()) . '</span>
																				</font>
																			</td>
																		</tr>';
    }
    $invoice_mail_content .= '<tr>
																			<th scope="row" colspan="2">
																				<font align="left">Tax:</font>
																			</th>
																			<td>
																				<font align="left">
																					<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_cart_tax() + $wooCommerceOrderObject->get_shipping_tax()) . '</span>
																				</font>
																			</td>
																		</tr>
																		<tr>
																			<th scope="row" colspan="2">
																				<font align="left">Shipping:</font>
																			</th>
																			<td>
																				<font align="left">
																					<span class="amount">$' . $wooCommerceOrderObject->get_total_shipping() . '</span>&nbsp;<small>via ' . $wooCommerceOrderObject->get_shipping_method() . '</small>
																				</font>
																			</td>
																		</tr>
																		<tr>
																			<th scope="row" colspan="2">
																				<font align="left">Payment Method:</font>
																			</th>
																			<td>
																				<font align="left">' . $wooCommerceOrderObject->payment_method_title . '</font>
																			</td>
																		</tr>
																		<tr>
																			<th scope="row" colspan="2">
																				<font align="left">Order Total:</font>
																			</th>
																			<td>
																				<font align="left">
																					<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_total()) . '</span>
																				</font>
																			</td>
																		</tr>
																	</tfoot>
开发者ID:quadranttech,项目名称:wp-plex,代码行数:67,代码来源:plexsupportforwoocommerce.php


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