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


PHP wc_get_base_location函数代码示例

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


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

示例1: get_origin_address

 public function get_origin_address()
 {
     $wc_address_fields = array();
     $wc_address_fields['company'] = get_bloginfo('name');
     $wc_address_fields['name'] = wp_get_current_user()->display_name;
     $base_location = wc_get_base_location();
     $wc_address_fields['country'] = $base_location['country'];
     $wc_address_fields['state'] = $base_location['state'];
     $wc_address_fields['address'] = '';
     $wc_address_fields['address_2'] = '';
     $wc_address_fields['city'] = '';
     $wc_address_fields['postcode'] = '';
     $stored_address_fields = get_option('wc_connect_origin_address', array());
     return array_merge($wc_address_fields, $stored_address_fields);
 }
开发者ID:Automattic,项目名称:woocommerce-connect-client,代码行数:15,代码来源:class-wc-connect-service-settings-store.php

示例2: country_select

 /**
  * Output manual country select form
  */
 public function country_select()
 {
     $all_countries = WC()->countries->get_countries();
     $base_country = wc_get_base_location();
     $countries[$base_country['country']] = $all_countries[$base_country['country']];
     foreach (TFLS()->get_regions() as $region) {
         foreach ($region['countries'] as $country) {
             if (!array_key_exists($country, $countries)) {
                 $countries[$country] = $all_countries[$country];
             }
         }
     }
     asort($countries);
     $other_country = key(array_diff_key($all_countries, $countries));
     $countries[$other_country] = apply_filters('tfls_other_countries_text', __('Other countries'));
     wc_get_template('country-selector.php', array('countries' => $countries), 'woocommerce-the-fairy-light-shop/', untrailingslashit(plugin_dir_path(TFLS_FILE)) . '/templates/');
 }
开发者ID:voice-brand-agency,项目名称:the-fairy-light-shop-site-plugin,代码行数:20,代码来源:class-tfls-frontend.php

示例3: get_taxable_address

 /**
  * get_taxable_address function.
  *
  * @return array
  */
 public function get_taxable_address()
 {
     $tax_based_on = get_option('woocommerce_tax_based_on');
     // Check shipping method at this point to see if we need special handling
     if (true == apply_filters('woocommerce_apply_base_tax_for_local_pickup', true) && WC()->cart->needs_shipping() && sizeof(array_intersect(WC()->session->get('chosen_shipping_methods', array(get_option('woocommerce_default_shipping_method'))), apply_filters('woocommerce_local_pickup_methods', array('local_pickup')))) > 0) {
         $tax_based_on = 'base';
     }
     if ($tax_based_on == 'base') {
         $default = wc_get_base_location();
         $country = $default['country'];
         $state = $default['state'];
         $postcode = '';
         $city = '';
     } elseif ($tax_based_on == 'billing') {
         $country = $this->get_country();
         $state = $this->get_state();
         $postcode = $this->get_postcode();
         $city = $this->get_city();
     } else {
         $country = $this->get_shipping_country();
         $state = $this->get_shipping_state();
         $postcode = $this->get_shipping_postcode();
         $city = $this->get_shipping_city();
     }
     return apply_filters('woocommerce_customer_taxable_address', array($country, $state, $postcode, $city));
 }
开发者ID:ayoayco,项目名称:upbeat,代码行数:31,代码来源:class-wc-customer.php

示例4: get_base_state

 /**
  * Get the base state for the store.
  * @return string
  */
 public function get_base_state()
 {
     $default = wc_get_base_location();
     return apply_filters('woocommerce_countries_base_state', $default['state']);
 }
开发者ID:manuhareendran,项目名称:project,代码行数:9,代码来源:class-wc-countries.php

示例5: calc_line_taxes

 /**
  * Calc line tax.
  */
 public static function calc_line_taxes()
 {
     global $wpdb;
     check_ajax_referer('calc-totals', 'security');
     if (!current_user_can('edit_shop_orders')) {
         die(-1);
     }
     $tax = new WC_Tax();
     $tax_based_on = get_option('woocommerce_tax_based_on');
     $order_id = absint($_POST['order_id']);
     $items = array();
     $country = strtoupper(esc_attr($_POST['country']));
     $state = strtoupper(esc_attr($_POST['state']));
     $postcode = strtoupper(esc_attr($_POST['postcode']));
     $city = wc_clean(esc_attr($_POST['city']));
     $order = wc_get_order($order_id);
     $taxes = array();
     $shipping_taxes = array();
     // Default to base
     if ('base' === $tax_based_on || empty($country)) {
         $default = wc_get_base_location();
         $country = $default['country'];
         $state = $default['state'];
         $postcode = '';
         $city = '';
     }
     // Parse the jQuery serialized items
     parse_str($_POST['items'], $items);
     // Prevent undefined warnings
     if (!isset($items['line_tax'])) {
         $items['line_tax'] = array();
     }
     if (!isset($items['line_subtotal_tax'])) {
         $items['line_subtotal_tax'] = array();
     }
     $items['order_taxes'] = array();
     // Action
     $items = apply_filters('woocommerce_ajax_calc_line_taxes', $items, $order_id, $country, $_POST);
     // Get items and fees taxes
     if (isset($items['order_item_id'])) {
         $line_total = $line_subtotal = $order_item_tax_class = array();
         foreach ($items['order_item_id'] as $item_id) {
             $item_id = absint($item_id);
             $line_total[$item_id] = isset($items['line_total'][$item_id]) ? wc_format_decimal($items['line_total'][$item_id]) : 0;
             $line_subtotal[$item_id] = isset($items['line_subtotal'][$item_id]) ? wc_format_decimal($items['line_subtotal'][$item_id]) : $line_total[$item_id];
             $order_item_tax_class[$item_id] = isset($items['order_item_tax_class'][$item_id]) ? sanitize_text_field($items['order_item_tax_class'][$item_id]) : '';
             $product_id = $order->get_item_meta($item_id, '_product_id', true);
             // Get product details
             if (get_post_type($product_id) == 'product') {
                 $_product = wc_get_product($product_id);
                 $item_tax_status = $_product->get_tax_status();
             } else {
                 $item_tax_status = 'taxable';
             }
             if ('0' !== $order_item_tax_class[$item_id] && 'taxable' === $item_tax_status) {
                 $tax_rates = WC_Tax::find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => $order_item_tax_class[$item_id]));
                 $line_taxes = WC_Tax::calc_tax($line_total[$item_id], $tax_rates, false);
                 $line_subtotal_taxes = WC_Tax::calc_tax($line_subtotal[$item_id], $tax_rates, false);
                 // Set the new line_tax
                 foreach ($line_taxes as $_tax_id => $_tax_value) {
                     $items['line_tax'][$item_id][$_tax_id] = $_tax_value;
                 }
                 // Set the new line_subtotal_tax
                 foreach ($line_subtotal_taxes as $_tax_id => $_tax_value) {
                     $items['line_subtotal_tax'][$item_id][$_tax_id] = $_tax_value;
                 }
                 // Sum the item taxes
                 foreach (array_keys($taxes + $line_taxes) as $key) {
                     $taxes[$key] = (isset($line_taxes[$key]) ? $line_taxes[$key] : 0) + (isset($taxes[$key]) ? $taxes[$key] : 0);
                 }
             }
         }
     }
     // Get shipping taxes
     if (isset($items['shipping_method_id'])) {
         $matched_tax_rates = array();
         $tax_rates = WC_Tax::find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => ''));
         if ($tax_rates) {
             foreach ($tax_rates as $key => $rate) {
                 if (isset($rate['shipping']) && 'yes' == $rate['shipping']) {
                     $matched_tax_rates[$key] = $rate;
                 }
             }
         }
         $shipping_cost = $shipping_taxes = array();
         foreach ($items['shipping_method_id'] as $item_id) {
             $item_id = absint($item_id);
             $shipping_cost[$item_id] = isset($items['shipping_cost'][$item_id]) ? wc_format_decimal($items['shipping_cost'][$item_id]) : 0;
             $_shipping_taxes = WC_Tax::calc_shipping_tax($shipping_cost[$item_id], $matched_tax_rates);
             // Set the new shipping_taxes
             foreach ($_shipping_taxes as $_tax_id => $_tax_value) {
                 $items['shipping_taxes'][$item_id][$_tax_id] = $_tax_value;
                 $shipping_taxes[$_tax_id] = isset($shipping_taxes[$_tax_id]) ? $shipping_taxes[$_tax_id] + $_tax_value : $_tax_value;
             }
         }
     }
     // Remove old tax rows
//.........这里部分代码省略.........
开发者ID:tronsha,项目名称:woocommerce,代码行数:101,代码来源:class-wc-ajax.php

示例6: calculate_shipping_tax

 /**
  * Calculate wcmp vendor shipping tax
  *
  * @param double $shipping_amount
  * @param object $order
  */
 public function calculate_shipping_tax($shipping_amount, $order)
 {
     global $WCMp, $woocommerce;
     $wc_tax_enabled = get_option('woocommerce_calc_taxes');
     if ('no' === $wc_tax_enabled) {
         return 0;
     }
     $tax_based_on = get_option('woocommerce_tax_based_on');
     $WC_Tax = new WC_Tax();
     if ('base' === $tax_based_on) {
         $default = wc_get_base_location();
         $country = $default['country'];
         $state = $default['state'];
         $postcode = '';
         $city = '';
     } elseif ('billing' === $tax_based_on) {
         $country = $order->billing_country;
         $state = $order->billing_state;
         $postcode = $order->billing_postcode;
         $city = $order->billing_city;
     } else {
         $country = $order->shipping_country;
         $state = $order->shipping_state;
         $postcode = $order->shipping_postcode;
         $city = $order->shipping_city;
     }
     $matched_tax_rates = array();
     $tax_rates = $WC_Tax->find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => ''));
     if ($tax_rates) {
         foreach ($tax_rates as $key => $rate) {
             if (isset($rate['shipping']) && 'yes' === $rate['shipping']) {
                 $matched_tax_rates[$key] = $rate;
             }
         }
     }
     $vendor_shipping_taxes = $WC_Tax->calc_shipping_tax($shipping_amount, $matched_tax_rates);
     $vendor_shipping_tax_total = $WC_Tax->round(array_sum($vendor_shipping_taxes));
     return $vendor_shipping_tax_total;
 }
开发者ID:qhuit,项目名称:UrbanPekor,代码行数:45,代码来源:class-wcmp-vendor-details.php

示例7: maybe_exclude_vat

 function maybe_exclude_vat()
 {
     if ((is_checkout() || is_cart() || defined('WOOCOMMERCE_CHECKOUT') || defined('WOOCOMMERCE_CART') || defined('DOING_AJAX') && DOING_AJAX) && !empty(WC()->customer) && 'yes' === get_option('wcj_eu_vat_number_validate', 'yes') && 'yes' === get_option('wcj_eu_vat_number_disable_for_valid', 'yes') && isset($_SESSION['wcj_is_eu_vat_number_valid']) && true === $_SESSION['wcj_is_eu_vat_number_valid'] && isset($_SESSION['wcj_eu_vat_number_to_check'])) {
         $preserve_base_country_check_passed = true;
         if ('yes' === apply_filters('booster_get_option', 'no', get_option('wcj_eu_vat_number_preserve_in_base_country', 'no'))) {
             $location = wc_get_base_location();
             if (empty($location['country'])) {
                 $location = wc_format_country_state_string(apply_filters('woocommerce_customer_default_location', get_option('woocommerce_default_country')));
             }
             $selected_country = substr($_SESSION['wcj_eu_vat_number_to_check'], 0, 2);
             if ('EL' === $selected_country) {
                 $selected_country = 'GR';
             }
             $preserve_base_country_check_passed = $location['country'] !== $selected_country ? true : false;
         }
         if ($preserve_base_country_check_passed) {
             /* $modified_matched_tax_rates = array();
             			foreach ( $matched_tax_rates as $i => $matched_tax_rate ) {
             				$matched_tax_rate['rate'] = 0;
             				$modified_matched_tax_rates[ $i ] = $matched_tax_rate;
             			}
             			return $modified_matched_tax_rates; */
             WC()->customer->set_is_vat_exempt(true);
         } else {
             WC()->customer->set_is_vat_exempt(false);
         }
     } else {
         if (!empty(WC()->customer)) {
             WC()->customer->set_is_vat_exempt(false);
         }
     }
     //		return $matched_tax_rates;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:33,代码来源:class-wcj-eu-vat-number.php

示例8: calculate_taxes

 /**
  * Calculate taxes for all line items and shipping, and store the totals and tax rows.
  *
  * Will use the base country unless customer addresses are set.
  *
  * @return bool success or fail
  */
 public function calculate_taxes()
 {
     $tax_total = 0;
     $taxes = array();
     $tax_based_on = get_option('woocommerce_tax_based_on');
     if ('billing' === $tax_based_on) {
         $country = $this->billing_country;
         $state = $this->billing_state;
         $postcode = $this->billing_postcode;
         $city = $this->billing_city;
     } elseif ('shipping' === $tax_based_on) {
         $country = $this->shipping_country;
         $state = $this->shipping_state;
         $postcode = $this->shipping_postcode;
         $city = $this->shipping_city;
     }
     // Default to base
     if ('base' === $tax_based_on || empty($country)) {
         $default = wc_get_base_location();
         $country = $default['country'];
         $state = $default['state'];
         $postcode = '';
         $city = '';
     }
     // Get items
     foreach ($this->get_items(array('line_item', 'fee')) as $item_id => $item) {
         $product = $this->get_product_from_item($item);
         $line_total = isset($item['line_total']) ? $item['line_total'] : 0;
         $line_subtotal = isset($item['line_subtotal']) ? $item['line_subtotal'] : 0;
         $tax_class = $item['tax_class'];
         $item_tax_status = $product ? $product->get_tax_status() : 'taxable';
         if ('0' !== $tax_class && 'taxable' === $item_tax_status) {
             $tax_rates = WC_Tax::find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => $tax_class));
             $line_subtotal_taxes = WC_Tax::calc_tax($line_subtotal, $tax_rates, false);
             $line_taxes = WC_Tax::calc_tax($line_total, $tax_rates, false);
             $line_subtotal_tax = max(0, array_sum($line_subtotal_taxes));
             $line_tax = max(0, array_sum($line_taxes));
             $tax_total += $line_tax;
             wc_update_order_item_meta($item_id, '_line_subtotal_tax', wc_format_decimal($line_subtotal_tax));
             wc_update_order_item_meta($item_id, '_line_tax', wc_format_decimal($line_tax));
             wc_update_order_item_meta($item_id, '_line_tax_data', array('total' => $line_taxes, 'subtotal' => $line_subtotal_taxes));
             // Sum the item taxes
             foreach (array_keys($taxes + $line_taxes) as $key) {
                 $taxes[$key] = (isset($line_taxes[$key]) ? $line_taxes[$key] : 0) + (isset($taxes[$key]) ? $taxes[$key] : 0);
             }
         }
     }
     // Now calculate shipping tax
     $matched_tax_rates = array();
     $tax_rates = WC_Tax::find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => ''));
     if (!empty($tax_rates)) {
         foreach ($tax_rates as $key => $rate) {
             if (isset($rate['shipping']) && 'yes' === $rate['shipping']) {
                 $matched_tax_rates[$key] = $rate;
             }
         }
     }
     $shipping_taxes = WC_Tax::calc_shipping_tax($this->order_shipping, $matched_tax_rates);
     $shipping_tax_total = WC_Tax::round(array_sum($shipping_taxes));
     // Save tax totals
     $this->set_total($shipping_tax_total, 'shipping_tax');
     $this->set_total($tax_total, 'tax');
     // Tax rows
     $this->remove_order_items('tax');
     // Now merge to keep tax rows
     foreach (array_keys($taxes + $shipping_taxes) as $tax_rate_id) {
         $this->add_tax($tax_rate_id, isset($taxes[$tax_rate_id]) ? $taxes[$tax_rate_id] : 0, isset($shipping_taxes[$tax_rate_id]) ? $shipping_taxes[$tax_rate_id] : 0);
     }
     return true;
 }
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:77,代码来源:abstract-wc-order.php

示例9: country_select

 /**
  * Output manual country select form
  */
 public function country_select()
 {
     $all_countries = WC()->countries->get_countries();
     $base_country = wc_get_base_location();
     $countries[$base_country['country']] = $all_countries[$base_country['country']];
     foreach (WCPBC()->get_regions() as $region) {
         foreach ($region['countries'] as $country) {
             if (!array_key_exists($country, $countries)) {
                 $countries[$country] = $all_countries[$country];
             }
         }
     }
     asort($countries);
     $other_country = key(array_diff_key($all_countries, $countries));
     $countries[$other_country] = apply_filters('wcpbc_other_countries_text', __('Other countries'));
     wc_get_template('country-selector.php', array('countries' => $countries), 'woocommerce-product-price-based-on-countries/', WCPBC()->plugin_path() . '/templates/');
 }
开发者ID:raminabsari,项目名称:phonicsschool,代码行数:20,代码来源:class-wcpbc-frontend.php

示例10: simplify_commerce_notice

 /**
  * Simplify Commerce is being removed from core.
  */
 public static function simplify_commerce_notice()
 {
     $location = wc_get_base_location();
     if (class_exists('WC_Gateway_Simplify_Commerce_Loader') || !in_array($location['country'], apply_filters('woocommerce_gateway_simplify_commerce_supported_countries', array('US', 'IE')))) {
         self::remove_notice('simplify_commerce');
         return;
     }
     if (empty($_GET['action'])) {
         include 'views/html-notice-simplify-commerce.php';
     }
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:14,代码来源:class-wc-admin-notices.php

示例11: get_paper_size

 public function get_paper_size()
 {
     $paper_size = NULL;
     //$this->settings_store->get_preferred_paper_size();
     if ($paper_size) {
         return $paper_size;
     }
     // According to https://en.wikipedia.org/wiki/Letter_(paper_size) US, Mexico, Canada and Dominican Republic
     // use "Letter" size, and pretty much all the rest of the world use A4, so those are sensible defaults
     $base_location = wc_get_base_location();
     if (in_array($base_location['country'], array('US', 'CA', 'MX', 'DO'))) {
         return 'letter';
     }
     return 'a4';
 }
开发者ID:Automattic,项目名称:woocommerce-connect-client,代码行数:15,代码来源:class-wc-connect-shipping-label.php

示例12: admin_options

    public function admin_options()
    {
        $current_user = wp_get_current_user();
        $section_slug = strtolower(get_class($this));
        $production_connect_url = 'https://connect.woocommerce.com/login/braintree';
        $sandbox_connect_url = 'https://connect.woocommerce.com/login/braintreesandbox';
        $redirect_url = add_query_arg(array('page' => 'wc-settings', 'tab' => 'checkout', 'section' => $section_slug), admin_url('admin.php'));
        $redirect_url = wp_nonce_url($redirect_url, 'connect_paypal_braintree', 'wc_paypal_braintree_admin_nonce');
        // Note:  We doubly urlencode the redirect url to avoid Braintree's server
        // decoding it which would cause loss of query params on the final redirect
        // Note: Although the Partner API expects an array
        // ( per https://developers.braintreepayments.com/guides/partner-api/sign-up/php )
        // our middleware presently wants things flattened, so instead of passing a user
        // array and a business array, we pass selected fields with user_ and business_
        // prepended
        $query_args = array('redirect' => urlencode(urlencode($redirect_url)), 'scopes' => 'read_write');
        $current_user = wp_get_current_user();
        $query_args['user_email'] = $current_user->user_email;
        if (!empty($current_user->user_firstname)) {
            $query_args['user_firstName'] = $current_user->user_firstname;
        }
        if (!empty($current_user->user_lastname)) {
            $query_args['user_lastName'] = $current_user->user_lastname;
        }
        $query_args['business_currency'] = get_woocommerce_currency();
        // Let's go ahead and assume the user and business are in the same region and country,
        // because they probably are.  If not, they can edit these anyways
        $base_location = wc_get_base_location();
        if (array_key_exists('country', $base_location)) {
            $country = $base_location['country'];
            if (!empty($country)) {
                $query_args['business_country'] = $country;
                $query_args['user_country'] = $country;
            }
        }
        if (array_key_exists('state', $base_location)) {
            $state = $base_location['state'];
            if (!empty($state)) {
                $query_args['business_region'] = $state;
                $query_args['user_region'] = $state;
            }
        }
        $site_name = get_bloginfo('name');
        if (!empty($site_name)) {
            $query_args['business_name'] = $site_name;
        }
        $site_description = get_bloginfo('description');
        if (!empty($site_description)) {
            $query_args['business_description'] = $site_description;
        }
        $query_args['business_website'] = get_bloginfo('url');
        $production_connect_url = add_query_arg($query_args, $production_connect_url);
        $sandbox_connect_url = add_query_arg($query_args, $sandbox_connect_url);
        $disconnect_url = add_query_arg(array('page' => 'wc-settings', 'tab' => 'checkout', 'section' => $section_slug, 'disconnect_paypal_braintree' => 1), admin_url('admin.php'));
        $disconnect_url = wp_nonce_url($disconnect_url, 'disconnect_paypal_braintree', 'wc_paypal_braintree_admin_nonce');
        ?>
			<div class='paypal-braintree-admin-header'>
				<div class='paypal-braintree-admin-brand'>
					<img src="<?php 
        echo plugins_url('../assets/images/branding/paypal-braintree-horizontal.png', __FILE__);
        ?>
" />
				</div>
				<div class='paypal-braintree-admin-payment-methods'>
					<img src="<?php 
        echo plugins_url('../assets/images/payments/visa.png', __FILE__);
        ?>
" />
					<img src="<?php 
        echo plugins_url('../assets/images/payments/master-card.png', __FILE__);
        ?>
" />
					<img src="<?php 
        echo plugins_url('../assets/images/payments/discover.png', __FILE__);
        ?>
" />
					<img src="<?php 
        echo plugins_url('../assets/images/payments/american-express.png', __FILE__);
        ?>
" />
					<img src="<?php 
        echo plugins_url('../assets/images/payments/paypal.png', __FILE__);
        ?>
" />
				</div>
			</div>
			<?php 
        if (empty($this->merchant_access_token)) {
            ?>
				<p class='paypal-braintree-admin-connect-prompt'>
					<?php 
            echo esc_html('Connect with Braintree to start accepting credit and debit card payments in your checkout.', 'woocommerce-gateway-paypal-braintree');
            ?>
					<br/>
					<a href="https://www.braintreepayments.com/partners/learn-more" target="_blank">
						<?php 
            echo esc_html('Learn more', 'woocommerce-gateway-paypal-braintree');
            ?>
					</a>
				</p>
//.........这里部分代码省略.........
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:101,代码来源:class-wc-gateway-paypal-braintree.php

示例13: _calculate_fee_taxes

 protected function _calculate_fee_taxes(&$order)
 {
     $tax_total = 0;
     $shipping_tax_total = 0;
     $taxes = array();
     $shipping_taxes = array();
     $tax_based_on = get_option('woocommerce_tax_based_on');
     // If is_vat_exempt is 'yes', or wc_tax_enabled is false, return and do nothing.
     if ('yes' === $order->is_vat_exempt || !wc_tax_enabled()) {
         return false;
     }
     if ('billing' === $tax_based_on) {
         $country = $order->billing_country;
         $state = $order->billing_state;
         $postcode = $order->billing_postcode;
         $city = $order->billing_city;
     } elseif ('shipping' === $tax_based_on) {
         $country = $order->shipping_country;
         $state = $order->shipping_state;
         $postcode = $order->shipping_postcode;
         $city = $order->shipping_city;
     }
     // Default to base
     if ('base' === $tax_based_on || empty($country)) {
         $default = wc_get_base_location();
         $country = $default['country'];
         $state = $default['state'];
         $postcode = '';
         $city = '';
     }
     // Get items
     foreach ($order->get_items(array('fee')) as $item_id => $item) {
         $product = $order->get_product_from_item($item);
         $line_total = isset($item['line_total']) ? $item['line_total'] : 0;
         $line_subtotal = isset($item['line_subtotal']) ? $item['line_subtotal'] : 0;
         $tax_class = $item['tax_class'];
         $item_tax_status = $product ? $product->get_tax_status() : 'taxable';
         if ('0' !== $tax_class && 'taxable' === $item_tax_status) {
             $tax_rates = WC_Tax::find_rates(array('country' => $country, 'state' => $state, 'postcode' => $postcode, 'city' => $city, 'tax_class' => $tax_class));
             $line_subtotal_taxes = WC_Tax::calc_tax($line_subtotal, $tax_rates, false);
             $line_taxes = WC_Tax::calc_tax($line_total, $tax_rates, false);
             $line_subtotal_tax = max(0, array_sum($line_subtotal_taxes));
             $line_tax = max(0, array_sum($line_taxes));
             $tax_total += $line_tax;
             wc_update_order_item_meta($item_id, '_line_subtotal_tax', wc_format_decimal($line_subtotal_tax));
             wc_update_order_item_meta($item_id, '_line_tax', wc_format_decimal($line_tax));
             wc_update_order_item_meta($item_id, '_line_tax_data', array('total' => $line_taxes, 'subtotal' => $line_subtotal_taxes));
             // Sum the item taxes
             foreach (array_keys($taxes + $line_taxes) as $key) {
                 $taxes[$key] = (isset($line_taxes[$key]) ? $line_taxes[$key] : 0) + (isset($taxes[$key]) ? $taxes[$key] : 0);
             }
         }
     }
 }
开发者ID:estrategasdigitales,项目名称:rufiatta,代码行数:54,代码来源:XmlImportWooCommerceShopOrder.php

示例14: output

 /**
  * Output the settings
  */
 public function output()
 {
     global $current_section;
     if ($current_section) {
         $base_country = wc_get_base_location();
         $not_available_countries = array();
         $regions = get_option('wc_price_based_country_regions', array());
         foreach ($regions as $key => $value) {
             foreach ($value['countries'] as $code) {
                 if ($current_section !== $key) {
                     $not_available_countries[] = $code;
                 }
             }
         }
         if ($current_section == 'new_group') {
             $this->section_settings($not_available_countries);
         } else {
             if (isset($regions[$current_section])) {
                 $this->section_settings($not_available_countries, $regions[$current_section]);
             }
         }
     } else {
         parent::output();
     }
 }
开发者ID:raminabsari,项目名称:phonicsschool,代码行数:28,代码来源:class-wc-settings-price-based-country.php

示例15: test_wc_get_base_location

 /**
  * Test wc_get_base_location().
  *
  * @since 2.3.0
  */
 public function test_wc_get_base_location()
 {
     $default = wc_get_base_location();
     $this->assertEquals('GB', $default['country']);
     $this->assertEquals('', $default['state']);
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:11,代码来源:core-functions.php


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