本文整理汇总了PHP中wc_round_tax_total函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_round_tax_total函数的具体用法?PHP wc_round_tax_total怎么用?PHP wc_round_tax_total使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_round_tax_total函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: CallSetExpressCheckout
/**
* CallSetExpressCheckout
*
* Makes a request to PayPal's SetExpressCheckout API
* to setup the checkout and obtain a token.
*
* @paymentAmount (double) Total payment amount of the order.
* @returnURL (string) URL for PayPal to send the buyer to after review and continue from PayPal.
* @cancelURL (string) URL for PayPal to send the buyer to if they cancel the payment.
*/
function CallSetExpressCheckout($paymentAmount, $returnURL, $cancelURL, $usePayPalCredit = false, $posted)
{
/*
* Display message to user if session has expired.
*/
if (sizeof(WC()->cart->get_cart()) == 0) {
$ms = sprintf(__('Sorry, your session has expired. <a href=%s>Return to homepage →</a>', 'paypal-for-woocommerce'), '"' . home_url() . '"');
$set_ec_message = apply_filters('angelleye_set_ec_message', $ms);
wc_add_notice($set_ec_message, "error");
}
/*
* Check if the PayPal class has already been established.
*/
if (!class_exists('Angelleye_PayPal')) {
require_once 'lib/angelleye/paypal-php-library/includes/paypal.class.php';
}
/*
* Create PayPal object.
*/
$PayPalConfig = array('Sandbox' => $this->testmode == 'yes' ? TRUE : FALSE, 'APIUsername' => $this->api_username, 'APIPassword' => $this->api_password, 'APISignature' => $this->api_signature);
$PayPal = new Angelleye_PayPal($PayPalConfig);
/**
* Prepare PayPal request data.
*/
/**
* If Gift Wrap options are enabled, then MAXAMT is required
* in SetExpressCheckout.
*
* https://github.com/angelleye/paypal-woocommerce/issues/142
*/
if ($this->gift_wrap_enabled == 'yes') {
$maxAmount = $paymentAmount * 2;
$maxAmount = $maxAmount + $this->gift_wrap_amount;
$maxAmount = number_format($maxAmount, 2, '.', '');
} else {
$maxAmount = '';
}
$SECFields = array('token' => '', 'maxamt' => $maxAmount, 'returnurl' => urldecode($returnURL), 'cancelurl' => urldecode($cancelURL), 'callback' => '', 'callbacktimeout' => '', 'callbackversion' => '', 'reqconfirmshipping' => '', 'noshipping' => '', 'allownote' => '', 'addroverride' => '', 'localecode' => $this->use_wp_locale_code == 'yes' && get_locale() != '' ? get_locale() : '', 'pagestyle' => '', 'hdrimg' => $this->checkout_logo_hdrimg, 'logourl' => $this->checkout_logo, 'hdrbordercolor' => '', 'hdrbackcolor' => '', 'payflowcolor' => '', 'skipdetails' => $this->skip_final_review == 'yes' ? '1' : '0', 'email' => '', 'channeltype' => '', 'giropaysuccessurl' => '', 'giropaycancelurl' => '', 'banktxnpendingurl' => '', 'brandname' => $this->brand_name, 'customerservicenumber' => $this->customer_service_number, 'buyeremailoptionenable' => '', 'surveyquestion' => '', 'surveyenable' => '', 'totaltype' => '', 'notetobuyer' => '', 'buyerid' => '', 'buyerusername' => '', 'buyerregistrationdate' => '', 'allowpushfunding' => '', 'taxidtype' => '', 'taxid' => '');
/**
* If Gift Wrap options are enabled, add them to SEC
*/
if (strtolower($this->gift_wrap_enabled) == 'yes') {
$SECFields['giftwrapenable'] = '1';
// Enable gift wrap widget on the PayPal Review page. Allowable values are 0 and 1.
$SECFields['giftmessageenable'] = $this->gift_message_enabled ? '1' : '';
// Enable gift message widget on the PayPal Review page. Allowable values are 0 and 1
$SECFields['giftreceiptenable'] = $this->gift_receipt_enabled ? '1' : '';
// Enable gift receipt widget on the PayPal Review page. Allowable values are 0 and 1
$SECFields['giftwrapname'] = $this->gift_wrap_name;
// Label for the gift wrap option such as "Box with ribbon". 25 char max.
$SECFields['giftwrapamount'] = $this->gift_wrap_amount;
// Amount charged for gift-wrap service.
}
/**
* If PayPal Credit is being used, override the necessary parameters
*/
if ($usePayPalCredit) {
$SECFields['solutiontype'] = 'Sole';
$SECFields['landingpage'] = 'Billing';
$SECFields['userselectedfundingsource'] = 'BML';
} elseif (strtolower($this->paypal_account_optional) == 'yes' && strtolower($this->landing_page) == 'billing') {
$SECFields['solutiontype'] = 'Sole';
$SECFields['landingpage'] = 'Billing';
$SECFields['userselectedfundingsource'] = 'CreditCard';
} elseif (strtolower($this->paypal_account_optional) == 'yes' && strtolower($this->landing_page) == 'login') {
$SECFields['solutiontype'] = 'Sole';
$SECFields['landingpage'] = 'Login';
}
// Basic array of survey choices. Nothing but the values should go in here.
$SurveyChoices = array('Choice 1', 'Choice2', 'Choice3', 'etc');
/*
* Get tax amount.
*/
if (get_option('woocommerce_prices_include_tax') == 'yes') {
$shipping = WC()->cart->shipping_total + WC()->cart->shipping_tax_total;
$tax = '0.00';
} else {
$shipping = WC()->cart->shipping_total;
$tax = WC()->cart->get_taxes_total();
}
if ('yes' === get_option('woocommerce_calc_taxes') && 'yes' === get_option('woocommerce_prices_include_tax')) {
$tax = wc_round_tax_total(WC()->cart->tax_total + WC()->cart->shipping_tax_total);
}
$Payments = array();
$Payment = array('amt' => number_format(WC()->cart->total, 2, '.', ''), 'currencycode' => get_woocommerce_currency(), 'shippingamt' => number_format($shipping, 2, '.', ''), 'shippingdiscamt' => '', 'insuranceamt' => '', 'insuranceoptionoffered' => '', 'handlingamt' => '', 'taxamt' => number_format($tax, 2, '.', ''), 'desc' => '', 'custom' => '', 'invnum' => '', 'notifyurl' => '', 'shiptoname' => '', 'shiptostreet' => '', 'shiptostreet2' => '', 'shiptocity' => '', 'shiptostate' => '', 'shiptozip' => '', 'shiptocountrycode' => '', 'shiptophonenum' => '', 'notetext' => '', 'allowedpaymentmethod' => '', 'paymentaction' => $this->payment_action == 'Authorization' ? 'Authorization' : 'Sale', 'paymentrequestid' => '', 'sellerpaypalaccountid' => '');
/**
* If checkout like regular payment
*/
if (!empty($posted) && WC()->cart->needs_shipping()) {
$SECFields['addroverride'] = 1;
//.........这里部分代码省略.........
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:101,代码来源:wc-gateway-paypal-express-angelleye.php
示例2: get_taxes_total
/**
* Get tax row amounts with or without compound taxes includes.
*
* @param bool $compound True if getting compound taxes
* @param bool $display True if getting total to display
* @return float price
*/
public function get_taxes_total($compound = true, $display = true)
{
$total = 0;
foreach ($this->taxes as $key => $tax) {
if (!$compound && WC_Tax::is_compound($key)) {
continue;
}
$total += $tax;
}
foreach ($this->shipping_taxes as $key => $tax) {
if (!$compound && WC_Tax::is_compound($key)) {
continue;
}
$total += $tax;
}
if ($display) {
$total = wc_round_tax_total($total);
}
return apply_filters('woocommerce_cart_taxes_total', $total, $compound, $display, $this);
}
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:27,代码来源:class-wc-cart.php
示例3: get_line_tax
/**
* Calculate line tax - useful for gateways.
*
* @param mixed $item
* @return float
*/
public function get_line_tax($item)
{
return apply_filters('woocommerce_order_amount_line_tax', wc_round_tax_total($item['line_tax']), $item, $this);
}
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:10,代码来源:abstract-wc-order.php
示例4: woocommerce_round_tax_total
/**
* @deprecated
*/
function woocommerce_round_tax_total($tax)
{
return wc_round_tax_total($tax);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php
示例5: get_tax_refunded_for_item
/**
* Get the refunded amount for a line item.
*
* @param int $item_id ID of the item we're checking
* @param int $tax_id ID of the tax we're checking
* @param string $item_type type of the item we're checking, if not a line_item
* @return double
*/
public function get_tax_refunded_for_item($item_id, $tax_id, $item_type = 'line_item')
{
$total = 0;
foreach ($this->get_refunds() as $refund) {
foreach ($refund->get_items($item_type) as $refunded_item) {
if (isset($refunded_item['refunded_item_id']) && $refunded_item['refunded_item_id'] == $item_id) {
switch ($item_type) {
case 'shipping':
$tax_data = maybe_unserialize($refunded_item['taxes']);
if (isset($tax_data[$tax_id])) {
$total += $tax_data[$tax_id];
}
break;
default:
$tax_data = maybe_unserialize($refunded_item['line_tax_data']);
if (isset($tax_data['total'][$tax_id])) {
$total += $tax_data['total'][$tax_id];
}
break;
}
}
}
}
return wc_round_tax_total($total) * -1;
}
开发者ID:magicdustwebsites,项目名称:woocommerce,代码行数:33,代码来源:class-wc-order.php
示例6: isset
</div>
</td>
<?php
if (empty($legacy_order) && 'yes' == get_option('woocommerce_calc_taxes')) {
$shipping_taxes = isset($item['taxes']) ? $item['taxes'] : '';
$tax_data = maybe_unserialize($shipping_taxes);
foreach ($order_taxes as $tax_item) {
$tax_item_id = $tax_item['rate_id'];
$tax_item_total = isset($tax_data[$tax_item_id]) ? $tax_data[$tax_item_id] : '';
?>
<td class="line_tax" width="1%">
<div class="view">
<?php
echo '' != $tax_item_total ? wc_price(wc_round_tax_total($tax_item_total)) : '–';
if ($refunded = $order->get_tax_refunded_for_item($item_id, $tax_item_id, 'shipping')) {
echo '<small class="refunded">-' . wc_price($refunded) . '</small>';
}
?>
</div>
<div class="edit" style="display: none;">
<input type="text" name="shipping_taxes[<?php
echo absint($item_id);
?>
][<?php
echo absint($tax_item_id);
?>
]" placeholder="<?php
echo wc_format_localized_price(0);
?>
开发者ID:tleonard2,项目名称:durablegbFeb,代码行数:31,代码来源:html-order-shipping.php
示例7: isset
" class="refund_line_total wc_input_price" />
</div>
</td>
<?php
if (empty($legacy_order) && wc_tax_enabled()) {
$shipping_taxes = isset($item['taxes']) ? $item['taxes'] : '';
$tax_data = maybe_unserialize($shipping_taxes);
foreach ($order_taxes as $tax_item) {
$tax_item_id = $tax_item['rate_id'];
$tax_item_total = isset($tax_data[$tax_item_id]) ? $tax_data[$tax_item_id] : '';
?>
<td class="line_tax" width="1%">
<div class="view">
<?php
echo '' != $tax_item_total ? wc_price(wc_round_tax_total($tax_item_total), array('currency' => $order->get_order_currency())) : '–';
if ($refunded = $order->get_tax_refunded_for_item($item_id, $tax_item_id, 'shipping')) {
echo '<small class="refunded">-' . wc_price($refunded, array('currency' => $order->get_order_currency())) . '</small>';
}
?>
</div>
<div class="edit" style="display: none;">
<input type="text" name="shipping_taxes[<?php
echo absint($item_id);
?>
][<?php
echo esc_attr($tax_item_id);
?>
]" placeholder="<?php
echo wc_format_localized_price(0);
?>
开发者ID:abesamislyndon,项目名称:femaccms,代码行数:31,代码来源:html-order-shipping.php
示例8: ajax_update_recurring_tax
/**
* Update recurring line taxes via AJAX
* @see WC_Subscriptions_Order::calculate_recurring_line_taxes()
*
* @since 4.4
* @return JSON object with updated tax data
*/
public static function ajax_update_recurring_tax()
{
global $wpdb;
$woo_22_plus = version_compare(WOOCOMMERCE_VERSION, '2.2', '>=');
check_ajax_referer('woocommerce-subscriptions', 'security');
$order_id = absint($_POST['order_id']);
$country = strtoupper(esc_attr($_POST['country']));
// Step out of the way if the customer is not located in the US
if ($country != 'US') {
return;
}
$shipping = $_POST['shipping'];
$line_subtotal = isset($_POST['line_subtotal']) ? esc_attr($_POST['line_subtotal']) : 0;
$line_total = isset($_POST['line_total']) ? esc_attr($_POST['line_total']) : 0;
// Set up WC_WooTax_Order object
$order = self::get_order($order_id);
// We only need to instantiate a WC_Tax object if we are using WooCommerce < 2.3
if (!$woo_22_plus) {
$tax = new WC_Tax();
}
$taxes = $shipping_taxes = array();
$return = array();
$item_data = array();
$type_array = array();
$product_id = '';
if (isset($_POST['order_item_id'])) {
$product_id = woocommerce_get_order_item_meta($_POST['order_item_id'], '_product_id');
} elseif (isset($_POST['product_id'])) {
$product_id = esc_attr($_POST['product_id']);
}
if (!empty($product_id) && WC_Subscriptions_Product::is_subscription($product_id)) {
// Get product details
$product = WC_Subscriptions::get_product($product_id);
// Add product to items array
$tic = get_post_meta($product->id, 'wootax_tic', true);
$item_info = array('Index' => '', 'ItemID' => isset($_POST['order_item_id']) ? $_POST['order_item_id'] : $product_id, 'Qty' => 1, 'Price' => $line_subtotal > 0 ? $line_subtotal : $product->get_price(), 'Type' => 'cart');
if (!empty($tic) && $tic) {
$item_info['TIC'] = $tic;
}
$item_data[] = $item_info;
$type_array[$_POST['order_item_id']] = 'cart';
// Add shipping to items array
if ($shipping > 0) {
$item_data[] = array('Index' => '', 'ItemID' => WT_SHIPPING_ITEM, 'TIC' => WT_SHIPPING_TIC, 'Qty' => 1, 'Price' => $shipping, 'Type' => 'shipping');
$type_array[WT_SHIPPING_ITEM] = 'shipping';
}
// Issue Lookup request
$res = $order->do_lookup($item_data, $type_array, true);
if (is_array($res)) {
$return['recurring_shipping_tax'] = 0;
$return['recurring_line_subtotal_tax'] = 0;
$return['recurring_line_tax'] = 0;
foreach ($res as $item) {
$item_id = $item->ItemID;
$item_tax = $item->TaxAmount;
if ($item_id == WT_SHIPPING_ITEM) {
$return['recurring_shipping_tax'] += $item_tax;
} else {
$return['recurring_line_subtotal_tax'] += $item_tax;
$return['recurring_line_tax'] += $item_tax;
}
}
$taxes[WT_RATE_ID] = $return['recurring_line_tax'];
$shipping_taxes[WT_RATE_ID] = $return['recurring_shipping_tax'];
// Get tax rates
$tax_codes = array(WT_RATE_ID => apply_filters('wootax_rate_code', 'WOOTAX-RATE-DO-NOT-REMOVE'));
// Remove old tax rows
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = 'recurring_tax' )", $order_id));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = 'recurring_tax'", $order_id));
// Now merge to keep tax rows
ob_start();
foreach (array_keys($taxes + $shipping_taxes) as $key) {
$item = array();
$item['rate_id'] = $key;
$item['name'] = $tax_codes[$key];
$item['label'] = $woo_22_plus ? WC_Tax::get_rate_label($key) : $tax->get_rate_label($key);
$item['compound'] = $woo_22_plus ? WC_Tax::is_compound($key) : $tax->is_compound($key) ? 1 : 0;
$item['tax_amount'] = wc_round_tax_total(isset($taxes[$key]) ? $taxes[$key] : 0);
$item['shipping_tax_amount'] = wc_round_tax_total(isset($shipping_taxes[$key]) ? $shipping_taxes[$key] : 0);
if (!$item['label']) {
$item['label'] = WC()->countries->tax_or_vat();
}
// Add line item
$item_id = woocommerce_add_order_item($order_id, array('order_item_name' => $item['name'], 'order_item_type' => 'recurring_tax'));
// Add line item meta
if ($item_id) {
woocommerce_add_order_item_meta($item_id, 'rate_id', $item['rate_id']);
woocommerce_add_order_item_meta($item_id, 'label', $item['label']);
woocommerce_add_order_item_meta($item_id, 'compound', $item['compound']);
woocommerce_add_order_item_meta($item_id, 'tax_amount', $item['tax_amount']);
woocommerce_add_order_item_meta($item_id, 'shipping_tax_amount', $item['shipping_tax_amount']);
}
include plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/admin/post-types/writepanels/order-tax-html.php';
//.........这里部分代码省略.........
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:101,代码来源:class-wt-orders.php
示例9: get_orders_csv_row
/**
* Get the order data for a single CSV row
*
* Note items are keyed according to the column header keys above so these can be modified using
* the provider filter without needing to worry about the array order
*
* @since 3.0
* @param int $order_id the WC_Order ID
* @return array order data in the format key => content
*/
private function get_orders_csv_row($order_id)
{
$order = wc_get_order($order_id);
$line_items = $shipping_items = $fee_items = $tax_items = $coupon_items = array();
// get line items
foreach ($order->get_items() as $item_id => $item) {
$product = $order->get_product_from_item($item);
if (!is_object($product)) {
$product = new WC_Product(0);
}
$item_meta = new WC_Order_Item_Meta(SV_WC_Plugin_Compatibility::is_wc_version_gte_2_4() ? $item : $item['item_meta']);
$meta = $item_meta->display(true, true);
if ($meta) {
// remove newlines
$meta = str_replace(array("\r", "\r\n", "\n"), '', $meta);
// switch reserved chars (:;|) to =
$meta = str_replace(array(': ', ':', ';', '|'), '=', $meta);
}
$line_item = array('name' => html_entity_decode($product->get_title() ? $product->get_title() : $item['name'], ENT_NOQUOTES, 'UTF-8'), 'sku' => $product->get_sku(), 'quantity' => $item['qty'], 'total' => wc_format_decimal($order->get_line_total($item), 2), 'refunded' => wc_format_decimal($order->get_total_refunded_for_item($item_id), 2), 'meta' => html_entity_decode($meta, ENT_NOQUOTES, 'UTF-8'));
// add line item tax
$line_tax_data = isset($item['line_tax_data']) ? $item['line_tax_data'] : array();
$tax_data = maybe_unserialize($line_tax_data);
$line_item['tax'] = isset($tax_data['total']) ? wc_format_decimal(wc_round_tax_total(array_sum((array) $tax_data['total'])), 2) : '';
/**
* CSV Order Export Line Item.
*
* Filter the individual line item entry for the default export
*
* @since 3.0.6
* @param array $line_item {
* line item data in key => value format
* the keys are for convenience and not used for exporting. Make
* sure to prefix the values with the desired line item entry name
* }
*
* @param array $item WC order item data
* @param WC_Product $product the product
* @param WC_Order $order the order
* @param \WC_Customer_Order_CSV_Export_Generator $this, generator instance
*/
$line_item = apply_filters('wc_customer_order_csv_export_order_line_item', $line_item, $item, $product, $order, $this);
if ('default_one_row_per_item' !== $this->order_format && is_array($line_item)) {
foreach ($line_item as $name => $value) {
$line_item[$name] = $name . ':' . $value;
}
$line_item = implode('|', $line_item);
}
if ($line_item) {
$line_items[] = $line_item;
}
}
foreach ($order->get_shipping_methods() as $_ => $shipping_item) {
$shipping_items[] = implode('|', array('method:' . $shipping_item['name'], 'total:' . wc_format_decimal($shipping_item['cost'], 2)));
}
// get fee items & total
$fee_total = 0;
$fee_tax_total = 0;
foreach ($order->get_fees() as $fee_id => $fee) {
$fee_items[] = implode('|', array('name:' . $fee['name'], 'total:' . wc_format_decimal($fee['line_total'], 2), 'tax:' . wc_format_decimal($fee['line_tax'], 2)));
$fee_total += $fee['line_total'];
$fee_tax_total += $fee['line_tax'];
}
// get tax items
foreach ($order->get_tax_totals() as $tax_code => $tax) {
$tax_items[] = implode('|', array('code:' . $tax_code, 'total:' . wc_format_decimal($tax->amount, 2)));
}
// add coupons
foreach ($order->get_items('coupon') as $_ => $coupon_item) {
$coupon = new WC_Coupon($coupon_item['name']);
$coupon_post = get_post($coupon->id);
$coupon_items[] = implode('|', array('code:' . $coupon_item['name'], 'description:' . (is_object($coupon_post) ? $coupon_post->post_excerpt : ''), 'amount:' . wc_format_decimal($coupon_item['discount_amount'], 2)));
}
$order_data = array('order_id' => $order->id, 'order_number' => $order->get_order_number(), 'order_date' => $order->order_date, 'status' => $order->get_status(), 'shipping_total' => $order->get_total_shipping(), 'shipping_tax_total' => wc_format_decimal($order->get_shipping_tax(), 2), 'fee_total' => wc_format_decimal($fee_total, 2), 'fee_tax_total' => wc_format_decimal($fee_tax_total, 2), 'tax_total' => wc_format_decimal($order->get_total_tax(), 2), 'cart_discount' => SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3() ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_cart_discount(), 2), 'order_discount' => SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3() ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_order_discount(), 2), 'discount_total' => wc_format_decimal($order->get_total_discount(), 2), 'order_total' => wc_format_decimal($order->get_total(), 2), 'refunded_total' => wc_format_decimal($order->get_total_refunded(), 2), 'order_currency' => $order->get_order_currency(), 'payment_method' => $order->payment_method, 'shipping_method' => $order->get_shipping_method(), 'customer_id' => $order->get_user_id(), 'billing_first_name' => $order->billing_first_name, 'billing_last_name' => $order->billing_last_name, 'billing_company' => $order->billing_company, 'billing_email' => $order->billing_email, 'billing_phone' => $order->billing_phone, 'billing_address_1' => $order->billing_address_1, 'billing_address_2' => $order->billing_address_2, 'billing_postcode' => $order->billing_postcode, 'billing_city' => $order->billing_city, 'billing_state' => $order->billing_state, 'billing_country' => $order->billing_country, 'shipping_first_name' => $order->shipping_first_name, 'shipping_last_name' => $order->shipping_last_name, 'shipping_company' => $order->shipping_company, 'shipping_address_1' => $order->shipping_address_1, 'shipping_address_2' => $order->shipping_address_2, 'shipping_postcode' => $order->shipping_postcode, 'shipping_city' => $order->shipping_city, 'shipping_state' => $order->shipping_state, 'shipping_country' => $order->shipping_country, 'customer_note' => $order->customer_note, 'shipping_items' => implode(';', $shipping_items), 'fee_items' => implode(';', $fee_items), 'tax_items' => implode(';', $tax_items), 'coupon_items' => implode(';', $coupon_items), 'order_notes' => implode('|', $this->get_order_notes($order)), 'download_permissions' => $order->download_permissions_granted ? $order->download_permissions_granted : 0);
if ('default_one_row_per_item' === $this->order_format) {
$new_order_data = array();
foreach ($line_items as $item) {
$order_data['item_name'] = $item['name'];
$order_data['item_sku'] = $item['sku'];
$order_data['item_quantity'] = $item['quantity'];
$order_data['item_tax'] = $item['tax'];
$order_data['item_total'] = $item['total'];
$order_data['item_refunded'] = $item['refunded'];
$order_data['item_meta'] = $item['meta'];
/**
* CSV Order Export Row for One Row per Item.
*
* Filter the individual row data for the order export
*
* @since 3.3.0
* @param array $order_data {
//.........这里部分代码省略.........
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:101,代码来源:class-wc-customer-order-csv-export-generator.php
示例10: wc_price
" class="line_total wc_input_price" /></label>
</div>
</td>
<?php
if (get_option('woocommerce_calc_taxes') == 'yes') {
?>
<td class="line_tax" width="1%">
<div class="view">
<?php
if (isset($item['line_tax'])) {
if (isset($item['line_subtotal_tax']) && $item['line_subtotal_tax'] != $item['line_tax']) {
echo '<del>' . wc_price(wc_round_tax_total($item['line_subtotal_tax'])) . '</del> ';
}
echo wc_price(wc_round_tax_total($item['line_tax']));
}
?>
</div>
<div class="edit" style="display:none">
<span class="subtotal"><input type="text" name="line_subtotal_tax[<?php
echo absint($item_id);
?>
]" placeholder="<?php
echo wc_format_localized_price(0);
?>
" value="<?php
if (isset($item['line_subtotal_tax'])) {
echo esc_attr(wc_format_localized_price($item['line_subtotal_tax']));
}
?>
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:31,代码来源:html-order-item.php
示例11: get_main_chart
/**
* Get the main chart
*
* @return string
*/
public function get_main_chart()
{
global $wpdb;
$tax_rows = $this->get_order_report_data(array('data' => array('order_item_name' => array('type' => 'order_item', 'function' => '', 'name' => 'tax_rate'), 'tax_amount' => array('type' => 'order_item_meta', 'order_item_type' => 'tax', 'function' => '', 'name' => 'tax_amount'), 'shipping_tax_amount' => array('type' => 'order_item_meta', 'order_item_type' => 'tax', 'function' => '', 'name' => 'shipping_tax_amount'), 'rate_id' => array('type' => 'order_item_meta', 'order_item_type' => 'tax', 'function' => '', 'name' => 'rate_id'), 'order_id' => array('type' => 'order_item', 'function' => '', 'name' => 'order_id')), 'where' => array(array('key' => 'order_item_type', 'value' => 'tax', 'operator' => '='), array('key' => 'order_item_name', 'value' => '', 'operator' => '!=')), 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true));
?>
<table class="widefat">
<thead>
<tr>
<th><?php
_e('Tax', 'woocommerce');
?>
</th>
<th><?php
_e('Rate', 'woocommerce');
?>
</th>
<th class="total_row"><?php
_e('Number of orders', 'woocommerce');
?>
</th>
<th class="total_row"><?php
_e('Tax Amount', 'woocommerce');
?>
<a class="tips" data-tip="<?php
esc_attr_e('This is the sum of the "Tax Rows" tax amount within your orders.', 'woocommerce');
?>
" href="#">[?]</a></th>
<th class="total_row"><?php
_e('Shipping Tax Amount', 'woocommerce');
?>
<a class="tips" data-tip="<?php
esc_attr_e('This is the sum of the "Tax Rows" shipping tax amount within your orders.', 'woocommerce');
?>
" href="#">[?]</a></th>
<th class="total_row"><?php
_e('Total Tax', 'woocommerce');
?>
<a class="tips" data-tip="<?php
esc_attr_e('This is the total tax for the rate (shipping tax + product tax).', 'woocommerce');
?>
" href="#">[?]</a></th>
</tr>
</thead>
<?php
if ($tax_rows) {
?>
<tbody>
<?php
$grouped_tax_tows = array();
foreach ($tax_rows as $tax_row) {
if (!isset($grouped_tax_tows[$tax_row->rate_id])) {
$grouped_tax_tows[$tax_row->rate_id] = (object) array('tax_rate' => $tax_row->tax_rate, 'total_orders' => 0, 'tax_amount' => 0, 'shipping_tax_amount' => 0);
}
if ('shop_order' === get_post_type($tax_row->order_id)) {
$grouped_tax_tows[$tax_row->rate_id]->total_orders++;
}
$grouped_tax_tows[$tax_row->rate_id]->tax_amount += wc_round_tax_total($tax_row->tax_amount);
$grouped_tax_tows[$tax_row->rate_id]->shipping_tax_amount += wc_round_tax_total($tax_row->shipping_tax_amount);
}
foreach ($grouped_tax_tows as $rate_id => $tax_row) {
$rate = $wpdb->get_var($wpdb->prepare("SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $rate_id));
?>
<tr>
<th scope="row"><?php
echo $tax_row->tax_rate;
?>
</th>
<td><?php
echo $rate;
?>
%</td>
<td class="total_row"><?php
echo $tax_row->total_orders;
?>
</td>
<td class="total_row"><?php
echo wc_price($tax_row->tax_amount);
?>
</td>
<td class="total_row"><?php
echo wc_price($tax_row->shipping_tax_amount);
?>
</td>
<td class="total_row"><?php
echo wc_price($tax_row->tax_amount + $tax_row->shipping_tax_amount);
?>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th scope="row" colspan="3"><?php
//.........这里部分代码省略.........
开发者ID:blade3,项目名称:woocommerce,代码行数:101,代码来源:class-wc-report-taxes-by-code.php
示例12: store_transaction
/**
* Store an order as a transaction in Taxamo
*
* @param WC_Order $order
* @param bool $force_country
*/
public function store_transaction($order, $force_country)
{
// Get the billing country
$billing_country = $order->billing_country;
// The order manager
$order_manager = new WC_TA_Order_Manager();
// The transaction extra
$transaction_extra = array();
// Location confirmation
if (true === $force_country) {
// Set force country code
$transaction_extra['force_country_code'] = $billing_country;
}
// Check for VAT number
$vat_number = get_post_meta($order->id, WC_TA_Vat_Number_Field::META_KEY, true);
if ('' !== $vat_number) {
// Set VAT number
$transaction_extra['buyer_tax_number'] = $vat_number;
}
// Check for shipping/handling cost
if ($order->order_shipping > 0) {
// Transaction lines
$transaction_extra['transaction_lines'] = array();
// Get the shipping line items
$shipping_line_items = $order->get_items('shipping');
// Check if there are line items
if (count($shipping_line_items) > 0) {
// Loop
foreach ($shipping_line_items as $shipping_line_item_key => $shipping_line_item) {
// Calculate some taxes
$line_cost = $shipping_line_item['cost'];
// Array of taxes
$line_taxes = maybe_unserialize($shipping_line_item['taxes']);
// Get total tax
$line_tax_total = 0;
if (is_array($line_taxes)) {
$line_tax_total = array_sum($line_taxes);
}
// Calculate shipping tax of this line item
$shipping_tax_rate = 0;
if ($order->order_shipping_tax > 0) {
$shipping_tax_rate = $line_tax_total / $line_cost * 100;
}
// Add shipping line item to transaction line
$transaction_extra['transaction_lines'][] = array('product_type' => 'default', 'custom_id' => "" . $shipping_line_item_key, 'quantity' => 1, 'tax_rate' => $shipping_tax_rate, 'total_amount' => wc_round_tax_total($line_cost + $line_tax_total), 'description' => $shipping_line_item['name'], 'informative' => true);
}
}
}
// Setup request
$request_store_transaction = new WC_TA_Request_Store_Transaction($billing_country, $order_manager->get_items_from_order($order), $order->billing_first_name . ' ' . $order->billing_last_name, $order->billing_email, $order->id, $transaction_extra);
// Do request
if ($request_store_transaction->do_request()) {
// Get the body
$response_body = $request_store_transaction->get_response_body();
if (isset($response_body->transaction)) {
// Attach transaction to order
update_post_meta($order->id, 'taxamo_transaction_key', $response_body->transaction->key);
// Loop through line items
if (count($response_body->transaction->transaction_lines) > 0) {
foreach ($response_body->transaction->transaction_lines as $transaction_line) {
if (isset($transaction_line->custom_id) && isset($transaction_line->line_key)) {
// Add Taxamo line key to order item
wc_add_order_item_meta($transaction_line->custom_id, self::OIM_LINE_KEY, $transaction_line->line_key, true);
}
}
}
}
} else {
/**
* @todo Better error handling. Check if AJAX is updated correctly is country doesn't match first try but does second try.
* Block order button
*/
if (function_exists('wc_add_notice')) {
wc_add_notice($request_store_transaction->get_error_message(), 'error');
}
}
}
开发者ID:narendra-addweb,项目名称:MyImmoPix,代码行数:83,代码来源:class-wc-ta-taxamo-manager.php
示例13: get_orders_csv_row
/**
* Get the order data for a single CSV row
*
* Note items are keyed according to the column header keys above so these can be modified using
* the provider filter without needing to worry about the array order
*
* @since 3.0
* @param int $order_id the WC_Order ID
* @return array order data in the format key => content
*/
private function get_orders_csv_row($order_id)
{
$order = wc_get_order($order_id);
$is_json = 'import' == $this->order_format;
$line_items = $shipping_items = $fee_items = $tax_items = $coupon_items = array();
// get line items
foreach ($order->get_items() as $item_id => $item) {
$product = $order->get_product_from_item($item);
if (!is_object($product)) {
$product = new WC_Product(0);
}
$item_meta = new WC_Order_Item_Meta($item);
if ($is_json) {
$meta = array();
foreach ($item_meta->get_formatted('_') as $meta_key => $formatted_meta) {
$meta[$formatted_meta['key']] = $formatted_meta['value'];
}
} else {
add_filter('woocommerce_attribute_label', array($this, 'escape_reserved_meta_chars'));
add_filter('woocommerce_order_item_display_meta_value', array($this, 'escape_reserved_meta_chars'));
$meta = $item_meta->display(true, true);
remove_filter('woocommerce_attribute_label', array($this, 'escape_reserved_meta_chars'));
remove_filter('woocommerce_order_item_display_meta_value', array($this, 'escape_reserved_meta_chars'));
if ($meta) {
// replace key-value sperator (': ') with our own - equals sign (=)
$meta = str_replace(': ', '=', $meta);
// remove any newlines generated by WC_Order_Item_Meta::display()
$meta = str_replace(array(", \r\n", ", \r", ", \n"), ',', $meta);
// re-insert colons and newlines
$meta = str_replace(array('[INSERT_COLON_HERE]', '[INSERT_NEWLINE_HERE]'), array(':', "\n"), $meta);
}
}
$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();
}
if ($is_json) {
$line_item = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item), 2), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], 2), 'total' => wc_format_decimal($order->get_line_total($item), 2), 'total_tax' => wc_format_decimal($order->get_line_tax($item), 2), 'quantity' => (int) $item['qty'], 'name' => $item['name'], 'product_id' => $product_id, 'sku' => $product_sku, 'meta' => $meta, 'tax_data' => isset($item['line_tax_data']) ? maybe_unserialize($item['line_tax_data']) : '');
} else {
$line_item = array('name' => html_entity_decode($item['name'], ENT_NOQUOTES, 'UTF-8'), 'sku' => $product_sku, 'quantity' => (int) $item['qty'], 'total' => wc_format_decimal($order->get_line_total($item), 2), 'refunded' => wc_format_decimal($order->get_total_refunded_for_item($item_id), 2), 'refunded_qty' => $order->get_qty_refunded_for_item($item_id), 'meta' => is_string($meta) ? html_entity_decode($meta, ENT_NOQUOTES, 'UTF-8') : $meta);
// add line item tax
$line_tax_data = isset($item['line_tax_data']) ? $item['line_tax_data'] : array();
$tax_data = maybe_unserialize($line_tax_data);
$line_item['tax'] = isset($tax_data['total']) ? wc_format_decimal(wc_round_tax_total(array_sum((array) $tax_data['total'])), 2) : '';
}
/**
* CSV Order Export Line Item.
*
* Filter the individual line item entry for the default export
*
* @since 3.0.6
* @param array $line_item {
* line item data in key => value format
* the keys are for convenience and not used for exporting. Make
* sure to prefix the values with the desired line item entry name
* }
*
* @param array $item WC order item data
* @param WC_Product $product the product
* @param WC_Order $order the order
* @param \WC_Customer_Order_CSV_Export_Generator $this, generator instance
*/
$line_item = apply_filters('wc_customer_order_csv_export_order_line_item', $line_item, $item, $product, $order, $this);
if (!in_array($this->order_format, array('default_one_row_per_item', 'import')) && is_array($line_item)) {
foreach ($line_item as $name => $value) {
$name = $this->escape_reserved_item_chars($name);
$value = $this->escape_reserved_item_chars($value);
$line_item[$name] = $name . ':' . $value;
}
$line_item = implode('|', $line_item);
}
if ($line_item) {
$line_items[] = $line_item;
}
}
foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) {
$shipping_item = array('id' => $shipping_item_id, 'method_id' => $shipping_item['method_id'], 'method_title' => $shipping_item['name'], 'total' => wc_format_decimal($shipping_item['cost'], 2), 'taxes' => isset($shipping_item['taxes']) ? maybe_unserialize($shipping_item['taxes']) : '');
if ($is_json) {
$shipping_items[] = $shipping_item;
} else {
$shipping_items[] = implode('|', array('method:' . $this->escape_reserved_item_chars($shipping_item['method_title']), 'total:' . $shipping_item['total']));
}
}
// get fee items & total
$fee_total = 0;
$fee_tax_total = 0;
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:class-wc-customer-order-csv-export-generator.php
示例14: create_order
//.........这里部分代码省略.........
foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
$_product = $values['data'];
// Add line item
$item_id = wc_add_order_item($order_id, array('order_item_name' => $_product->get_title(), 'order_item_type' => 'line_item'));
// Add line item meta
if ($item_id) {
wc_add_order_item_meta($item_id, '_qty', apply_filters('woocommerce_stock_amount', $values['quantity']));
wc_add_order_item_meta($item_id, '_tax_class', $_product->get_tax_class());
wc_add_order_item_meta($item_id, '_product_id', $values['product_id']);
wc_add_order_item_meta($item_id, '_variation_id', $values['variation_id']);
wc_add_order_item_meta($item_id, '_line_subtotal', wc_format_decimal($values['line_subtotal']));
wc_add_order_item_meta($item_id, '_line_total', wc_format_decimal($values['line_total']));
wc_add_order_item_meta($item_id, '_line_tax', wc_format_decimal($values['line_tax']));
wc_add_order_item_meta($item_id, '_line_subtotal_tax', wc_format_decimal($values['line_subtotal_tax']));
// Store variation data in meta so admin can view it
if ($values['variation'] && is_array($values['variation'])) {
foreach ($values['variation'] as $key => $value) {
wc_add_order_item_meta($item_id, esc_attr(str_replace('attribute_', '', $key)), $value);
}
}
// Add line item meta for backorder status
if ($_product->backorders_require_notification() && $_product->is_on_backorder($values['quantity'])) {
wc_add_order_item_meta($item_id, apply_filters('woocommerce_backordered_item_meta_name', __('Backordered', 'woocommerce'), $cart_item_key, $order_id), $values['quantity'] - max(0, $_product->get_total_stock()));
}
// Allow plugins to add order item meta
do_action('woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key);
}
}
// Store fees
foreach (WC()->cart->get_fees() as $
|
请发表评论