コード例 #1
0
 /**
  * Get the product total price excluding tax
  *
  * @param int $quantity
  * @return float the total price of the product times the quantity without any tax included
  */
 public function get_price_excluding_tax($quantity = 1)
 {
     // to avoid rounding errors multiply by 100
     $price = $this->get_price() * 100;
     if (self::get_options()->get('fflcommerce_calc_taxes') === 'yes' && self::get_options()->get('fflcommerce_prices_include_tax') === 'yes') {
         $rates = (array) $this->get_tax_base_rate();
         if (count($rates) > 0) {
             // rates array sorted so that taxes applied to retail value come first. To reverse taxes, need to reverse this array
             $new_rates = array_reverse($rates, true);
             $tax_totals = 0;
             $_tax = new fflcommerce_tax(100);
             foreach ($new_rates as $key => $value) {
                 if ($value['is_not_compound_tax']) {
                     $tax_totals += $_tax->calc_tax($price * $quantity, $value['rate'], true);
                 } else {
                     $tax_amount[$key] = $_tax->calc_tax($price * $quantity, $value['rate'], true);
                     $tax_totals += $tax_amount[$key];
                 }
             }
             return round(($price * $quantity - $tax_totals) / 100, 4);
         }
     }
     return round($price * $quantity / 100, 4);
 }