is_taxable() public method

Returns whether or not the product is taxable.
public is_taxable ( ) : boolean
return boolean
 /**
  * Get standard product data that applies to every product type
  *
  * @since 2.1
  * @param WC_Product $product
  * @return array
  */
 private function get_product_data($product)
 {
     return array('title' => $product->get_name(), 'id' => $product->get_id(), 'created_at' => $this->server->format_datetime($product->get_date_created(), false, true), 'updated_at' => $this->server->format_datetime($product->get_date_modified(), false, true), 'type' => $product->get_type(), 'status' => $product->get_status(), 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => wc_format_decimal($product->get_price(), 2), 'regular_price' => wc_format_decimal($product->get_regular_price(), 2), 'sale_price' => $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->get_catalog_visibility(), 'on_sale' => $product->is_on_sale(), 'weight' => $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : null, 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height(), 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => apply_filters('the_content', $product->get_description()), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'categories' => wc_get_object_terms($product->get_id(), 'product_cat', 'name'), 'tags' => wc_get_object_terms($product->get_id(), 'product_tag', 'name'), 'images' => $this->get_images($product), 'featured_src' => wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'purchase_note' => apply_filters('the_content', $product->get_purchase_note()), 'total_sales' => $product->get_total_sales(), 'variations' => array(), 'parent' => array());
 }
Esempio n. 2
1
 /**
  * Get the product row subtotal.
  *
  * Gets the tax etc to avoid rounding issues.
  *
  * When on the checkout (review order), this will get the subtotal based on the customer's tax rate rather than the base rate.
  *
  * @param WC_Product $_product
  * @param int $quantity
  * @return string formatted price
  */
 public function get_product_subtotal($_product, $quantity)
 {
     $price = $_product->get_price();
     $taxable = $_product->is_taxable();
     // Taxable
     if ($taxable) {
         if ($this->tax_display_cart == 'excl') {
             $row_price = $_product->get_price_excluding_tax($quantity);
             $product_subtotal = wc_price($row_price);
             if ($this->prices_include_tax && $this->tax_total > 0) {
                 $product_subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
             }
         } else {
             $row_price = $_product->get_price_including_tax($quantity);
             $product_subtotal = wc_price($row_price);
             if (!$this->prices_include_tax && $this->tax_total > 0) {
                 $product_subtotal .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
             }
         }
         // Non-taxable
     } else {
         $row_price = $price * $quantity;
         $product_subtotal = wc_price($row_price);
     }
     return apply_filters('woocommerce_cart_product_subtotal', $product_subtotal, $_product, $quantity, $this);
 }
 /**
  * Get standard product data that applies to every product type
  *
  * @since 2.1
  * @param WC_Product $product
  * @return WC_Product
  */
 private function get_product_data($product)
 {
     return array('title' => $product->get_title(), 'id' => (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id, 'created_at' => $this->server->format_datetime($product->get_post_data()->post_date_gmt), 'updated_at' => $this->server->format_datetime($product->get_post_data()->post_modified_gmt), 'type' => $product->product_type, 'status' => $product->get_post_data()->post_status, 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->visibility, 'on_sale' => $product->is_on_sale(), 'product_url' => $product->is_type('external') ? $product->get_product_url() : '', 'button_text' => $product->is_type('external') ? $product->get_button_text() : '', 'weight' => $product->get_weight() ? $product->get_weight() : null, 'dimensions' => array('length' => $product->length, 'width' => $product->width, 'height' => $product->height, 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => wpautop(do_shortcode($product->get_post_data()->post_content)), 'short_description' => apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt), 'reviews_allowed' => 'open' === $product->get_post_data()->comment_status, 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => (int) $product->get_rating_count(), 'related_ids' => array_map('absint', array_values($product->get_related())), 'upsell_ids' => array_map('absint', $product->get_upsells()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sells()), 'parent_id' => $product->post->post_parent, 'categories' => wp_get_post_terms($product->id, 'product_cat', array('fields' => 'names')), 'tags' => wp_get_post_terms($product->id, 'product_tag', array('fields' => 'names')), 'images' => $this->get_images($product), 'featured_src' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->is_type('variation') ? $product->variation_id : $product->id)), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => (int) $product->download_limit, 'download_expiry' => (int) $product->download_expiry, 'download_type' => $product->download_type, 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->purchase_note))), 'total_sales' => metadata_exists('post', $product->id, 'total_sales') ? (int) get_post_meta($product->id, 'total_sales', true) : 0, 'variations' => array(), 'parent' => array(), 'grouped_products' => array());
 }
 /**
  * Calculates a price (could be per period price or sign-up fee) for a subscription less tax
  * if the subscription is taxable and the prices in the store include tax.
  *
  * Based on the WC_Product::get_price_excluding_tax() function.
  *
  * @param float $price The price to adjust based on taxes
  * @param WC_Product $product The product the price belongs too (needed to determine tax class)
  * @since 1.0
  */
 public static function calculate_tax_for_subscription($price, $product, $deduct_base_taxes = false)
 {
     _deprecated_function(__METHOD__, '1.5.8', 'WC_Product::get_price_including_tax()');
     if ($product->is_taxable()) {
         $tax = new WC_Tax();
         $base_tax_rates = $tax->get_shop_base_rate($product->tax_class);
         $tax_rates = $tax->get_rates($product->get_tax_class());
         // This will get the base rate unless we're on the checkout page
         if ($deduct_base_taxes && get_option('woocommerce_prices_include_tax') == 'yes') {
             $base_taxes = $tax->calc_tax($price, $base_tax_rates, true);
             $taxes = $tax->calc_tax($price - array_sum($base_taxes), $tax_rates, false);
         } elseif (get_option('woocommerce_prices_include_tax') == 'yes') {
             $taxes = $tax->calc_tax($price, $base_tax_rates, true);
         } else {
             $taxes = $tax->calc_tax($price, $base_tax_rates, false);
         }
         $tax_amount = $tax->get_tax_total($taxes);
     } else {
         $tax_amount = 0;
     }
     return $tax_amount;
 }
 /**
  * Outputs a formatted subtotal.
  *
  * @param  WC_Product 	$product
  * @param  double 		$subtotal
  * @return string
  */
 public function format_product_subtotal($product, $subtotal)
 {
     $cart = WC()->cart;
     $taxable = $product->is_taxable();
     // Taxable.
     if ($taxable) {
         if ($cart->tax_display_cart == 'excl') {
             $product_subtotal = wc_price($subtotal);
             if ($cart->prices_include_tax && $cart->tax_total > 0) {
                 $product_subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
             }
         } else {
             $product_subtotal = wc_price($subtotal);
             if (!$cart->prices_include_tax && $cart->tax_total > 0) {
                 $product_subtotal .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
             }
         }
         // Non-taxable.
     } else {
         $product_subtotal = wc_price($subtotal);
     }
     return $product_subtotal;
 }
Esempio n. 6
0
 /**
  *
  *
  * @param unknown $order
  * @param unknown $group (optional)
  *
  * @return unknown
  */
 public static function get_vendor_dues_from_order($order, $group = true)
 {
     global $woocommerce;
     $give_tax = WC_Vendors::$pv_options->get_option('give_tax');
     $give_shipping = WC_Vendors::$pv_options->get_option('give_shipping');
     $receiver = array();
     $shipping_given = 0;
     $tax_given = 0;
     WCV_Shipping::$pps_shipping_costs = array();
     foreach ($order->get_items() as $key => $product) {
         $product_id = !empty($product['variation_id']) ? $product['variation_id'] : $product['product_id'];
         $author = WCV_Vendors::get_vendor_from_product($product_id);
         $give_tax_override = get_user_meta($author, 'wcv_give_vendor_tax', true);
         $give_shipping_override = get_user_meta($author, 'wcv_give_vendor_shipping', true);
         $is_vendor = WCV_Vendors::is_vendor($author);
         $commission = $is_vendor ? WCV_Commission::calculate_commission($product['line_subtotal'], $product_id, $order, $product['qty']) : 0;
         $tax = !empty($product['line_tax']) ? (double) $product['line_tax'] : 0;
         // Check if shipping is enabled
         if (get_option('woocommerce_calc_shipping') === 'no') {
             $shipping = 0;
             $shipping_tax = 0;
         } else {
             $shipping_costs = WCV_Shipping::get_shipping_due($order->id, $product, $author);
             $shipping = $shipping_costs['amount'];
             $shipping_tax = $shipping_costs['tax'];
         }
         $_product = new WC_Product($product['product_id']);
         // Add line item tax and shipping taxes together
         $total_tax = $_product->is_taxable() ? (double) $tax + (double) $shipping_tax : 0;
         // Tax override on a per vendor basis
         if ($give_tax_override) {
             $give_tax = true;
         }
         // Shipping override
         if ($give_shipping_override) {
             $give_shipping = true;
         }
         if ($is_vendor) {
             $shipping_given += $give_shipping ? $shipping : 0;
             $tax_given += $give_tax ? $total_tax : 0;
             $give = 0;
             $give += !empty($receiver[$author]['total']) ? $receiver[$author]['total'] : 0;
             $give += $give_shipping ? $shipping : 0;
             $give += $commission;
             $give += $give_tax ? $total_tax : 0;
             if ($group) {
                 $receiver[$author] = array('vendor_id' => (int) $author, 'commission' => !empty($receiver[$author]['commission']) ? $receiver[$author]['commission'] + $commission : $commission, 'shipping' => $give_shipping ? !empty($receiver[$author]['shipping']) ? $receiver[$author]['shipping'] + $shipping : $shipping : 0, 'tax' => $give_tax ? !empty($receiver[$author]['tax']) ? $receiver[$author]['tax'] + $total_tax : $total_tax : 0, 'qty' => !empty($receiver[$author]['qty']) ? $receiver[$author]['qty'] + $product['qty'] : $product['qty'], 'total' => $give);
             } else {
                 $receiver[$author][$key] = array('vendor_id' => (int) $author, 'product_id' => $product_id, 'commission' => $commission, 'shipping' => $give_shipping ? $shipping : 0, 'tax' => $give_tax ? $total_tax : 0, 'qty' => $product['qty'], 'total' => ($give_shipping ? $shipping : 0) + $commission + ($give_tax ? $total_tax : 0));
             }
         }
         $admin_comm = $product['line_subtotal'] - $commission;
         if ($group) {
             $receiver[1] = array('vendor_id' => 1, 'qty' => !empty($receiver[1]['qty']) ? $receiver[1]['qty'] + $product['qty'] : $product['qty'], 'commission' => !empty($receiver[1]['commission']) ? $receiver[1]['commission'] + $admin_comm : $admin_comm, 'total' => !empty($receiver[1]) ? $receiver[1]['total'] + $admin_comm : $admin_comm);
         } else {
             $receiver[1][$key] = array('vendor_id' => 1, 'product_id' => $product_id, 'commission' => $admin_comm, 'shipping' => 0, 'tax' => 0, 'qty' => $product['qty'], 'total' => $admin_comm);
         }
     }
     // Add remainders on end to admin
     $discount = $order->get_total_discount();
     $shipping = $order->order_shipping - $shipping_given;
     $tax = round($order->order_tax + $order->order_shipping_tax - $tax_given, 2);
     $total = $tax + $shipping - $discount;
     if ($group) {
         $receiver[1]['commission'] = $receiver[1]['commission'] - $discount;
         $receiver[1]['shipping'] = $shipping;
         $receiver[1]['tax'] = $tax;
         $receiver[1]['total'] += $total;
     } else {
         $receiver[1][$key]['commission'] = $receiver[1][$key]['commission'] - $discount;
         $receiver[1][$key]['shipping'] = $order->order_shipping - $shipping_given;
         $receiver[1][$key]['tax'] = $tax;
         $receiver[1][$key]['total'] += $total;
     }
     // Reset the array keys
     // $receivers = array_values( $receiver );
     return $receiver;
 }
/**
 * For a given product, and optionally price/qty, work out the price with tax excluded, based on store settings.
 * @since  2.7.0
 * @param  WC_Product $product
 * @param  array $args
 * @return float
 */
function wc_get_price_excluding_tax($product, $args = array())
{
    $args = wp_parse_args($args, array('qty' => '', 'price' => ''));
    $price = $args['price'] ? $args['price'] : $product->get_price();
    $qty = $args['qty'] ? $args['qty'] : 1;
    if ($product->is_taxable() && wc_prices_include_tax()) {
        $tax_rates = WC_Tax::get_base_tax_rates($product->get_tax_class(true));
        $taxes = WC_Tax::calc_tax($price * $qty, $tax_rates, true);
        $price = WC_Tax::round($price * $qty - array_sum($taxes));
    } else {
        $price = $price * $qty;
    }
    return apply_filters('woocommerce_get_price_excluding_tax', $price, $qty, $product);
}
 /**
  * Displays each cart tax in a subscription string and calculates the sign-up fee taxes (if any)
  * to display in the string.
  *
  * @since 1.0
  */
 public static function get_formatted_taxes($taxes)
 {
     global $woocommerce;
     if (self::cart_contains_subscription()) {
         foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) {
             $product = new WC_Product($cart_item['product_id']);
             if ($product->is_taxable()) {
                 $base_tax_rates = $woocommerce->cart->tax->get_shop_base_rate($product->tax_class);
                 $tax_rates = $woocommerce->cart->tax->get_rates($product->get_tax_class());
                 // This will get the base rate unless we're on the checkout page
                 $signup_fee = WC_Subscriptions_Product::get_sign_up_fee($product);
                 // Remove discounts from sign-up fee
                 if ($woocommerce->cart->sign_up_fee_discount_cart) {
                     $signup_fee -= $woocommerce->cart->sign_up_fee_discount_cart;
                 }
                 if ($woocommerce->cart->display_cart_ex_tax && $tax_rates == $base_tax_rates && $woocommerce->cart->prices_include_tax) {
                     if ($signup_fee > 0) {
                         $signup_taxes = $woocommerce->cart->tax->calc_tax($signup_fee, $base_tax_rates, true);
                     }
                 } elseif ($woocommerce->cart->display_cart_ex_tax && $woocommerce->cart->prices_include_tax) {
                     if ($signup_fee > 0) {
                         $base_signup_taxes = $woocommerce->cart->tax->calc_tax($signup_fee, $base_tax_rates, true, true);
                         $signup_taxes = $woocommerce->cart->tax->calc_tax($signup_fee - array_sum($base_signup_taxes), $tax_rates, false);
                     }
                 } else {
                     if ($signup_fee > 0) {
                         $signup_taxes = $woocommerce->cart->tax->calc_tax($signup_fee, $tax_rates, false);
                     }
                 }
             }
             foreach ($taxes as $tax_id => $tax_amount) {
                 $subscription_interval = WC_Subscriptions_Product::get_interval($product);
                 $subscription_tax_string = sprintf(_n(' %s / %s', ' %s every %s', $subscription_interval, WC_Subscriptions::$text_domain), $tax_amount, WC_Subscriptions_Manager::get_subscription_period_strings($subscription_interval, WC_Subscriptions_Product::get_period($product)));
                 if (WC_Subscriptions_Product::get_sign_up_fee($product) && isset($signup_taxes[$tax_id]) && $signup_taxes[$tax_id] > 0) {
                     $subscription_tax_string = sprintf(__('%s with %s tax on the sign-up fee', WC_Subscriptions::$text_domain), $subscription_tax_string, woocommerce_price($signup_taxes[$tax_id]));
                 }
                 $taxes[$tax_id] = $subscription_tax_string;
             }
         }
     }
     return $taxes;
 }
 /**
  * Get standard product data that applies to every product type
  *
  * @since 2.1
  * @param WC_Product $product
  * @return WC_Product
  */
 private function get_product_data($product, $fields = null)
 {
     if ($fields) {
         $field_list = explode(',', $fields);
     }
     $product_data = array();
     if (!$fields || $fields && in_array('title', $field_list)) {
         $product_data['title'] = $product->get_title();
     }
     if (!$fields || $fields && in_array('id', $field_list)) {
         $product_data['id'] = (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id;
     }
     if (!$fields || $fields && in_array('created_at', $field_list)) {
         $product_data['created_at'] = $this->server->format_datetime($product->get_post_data()->post_date_gmt);
     }
     if (!$fields || $fields && in_array('updated_at', $field_list)) {
         $product_data['updated_at'] = $this->server->format_datetime($product->get_post_data()->post_modified_gmt);
     }
     if (!$fields || $fields && in_array('type', $field_list)) {
         $product_data['type'] = $product->product_type;
     }
     if (!$fields || $fields && in_array('status', $field_list)) {
         $product_data['status'] = $product->get_post_data()->post_status;
     }
     if (!$fields || $fields && in_array('downloadable', $field_list)) {
         $product_data['downloadable'] = $product->is_downloadable();
     }
     if (!$fields || $fields && in_array('virtual', $field_list)) {
         $product_data['virtual'] = $product->is_virtual();
     }
     if (!$fields || $fields && in_array('permalink', $field_list)) {
         $product_data['permalink'] = $product->get_permalink();
     }
     if (!$fields || $fields && in_array('sku', $field_list)) {
         $product_data['sku'] = $product->get_sku();
     }
     if (!$fields || $fields && in_array('price', $field_list)) {
         $product_data['price'] = $product->get_price();
     }
     if (!$fields || $fields && in_array('regular_price', $field_list)) {
         $product_data['regular_price'] = $product->get_regular_price();
     }
     if (!$fields || $fields && in_array('sale_price', $field_list)) {
         $product_data['sale_price'] = $product->get_sale_price() ? $product->get_sale_price() : null;
     }
     if (!$fields || $fields && in_array('price_html', $field_list)) {
         $product_data['price_html'] = $product->get_price_html();
     }
     if (!$fields || $fields && in_array('taxable', $field_list)) {
         $product_data['taxable'] = $product->is_taxable();
     }
     if (!$fields || $fields && in_array('tax_status', $field_list)) {
         $product_data['tax_status'] = $product->get_tax_status();
     }
     if (!$fields || $fields && in_array('tax_class', $field_list)) {
         $product_data['tax_class'] = $product->get_tax_class();
     }
     if (!$fields || $fields && in_array('managing_stock', $field_list)) {
         $product_data['managing_stock'] = $product->managing_stock();
     }
     if (!$fields || $fields && in_array('stock_quantity', $field_list)) {
         $product_data['stock_quantity'] = $product->get_stock_quantity();
     }
     if (!$fields || $fields && in_array('in_stock', $field_list)) {
         $product_data['in_stock'] = $product->is_in_stock();
     }
     if (!$fields || $fields && in_array('backorders_allowed', $field_list)) {
         $product_data['backorders_allowed'] = $product->backorders_allowed();
     }
     if (!$fields || $fields && in_array('backordered', $field_list)) {
         $product_data['backordered'] = $product->is_on_backorder();
     }
     if (!$fields || $fields && in_array('sold_individually', $field_list)) {
         $product_data['sold_individually'] = $product->is_sold_individually();
     }
     if (!$fields || $fields && in_array('purchaseable', $field_list)) {
         $product_data['purchaseable'] = $product->is_purchasable();
     }
     if (!$fields || $fields && in_array('featured', $field_list)) {
         $product_data['featured'] = $product->is_featured();
     }
     if (!$fields || $fields && in_array('visible', $field_list)) {
         $product_data['visible'] = $product->is_visible();
     }
     if (!$fields || $fields && in_array('catalog_visibility', $field_list)) {
         $product_data['catalog_visibility'] = $product->visibility;
     }
     if (!$fields || $fields && in_array('on_sale', $field_list)) {
         $product_data['on_sale'] = $product->is_on_sale();
     }
     if (!$fields || $fields && in_array('product_url', $field_list)) {
         $product_data['product_url'] = $product->is_type('external') ? $product->get_product_url() : '';
     }
     if (!$fields || $fields && in_array('button_text', $field_list)) {
         $product_data['button_text'] = $product->is_type('external') ? $product->get_button_text() : '';
     }
     if (!$fields || $fields && in_array('weight', $field_list)) {
         $product_data['weight'] = $product->get_weight() ? $product->get_weight() : null;
     }
     if (!$fields || $fields && in_array('dimensions', $field_list)) {
         $product_data['dimensions'] = array('length' => $product->length, 'width' => $product->width, 'height' => $product->height, 'unit' => get_option('woocommerce_dimension_unit'));
     }
     if (!$fields || $fields && in_array('shipping_required', $field_list)) {
         $product_data['shipping_required'] = $product->needs_shipping();
     }
     if (!$fields || $fields && in_array('shipping_taxable', $field_list)) {
         $product_data['shipping_taxable'] = $product->is_shipping_taxable();
     }
     if (!$fields || $fields && in_array('shipping_class', $field_list)) {
         $product_data['shipping_class'] = $product->get_shipping_class();
     }
     if (!$fields || $fields && in_array('shipping_class_id', $field_list)) {
         $product_data['shipping_class_id'] = 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null;
     }
     if (!$fields || $fields && in_array('description', $field_list)) {
         $product_data['description'] = wpautop(do_shortcode($product->get_post_data()->post_content));
     }
     if (!$fields || $fields && in_array('short_description', $field_list)) {
         $product_data['short_description'] = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt);
     }
     if (!$fields || $fields && in_array('reviews_allowed', $field_list)) {
         $product_data['reviews_allowed'] = 'open' === $product->get_post_data()->comment_status;
     }
     if (!$fields || $fields && in_array('average_rating', $field_list)) {
         $product_data['average_rating'] = wc_format_decimal($product->get_average_rating(), 2);
     }
     if (!$fields || $fields && in_array('rating_count', $field_list)) {
         $product_data['rating_count'] = (int) $product->get_rating_count();
     }
     if (!$fields || $fields && in_array('related_ids', $field_list)) {
         $product_data['related_ids'] = array_map('absint', array_values($product->get_related()));
     }
     if (!$fields || $fields && in_array('upsell_ids', $field_list)) {
         $product_data['upsell_ids'] = array_map('absint', $product->get_upsells());
     }
     if (!$fields || $fields && in_array('cross_sell_ids', $field_list)) {
         $product_data['cross_sell_ids'] = array_map('absint', $product->get_cross_sells());
     }
     if (!$fields || $fields && in_array('parent_id', $field_list)) {
         $product_data['parent_id'] = $product->post->post_parent;
     }
     if (!$fields || $fields && in_array('categories', $field_list)) {
         $product_data['categories'] = wp_get_post_terms($product->id, 'product_cat', array('fields' => 'names'));
     }
     if (!$fields || $fields && in_array('tags', $field_list)) {
         $product_data['tags'] = wp_get_post_terms($product->id, 'product_tag', array('fields' => 'names'));
     }
     if (!$fields || $fields && in_array('images', $field_list)) {
         $product_data['images'] = $this->get_images($product);
     }
     if (!$fields || $fields && in_array('featured_src', $field_list)) {
         $product_data['featured_src'] = (string) wp_get_attachment_url(get_post_thumbnail_id($product->is_type('variation') ? $product->variation_id : $product->id));
     }
     if (!$fields || $fields && in_array('attributes', $field_list)) {
         $product_data['attributes'] = $this->get_attributes($product);
     }
     if (!$fields || $fields && in_array('downloads', $field_list)) {
         $product_data['downloads'] = $this->get_downloads($product);
     }
     if (!$fields || $fields && in_array('download_limit', $field_list)) {
         $product_data['download_limit'] = (int) $product->download_limit;
     }
     if (!$fields || $fields && in_array('download_expiry', $field_list)) {
         $product_data['download_expiry'] = (int) $product->download_expiry;
     }
     if (!$fields || $fields && in_array('download_type', $field_list)) {
         $product_data['download_type'] = $product->download_type;
     }
     if (!$fields || $fields && in_array('purchase_note', $field_list)) {
         $product_data['purchase_note'] = wpautop(do_shortcode(wp_kses_post($product->purchase_note)));
     }
     if (!$fields || $fields && in_array('total_sales', $field_list)) {
         $product_data['total_sales'] = metadata_exists('post', $product->id, 'total_sales') ? (int) get_post_meta($product->id, 'total_sales', true) : 0;
     }
     if (!$fields || $fields && in_array('variations', $field_list)) {
         $product_data['variations'] = array();
     }
     if (!$fields || $fields && in_array('parent', $field_list)) {
         $product_data['parent'] = array();
     }
     if (!$fields || $fields && in_array('grouped_products', $field_list)) {
         $product_data['grouped_products'] = array();
     }
     if (!$fields || $fields && in_array('menu_order', $field_list)) {
         $product_data['menu_order'] = $product->post->menu_order;
     }
     return $product_data;
 }
 /**
  *
  * Gets custom price on the order page
  *
  * @param WC_Product $product
  * @param int $item_id
  * @param str $start - Start date
  * @param str $end - End date
  * @param array $order_item
  * @param array $coupons
  * @return array $item_prices - Item prices (subtotal, total, tax subtotal and tax total)
  *
  **/
 public function easy_booking_get_booking_price($product, $item_id, $start, $end, $order_item, $coupons)
 {
     if (!$product) {
         return false;
     }
     $calc_mode = $this->options['easy_booking_calc_mode'];
     // Calculation mode (Days or Nights)
     // Get booking duration
     $start_diff = strtotime($start);
     $end_diff = strtotime($end);
     $diff = absint($start_diff - $end_diff) * 1000;
     $days = $diff / 86400000;
     if ($days === 0) {
         $days = 1;
     }
     // If calculation mode is set to "Days", add one day
     if ($calc_mode === 'days' && $start != $end) {
         $duration = absint($days + 1);
     } elseif ($calc_mode === 'days' && $start === $end) {
         $duration = absint($days);
     } else {
         $duration = absint($days);
     }
     if ($product->is_taxable()) {
         $price = $product->get_price_excluding_tax();
         // Product price excluding tax
     } else {
         $price = $product->get_price();
         // Product price
     }
     // Price for x days
     $new_price = apply_filters('easy_booking_get_order_item_price', $price * $duration, $product, $item_id, $duration);
     if ($product->is_taxable()) {
         $item_tax_class = $order_item['tax_class'];
         $product_taxes = $this->easy_booking_get_product_taxes($new_price, $item_tax_class);
         // Product taxes without potential discounts
         foreach ($product_taxes as $_tax_id => $_tax_value) {
             $tax_subtotal[$_tax_id] = $_tax_value;
         }
         $tax_amount = WC_Tax::get_tax_total($product_taxes);
     }
     if ($coupons) {
         foreach ($coupons as $code) {
             $coupon = new WC_Coupon($code);
             if ($coupon->is_valid_for_product($product)) {
                 $coupon_amount = $coupon->get_discount_amount($new_price, $order_item, true);
                 // Discounted amount for item price
                 $total = $new_price - $coupon_amount;
                 // New price with discount
                 if (!empty($product_taxes)) {
                     foreach ($product_taxes as $_tax_id => $_tax_value) {
                         $tax_discount[$_tax_id] = $coupon->get_discount_amount($_tax_value, $order_item, true);
                         // Discounted amount for item taxes
                         $tax_total[$_tax_id] = $_tax_value - $tax_discount[$_tax_id];
                         //  Product taxes with discount
                     }
                 }
             } else {
                 if (!empty($product_taxes)) {
                     foreach ($product_taxes as $_tax_id => $_tax_value) {
                         $tax_total[$_tax_id] = $_tax_value;
                         // No valid coupon - Product taxes unchanged
                     }
                 }
                 $total = $new_price;
                 // No valid coupon - Product  price unchanged
             }
         }
     } else {
         if (!empty($product_taxes)) {
             foreach ($product_taxes as $_tax_id => $_tax_value) {
                 $tax_total[$_tax_id] = $_tax_value;
                 // No coupon - Product taxes unchanged
             }
         }
         $total = $new_price;
         // No coupon - Product  price unchanged
     }
     $new_price = $new_price * $order_item['quantity'];
     // Multiply subtotal by item quantity
     $total = $total * $order_item['quantity'];
     // Multiply total by item quantity
     if (!empty($product_taxes)) {
         foreach ($tax_subtotal as $tax_subtotal_id => $tax_subtotal_amount) {
             $tax_subtotal[$tax_subtotal_id] = $tax_subtotal_amount * $order_item['quantity'];
         }
         // Multiply tax subtotal by item quantity
         foreach ($tax_total as $tax_total_id => $tax_total_amount) {
             $tax_total[$tax_total_id] = $tax_total_amount * $order_item['quantity'];
         }
         // Multiply tax total by item quantity
         // Format taxes
         $line_taxes = array_map('wc_format_decimal', $tax_total);
         $line_subtotal_taxes = array_map('wc_format_decimal', $tax_subtotal);
         $item_prices['tax_subtotal'] = $line_subtotal_taxes;
         $item_prices['tax_total'] = $line_taxes;
     }
     $item_prices['subtotal'] = floatval(wc_format_decimal($new_price, 0));
     $item_prices['total'] = floatval(wc_format_decimal($total, 0));
     return $item_prices;
 }