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


PHP Product::getIdTaxRulesGroupByIdProduct方法代码示例

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


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

示例1: updateTaxAmount

 public function updateTaxAmount($order, $tax_calculator = false)
 {
     $this->setContext((int) $this->id_shop);
     $address = new Address((int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $tax_manager = TaxManagerFactory::getManager($address, (int) Product::getIdTaxRulesGroupByIdProduct((int) $this->product_id, $this->context));
     $this->tax_calculator = $tax_manager->getTaxCalculator();
     return $tax_calculator ? $this->tax_calculator : $this->saveTaxCalculator($order, true);
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:8,代码来源:OrderDetail.php

示例2: getProductTaxRate

 /**
  * Returns the product tax
  *
  * @param integer $id_product
  * @param integer $id_country
  * @return Tax
  */
 public static function getProductTaxRate($id_product, $id_address = null, Context $context = null)
 {
     if ($context == null) {
         $context = Context::getContext();
     }
     $address = Address::initialize($id_address);
     $id_tax_rules = (int) Product::getIdTaxRulesGroupByIdProduct($id_product, $context);
     $tax_manager = TaxManagerFactory::getManager($address, $id_tax_rules);
     $tax_calculator = $tax_manager->getTaxCalculator();
     return $tax_calculator->getTotalRate();
 }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:18,代码来源:Tax.php

示例3: getOrderTotal


//.........这里部分代码省略.........
         }
         $type = Cart::ONLY_PRODUCTS;
     }
     $order_total = 0;
     if (Tax::excludeTaxeOption()) {
         $with_taxes = false;
     }
     $products_total = array();
     $ecotax_total = 0;
     foreach ($products as $product) {
         if ($virtual_context->shop->id != $product['id_shop']) {
             $virtual_context->shop = new Shop((int) $product['id_shop']);
         }
         if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
             $id_address = (int) $this->id_address_invoice;
         } else {
             $id_address = (int) $product['id_address_delivery'];
         }
         // Get delivery address of the product from the cart
         if (!Address::addressExists($id_address)) {
             $id_address = null;
         }
         $price = Product::getPriceStatic((int) $product['id_product'], false, (int) $product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $id_address, $null, false, true, $virtual_context);
         if (Configuration::get('PS_USE_ECOTAX')) {
             $ecotax = $product['ecotax'];
             if (isset($product['attribute_ecotax']) && $product['attribute_ecotax'] > 0) {
                 $ecotax = $product['attribute_ecotax'];
             }
         } else {
             $ecotax = 0;
         }
         $address = Address::initialize($id_address, true);
         if ($with_taxes) {
             $id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product'], $virtual_context);
             $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
             if ($ecotax) {
                 $ecotax_tax_calculator = TaxManagerFactory::getManager($address, (int) Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID'))->getTaxCalculator();
             }
         } else {
             $id_tax_rules_group = 0;
         }
         if (in_array(Configuration::get('PS_ROUND_TYPE'), array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
             if (!isset($products_total[$id_tax_rules_group])) {
                 $products_total[$id_tax_rules_group] = 0;
             }
         } else {
             if (!isset($products_total[$id_tax_rules_group . '_' . $id_address])) {
                 $products_total[$id_tax_rules_group . '_' . $id_address] = 0;
             }
         }
         switch (Configuration::get('PS_ROUND_TYPE')) {
             case Order::ROUND_TOTAL:
                 $products_total[$id_tax_rules_group . '_' . $id_address] += $price * (int) $product['cart_quantity'];
                 if ($ecotax) {
                     $ecotax_total += $ecotax * (int) $product['cart_quantity'];
                 }
                 break;
             case Order::ROUND_LINE:
                 $product_price = $price * $product['cart_quantity'];
                 $products_total[$id_tax_rules_group] += Tools::ps_round($product_price, _PS_PRICE_COMPUTE_PRECISION_);
                 if ($with_taxes) {
                     $products_total[$id_tax_rules_group] += Tools::ps_round($tax_calculator->getTaxesTotalAmount($product_price), _PS_PRICE_COMPUTE_PRECISION_);
                 }
                 if ($ecotax) {
                     $ecotax_price = $ecotax * (int) $product['cart_quantity'];
                     $ecotax_total += Tools::ps_round($ecotax_price, _PS_PRICE_COMPUTE_PRECISION_);
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:67,代码来源:Cart.php

示例4: priceCalculation

 /**
  * Price calculation / Get product price
  *
  * @param integer $id_shop Shop id
  * @param integer $id_product Product id
  * @param integer $id_product_attribute Product attribute id
  * @param integer $id_country Country id
  * @param integer $id_state State id
  * @param integer $id_currency Currency id
  * @param integer $id_group Group id
  * @param integer $quantity Quantity Required for Specific prices : quantity discount application
  * @param boolean $use_tax with (1) or without (0) tax
  * @param integer $decimals Number of decimals returned
  * @param boolean $only_reduc Returns only the reduction amount
  * @param boolean $use_reduc Set if the returned amount will include reduction
  * @param boolean $with_ecotax insert ecotax in price output.
  * @param variable_reference $specific_price_output
  * 	If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object
  * @return float Product price
  **/
 public static function priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction, $id_customer = 0, $use_customer_price = true, $id_cart = 0, $real_quantity = 0)
 {
     static $address = null;
     if ($address === null) {
         $address = new Address();
     }
     if (!$use_customer_price) {
         $id_customer = 0;
     }
     $cache_id = $id_product . '-' . $id_shop . '-' . $id_currency . '-' . $id_country . '-' . $id_state . '-' . $zipcode . '-' . $id_group . '-' . $quantity . '-' . (int) $id_product_attribute . '-' . ($use_tax ? '1' : '0') . '-' . $decimals . '-' . ($only_reduc ? '1' : '0') . '-' . ($use_reduc ? '1' : '0') . '-' . $with_ecotax . '-' . $id_customer;
     // reference parameter is filled before any returns
     $specific_price = SpecificPrice::getSpecificPrice((int) $id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity, $id_product_attribute, $id_customer, $id_cart, $real_quantity);
     if (isset(self::$_prices[$cache_id])) {
         return self::$_prices[$cache_id];
     }
     // fetch price & attribute price
     $cache_id_2 = $id_product;
     if (!isset(self::$_pricesLevel2[$cache_id_2])) {
         $sql = new DbQuery();
         $sql->select('product_shop.`price`, product_shop.`ecotax`');
         $sql->from('product', 'p');
         $sql->join(Shop::addSqlAssociation('product', 'p'));
         $sql->where('p.`id_product` = ' . (int) $id_product);
         if (Combination::isFeatureActive()) {
             $sql->select('product_attribute_shop.id_product_attribute, product_attribute_shop.`price` AS attribute_price, product_attribute_shop.default_on');
             $sql->leftJoin('product_attribute', 'pa', 'pa.`id_product` = p.`id_product`');
             $sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.id_shop =' . (int) $id_shop));
         } else {
             $sql->select('0 as id_product_attribute');
         }
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
         foreach ($res as $row) {
             $array_tmp = array('price' => $row['price'], 'ecotax' => $row['ecotax'], 'attribute_price' => isset($row['attribute_price']) ? $row['attribute_price'] : null);
             self::$_pricesLevel2[$cache_id_2][(int) $row['id_product_attribute']] = $array_tmp;
             if (isset($row['default_on']) && $row['default_on'] == 1) {
                 self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
             }
         }
     }
     if (!isset(self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute])) {
         return;
     }
     $result = self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute];
     if (!$specific_price || $specific_price['price'] < 0) {
         $price = (double) $result['price'];
     } else {
         $price = (double) $specific_price['price'];
     }
     // convert only if the specific price is in the default currency (id_currency = 0)
     if (!$specific_price || !($specific_price['price'] >= 0 && $specific_price['id_currency'])) {
         $price = Tools::convertPrice($price, $id_currency);
     }
     // Attribute price
     if (is_array($result) && (!$specific_price || !$specific_price['id_product_attribute'] || $specific_price['price'] < 0)) {
         $attribute_price = Tools::convertPrice($result['attribute_price'] !== null ? (double) $result['attribute_price'] : 0, $id_currency);
         if ($id_product_attribute !== false && !is_null($id_product_attribute)) {
             // If you want the default combination, please use NULL value instead
             $price += $attribute_price;
         }
     }
     // Tax
     $address->id_country = $id_country;
     $address->id_state = $id_state;
     $address->postcode = $zipcode;
     $tax_manager = TaxManagerFactory::getManager($address, Product::getIdTaxRulesGroupByIdProduct((int) $id_product));
     $product_tax_calculator = $tax_manager->getTaxCalculator();
     // Add Tax
     if ($use_tax) {
         $price = $product_tax_calculator->addTaxes($price);
     }
     $price = Tools::ps_round($price, $decimals);
     // Reduction
     $reduc = 0;
     if (($only_reduc || $use_reduc) && $specific_price) {
         if ($specific_price['reduction_type'] == 'amount') {
             $reduction_amount = $specific_price['reduction'];
             if (!$specific_price['id_currency']) {
                 $reduction_amount = Tools::convertPrice($reduction_amount, $id_currency);
             }
             $reduc = Tools::ps_round(!$use_tax ? $product_tax_calculator->removeTaxes($reduction_amount) : $reduction_amount, $decimals);
//.........这里部分代码省略.........
开发者ID:jicheng17,项目名称:vipinsg,代码行数:101,代码来源:Product.php

示例5: getTaxesInformations

 public static function getTaxesInformations($row, Context $context = null)
 {
     static $address = null;
     if ($context === null) {
         $context = Context::getContext();
     }
     if ($address === null) {
         $address = new Address();
     }
     $address->id_country = (int) $context->country->id;
     $address->id_state = 0;
     $address->postcode = 0;
     $tax_manager = TaxManagerFactory::getManager($address, Product::getIdTaxRulesGroupByIdProduct((int) $row['id_product'], $context));
     $row['rate'] = $tax_manager->getTaxCalculator()->getTotalRate();
     $row['tax_name'] = $tax_manager->getTaxCalculator()->getTaxesName();
     return $row;
 }
开发者ID:yewed,项目名称:share,代码行数:17,代码来源:Product.php

示例6: setSpecificPrice

 /**
  * Set specific price of the product
  * @param object $order
  */
 protected function setSpecificPrice(Order $order)
 {
     $this->reduction_amount = 0.0;
     $this->reduction_percent = 0.0;
     $this->reduction_amount_tax_incl = 0.0;
     $this->reduction_amount_tax_excl = 0.0;
     if ($this->specificPrice) {
         switch ($this->specificPrice['reduction_type']) {
             case 'percentage':
                 $this->reduction_percent = (double) $this->specificPrice['reduction'] * 100;
                 break;
             case 'amount':
                 $price = Tools::convertPrice($this->specificPrice['reduction'], $order->id_currency);
                 $this->reduction_amount = (double) (!$this->specificPrice['id_currency'] ? $price : $this->specificPrice['reduction']);
                 $id_tax_rules = (int) Product::getIdTaxRulesGroupByIdProduct((int) $this->specificPrice['id_product']);
                 $tax_manager = TaxManagerFactory::getManager($this->vat_address, $id_tax_rules);
                 $this->tax_calculator = $tax_manager->getTaxCalculator();
                 $this->reduction_amount_tax_incl = $this->reduction_amount;
                 $this->reduction_amount_tax_excl = Tools::ps_round($this->tax_calculator->removeTaxes($this->reduction_amount_tax_incl), 2);
                 break;
         }
     }
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:27,代码来源:OrderDetail.php

示例7: setSpecificPrice

 /**
  * Set specific price of the product
  * @param object $order
  */
 protected function setSpecificPrice($id_specific_price, $id_product, $id_currency)
 {
     $specificPrice = new AphSpecificPrice($id_specific_price);
     $reduction_amount = 0.0;
     $reduction_percent = 0.0;
     $reduction_amount_tax_incl = 0.0;
     $reduction_amount_tax_excl = 0.0;
     if ($specificPrice) {
         switch ($specificPrice['reduction_type']) {
             case 'percentage':
                 $reduction_percent = (double) $specificPrice['reduction'] * 100;
                 break;
             case 'amount':
                 $price = Tools::convertPrice($specificPrice['reduction'], $id_currency);
                 $reduction_amount = !$specificPrice['id_currency'] ? (double) $price : (double) $specificPrice['reduction'];
                 $id_tax_rules = (int) Product::getIdTaxRulesGroupByIdProduct((int) $specificPrice['id_product'], $context);
                 $tax_manager = TaxManagerFactory::getManager($vat_address, $id_tax_rules);
                 $tax_calculator = $tax_manager->getTaxCalculator();
                 if ($specificPrice['reduction_tax']) {
                     $reduction_amount_tax_incl = $reduction_amount;
                     $reduction_amount_tax_excl = Tools::ps_round($tax_calculator->removeTaxes($reduction_amount), _PS_PRICE_COMPUTE_PRECISION_);
                 } else {
                     $reduction_amount_tax_incl = Tools::ps_round($tax_calculator->addTaxes($reduction_amount), _PS_PRICE_COMPUTE_PRECISION_);
                     $reduction_amount_tax_excl = $reduction_amount;
                 }
                 break;
         }
     }
 }
开发者ID:paolobattistella,项目名称:aphro,代码行数:33,代码来源:calendar.php

示例8: setSpecificPrice

 /**
  * Set specific price of the product
  * @param object $order
  */
 protected function setSpecificPrice(Order $order, $product = null)
 {
     $this->reduction_amount = 0.0;
     $this->reduction_percent = 0.0;
     $this->reduction_amount_tax_incl = 0.0;
     $this->reduction_amount_tax_excl = 0.0;
     if ($this->specificPrice) {
         switch ($this->specificPrice['reduction_type']) {
             case 'percentage':
                 $this->reduction_percent = (double) $this->specificPrice['reduction'] * 100;
                 break;
             case 'amount':
                 $price = Tools::convertPrice($this->specificPrice['reduction'], $order->id_currency);
                 $this->reduction_amount = !$this->specificPrice['id_currency'] ? (double) $price : (double) $this->specificPrice['reduction'];
                 if ($product !== null) {
                     $this->setContext((int) $product['id_shop']);
                 }
                 $id_tax_rules = (int) Product::getIdTaxRulesGroupByIdProduct((int) $this->specificPrice['id_product'], $this->context);
                 $tax_manager = TaxManagerFactory::getManager($this->vat_address, $id_tax_rules);
                 $this->tax_calculator = $tax_manager->getTaxCalculator();
                 if ($this->reduction_tax) {
                     $this->reduction_amount_tax_incl = $this->reduction_amount;
                     $this->reduction_amount_tax_excl = Tools::ps_round($this->tax_calculator->removeTaxes($this->reduction_amount), _PS_PRICE_COMPUTE_PRECISION_);
                 } else {
                     $this->reduction_amount_tax_incl = Tools::ps_round($this->tax_calculator->addTaxes($this->reduction_amount), _PS_PRICE_COMPUTE_PRECISION_);
                     $this->reduction_amount_tax_excl = $this->reduction_amount;
                 }
                 break;
         }
     }
 }
开发者ID:nmardones,项目名称:PrestaShop,代码行数:35,代码来源:OrderDetail.php

示例9: priceCalculation


//.........这里部分代码省略.........
                         //$base_price_wt - (($row['reduction'] * $base_price_wt) / 100);
                     }
                 } else {
                     $row['price'] = 0;
                     //$row['price_wt'];
                 }
                 $array_tmp = array('price' => $row['price'], 'ecotax' => !empty($row['ecotax']), 'attribute_price' => isset($row['attribute_price']) ? $row['attribute_price'] : null);
                 self::$_pricesLevel2[$cache_id_2][(int) $row['id_product_attribute']] = $array_tmp;
                 if (isset($row['default_on']) && $row['default_on'] == 1) {
                     self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
                 }
             }
         }
     }
     if (!isset(self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute])) {
         return;
     }
     $result = self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute];
     if (!$specific_price || $specific_price['price'] < 0) {
         $price = (double) $result['price'];
     } else {
         $price = (double) $specific_price['price'];
     }
     if (!$specific_price || !($specific_price['price'] >= 0 && $specific_price['id_currency'])) {
         $price = Tools::convertPrice($price, $id_currency);
         if (isset($specific_price['price'])) {
             $specific_price['price'] = $price;
         }
     }
     if (is_array($result) && (!$specific_price || !$specific_price['id_product_attribute'] || $specific_price['price'] < 0)) {
         $attribute_price = Tools::convertPrice($result['attribute_price'] !== null ? (double) $result['attribute_price'] : 0, $id_currency);
         if ($id_product_attribute !== false) {
             $price += $attribute_price;
         }
     }
     $address->id_country = $id_country;
     $address->id_state = $id_state;
     $address->postcode = $zipcode;
     $tax_manager = TaxManagerFactory::getManager($address, Product::getIdTaxRulesGroupByIdProduct((int) $id_product, $context));
     $product_tax_calculator = $tax_manager->getTaxCalculator();
     if ($use_tax) {
         $price = $product_tax_calculator->addTaxes($price);
     }
     if (($result['ecotax'] || isset($result['attribute_ecotax'])) && $with_ecotax) {
         $ecotax = $result['ecotax'];
         if (isset($result['attribute_ecotax']) && $result['attribute_ecotax'] > 0) {
             $ecotax = $result['attribute_ecotax'];
         }
         if ($id_currency) {
             $ecotax = Tools::convertPrice($ecotax, $id_currency);
         }
         if ($use_tax) {
             $tax_manager = TaxManagerFactory::getManager($address, (int) Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID'));
             $ecotax_tax_calculator = $tax_manager->getTaxCalculator();
             $price += $ecotax_tax_calculator->addTaxes($ecotax);
         } else {
             $price += $ecotax;
         }
     }
     $specific_price_reduction = 0;
     if (($only_reduc || $use_reduc) && $specific_price) {
         if ($specific_price['reduction_type'] == 'amount') {
             $reduction_amount = $specific_price['reduction'];
             if (!$specific_price['id_currency']) {
                 $reduction_amount = Tools::convertPrice($reduction_amount, $id_currency);
             }
             $specific_price_reduction = $reduction_amount;
             if (!$use_tax && $specific_price['reduction_tax']) {
                 $specific_price_reduction = $product_tax_calculator->removeTaxes($specific_price_reduction);
             }
             if ($use_tax && !$specific_price['reduction_tax']) {
                 $specific_price_reduction = $product_tax_calculator->addTaxes($specific_price_reduction);
             }
         } else {
             $specific_price_reduction = $price * $specific_price['reduction'];
         }
     }
     if ($use_reduc) {
         $price -= $specific_price_reduction;
     }
     if ($use_group_reduction) {
         $reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
         if ($reduction_from_category !== false) {
             $group_reduction = $price * (double) $reduction_from_category;
         } else {
             // apply group reduction if there is no group reduction for this category
             $group_reduction = ($reduc = Group::getReductionByIdGroup($id_group)) != 0 ? $price * $reduc / 100 : 0;
         }
         $price -= $group_reduction;
     }
     if ($only_reduc) {
         return Tools::ps_round($specific_price_reduction, $decimals);
     }
     $price = Tools::ps_round($price, $decimals);
     if ($price < 0) {
         $price = 0;
     }
     self::$_prices[$cache_id] = $price;
     return self::$_prices[$cache_id];
 }
开发者ID:paolobattistella,项目名称:aphro,代码行数:101,代码来源:Product.php

示例10: validateOrder


//.........这里部分代码省略.........
                $query = 'INSERT INTO `' . _DB_PREFIX_ . 'order_detail`
					(`id_order`, `product_id`, `product_attribute_id`, `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`, `reduction_percent`, `reduction_amount`, `group_reduction`, `product_quantity_discount`, `product_ean13`, `product_upc`, `product_reference`, `product_supplier_reference`, `product_weight`, `tax_name`, `tax_rate`, `ecotax`, `ecotax_tax_rate`, `discount_quantity_applied`, `download_deadline`, `download_hash`)
				VALUES ';
                $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
                Product::addCustomizationPrice($products, $customizedDatas);
                $outOfStock = false;
                $store_all_taxes = array();
                foreach ($products as $key => $product) {
                    $productQuantity = (int) Product::getQuantity((int) $product['id_product'], $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL);
                    $quantityInStock = $productQuantity - (int) $product['cart_quantity'] < 0 ? $productQuantity : (int) $product['cart_quantity'];
                    if ($id_order_state != Configuration::get('PS_OS_CANCELED') and $id_order_state != Configuration::get('PS_OS_ERROR')) {
                        if (Product::updateQuantity($product, (int) $order->id)) {
                            $product['stock_quantity'] -= $product['cart_quantity'];
                        }
                        if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
                            $outOfStock = true;
                        }
                        Product::updateDefaultAttribute($product['id_product']);
                    }
                    $price = Product::getPriceStatic((int) $product['id_product'], false, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 6, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                    $price_wt = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 2, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                    /* Store tax info */
                    $id_country = (int) Country::getDefaultCountryId();
                    $id_state = 0;
                    $id_county = 0;
                    $rate = 0;
                    $id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
                    $address_infos = Address::getCountryAndState($id_address);
                    if ($address_infos['id_country']) {
                        $id_country = (int) $address_infos['id_country'];
                        $id_state = (int) $address_infos['id_state'];
                        $id_county = (int) County::getIdCountyByZipCode($address_infos['id_state'], $address_infos['postcode']);
                    }
                    $allTaxes = TaxRulesGroup::getTaxes((int) Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product']), $id_country, $id_state, $id_county);
                    // If its a freeOrder, there will be no calculation
                    if ($order->total_products > 0) {
                        // remove order discount quotepart on product price in order to obtain the real tax
                        $ratio = $price / $order->total_products;
                        $order_reduction_amount = (double) abs($cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS)) * $ratio;
                        $tmp_price = $price - $order_reduction_amount;
                        foreach ($allTaxes as $res) {
                            if (!isset($store_all_taxes[$res->id])) {
                                $store_all_taxes[$res->id] = array();
                                $store_all_taxes[$res->id]['amount'] = 0;
                            }
                            $store_all_taxes[$res->id]['name'] = $res->name[(int) $order->id_lang];
                            $store_all_taxes[$res->id]['rate'] = $res->rate;
                            $unit_tax_amount = $tmp_price * ($res->rate * 0.01);
                            $tmp_price = $tmp_price + $unit_tax_amount;
                            $store_all_taxes[$res->id]['amount'] += $unit_tax_amount * $product['cart_quantity'];
                        }
                    }
                    /* End */
                    // Add some informations for virtual products
                    $deadline = '0000-00-00 00:00:00';
                    $download_hash = null;
                    if ($id_product_download = ProductDownload::getIdFromIdProduct((int) $product['id_product'])) {
                        $productDownload = new ProductDownload((int) $id_product_download);
                        $deadline = $productDownload->getDeadLine();
                        $download_hash = $productDownload->getHash();
                    }
                    // Exclude VAT
                    if (!_PS_TAX_) {
                        $product['tax'] = 0;
                        $product['rate'] = 0;
                        $tax_rate = 0;
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:67,代码来源:PaymentModule.php

示例11: getProducts


//.........这里部分代码省略.........
                $pa_ids[] = $row['id_product_attribute'];
            }
        }
        // Thus you can avoid one query per product, because there will be only one query for all the products of the cart
        Product::cacheProductsFeatures($products_ids);
        Cart::cacheSomeAttributesLists($pa_ids, $this->id_lang);
        $this->_products = array();
        if (empty($result)) {
            return array();
        }
        $cart_shop_context = Context::getContext()->cloneContext();
        foreach ($result as &$row) {
            if (isset($row['ecotax_attr']) && $row['ecotax_attr'] > 0) {
                $row['ecotax'] = (double) $row['ecotax_attr'];
            }
            $row['stock_quantity'] = (int) $row['quantity'];
            // for compatibility with 1.2 themes
            $row['quantity'] = (int) $row['cart_quantity'];
            if (isset($row['id_product_attribute']) && (int) $row['id_product_attribute'] && isset($row['weight_attribute'])) {
                $row['weight'] = (double) $row['weight_attribute'];
            }
            if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
                $address_id = (int) $this->id_address_invoice;
            } else {
                $address_id = (int) $row['id_address_delivery'];
            }
            if (!Address::addressExists($address_id)) {
                $address_id = null;
            }
            if ($cart_shop_context->shop->id != $row['id_shop']) {
                $cart_shop_context->shop = new Shop((int) $row['id_shop']);
            }
            $address = Address::initialize($address_id, true);
            $id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $row['id_product'], $cart_shop_context);
            $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
            $row['price'] = Product::getPriceStatic((int) $row['id_product'], false, isset($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 6, null, false, true, $row['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $address_id, $specific_price_output, false, true, $cart_shop_context);
            switch (Configuration::get('PS_ROUND_TYPE')) {
                case Order::ROUND_TOTAL:
                case Order::ROUND_LINE:
                    $row['total'] = Tools::ps_round($row['price'] * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
                    $row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']) * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
                    break;
                case Order::ROUND_ITEM:
                default:
                    $row['total'] = Tools::ps_round($row['price'], _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
                    $row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']), _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
                    break;
            }
            $row['price_wt'] = $tax_calculator->addTaxes($row['price']);
            $row['description_short'] = Tools::nl2br($row['description_short']);
            /**
             * ABU: correction bug
             * https://github.com/PrestaShop/PrestaShop/commit/bbc5591495b12021aa95421af1a0d27acd7a378e?diff=split
             */
            /*if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0)
            		{
            			$cache_id = 'Cart::getProducts_'.'-pai_id_image-'.(int)$row['id_product'].'-'.(int)$this->id_lang.'-'.(int)$row['id_shop'];
            			if (!Cache::isStored($cache_id))
            			{
            				$row2 = Db::getInstance()->getRow('
            					SELECT image_shop.`id_image` id_image, il.`legend`
            					FROM `'._DB_PREFIX_.'image` i
            					JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop='.(int)$row['id_shop'].')
            					LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
            					WHERE i.`id_product` = '.(int)$row['id_product'].' AND image_shop.`cover` = 1'
            				);
开发者ID:ecSta,项目名称:prestanight,代码行数:67,代码来源:Cart.php

示例12: create

    public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true)
    {
        $currency = new Currency((int) $order->id_currency);
        $order_slip = new OrderSlip();
        $order_slip->id_customer = (int) $order->id_customer;
        $order_slip->id_order = (int) $order->id;
        $order_slip->conversion_rate = $currency->conversion_rate;
        if ($add_tax) {
            $add_or_remove = 'add';
            $inc_or_ex_1 = 'excl';
            $inc_or_ex_2 = 'incl';
        } else {
            $add_or_remove = 'remove';
            $inc_or_ex_1 = 'incl';
            $inc_or_ex_2 = 'excl';
        }
        $order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = 0;
        $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = 0;
        $order_slip->partial = 0;
        if ($shipping_cost !== false) {
            $order_slip->shipping_cost = true;
            $carrier = new Carrier((int) $order->id_carrier);
            $address = Address::initialize($order->id_address_delivery, false);
            $tax_calculator = $carrier->getTaxCalculator($address);
            $order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = $shipping_cost === null ? $order->{'total_shipping_tax_' . $inc_or_ex_1} : (double) $shipping_cost;
            if ($tax_calculator instanceof TaxCalculator) {
                $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($order_slip->{'total_shipping_tax_' . $inc_or_ex_1}), _PS_PRICE_COMPUTE_PRECISION_);
            } else {
                $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
            }
        } else {
            $order_slip->shipping_cost = false;
        }
        $order_slip->amount = 0;
        $order_slip->{'total_products_tax_' . $inc_or_ex_1} = 0;
        $order_slip->{'total_products_tax_' . $inc_or_ex_2} = 0;
        foreach ($product_list as &$product) {
            $order_detail = new OrderDetail((int) $product['id_order_detail']);
            $price = (double) $product['unit_price'];
            $quantity = (int) $product['quantity'];
            $order_slip_resume = OrderSlip::getProductSlipResume((int) $order_detail->id);
            if ($quantity + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
                $quantity = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
            }
            if ($quantity == 0) {
                continue;
            }
            $order_detail->product_quantity_refunded += $quantity;
            $order_detail->save();
            $address = Address::initialize($order->id_address_invoice, false);
            $id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $order_detail->product_id);
            $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
            $order_slip->{'total_products_tax_' . $inc_or_ex_1} += $price * $quantity;
            if (in_array(Configuration::get('PS_ROUND_TYPE'), array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
                if (!isset($total_products[$id_tax_rules_group])) {
                    $total_products[$id_tax_rules_group] = 0;
                } else {
                    if (!isset($total_products[$id_tax_rules_group . '_' . $id_address])) {
                        $total_products[$id_tax_rules_group . '_' . $id_address] = 0;
                    }
                }
            }
            $product_tax_incl_line = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price) * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
            switch (Configuration::get('PS_ROUND_TYPE')) {
                case Order::ROUND_ITEM:
                    $product_tax_incl = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_) * $quantity;
                    $total_products[$id_tax_rules_group] += $product_tax_incl;
                    break;
                case Order::ROUND_LINE:
                    $product_tax_incl = $product_tax_incl_line;
                    $total_products[$id_tax_rules_group] += $product_tax_incl;
                    break;
                case Order::ROUND_TOTAL:
                    $product_tax_incl = $product_tax_incl_line;
                    $total_products[$id_tax_rules_group . '_' . $id_address] += $price * $quantity;
                    break;
            }
            $product['unit_price_tax_' . $inc_or_ex_1] = $price;
            $product['unit_price_tax_' . $inc_or_ex_2] = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
            $product['total_price_tax_' . $inc_or_ex_1] = Tools::ps_round($price * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
            $product['total_price_tax_' . $inc_or_ex_2] = Tools::ps_round($product_tax_incl, _PS_PRICE_COMPUTE_PRECISION_);
            $product['product_id'] = $order_detail->product_id;
        }
        unset($product);
        foreach ($total_products as $key => $price) {
            if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
                $tmp = explode('_', $key);
                $address = Address::initialize((int) $tmp[1], true);
                $tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
                $order_slip->{'total_products_tax_' . $inc_or_ex_2} += Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
            } else {
                $order_slip->{'total_products_tax_' . $inc_or_ex_2} += $price;
            }
        }
        $order_slip->{'total_products_tax_' . $inc_or_ex_2} -= (double) $amount && !$amount_choosen ? (double) $amount : 0;
        $order_slip->amount = $amount_choosen ? (double) $amount : $order_slip->{'total_products_tax_' . $inc_or_ex_1};
        $order_slip->shipping_cost_amount = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
        if ((double) $amount && !$amount_choosen) {
            $order_slip->order_slip_type = 1;
        }
//.........这里部分代码省略.........
开发者ID:ankkal,项目名称:SPN_project,代码行数:101,代码来源:OrderSlip.php

示例13: prepareTaxClass

 /**
  * @return string
  */
 public function prepareTaxClass()
 {
     $taxRulesGroups = TaxRulesGroupCore::getTaxRulesGroups(true);
     $idTaxRulesGroup = (int) Product::getIdTaxRulesGroupByIdProduct($this->currentProduct->id, null);
     foreach ($taxRulesGroups as $taxRulesGroup) {
         if ($taxRulesGroup['id_tax_rules_group'] == $idTaxRulesGroup) {
             $tax = ShopgateSettings::getTaxItemByTaxRuleGroupId($idTaxRulesGroup);
             $taxClassName = '';
             if (is_array($tax->name) && !empty($tax->name[$this->getPlugin()->getLanguageId()])) {
                 $taxClassName = $tax->name[$this->getPlugin()->getLanguageId()];
             } else {
                 if (is_array($tax->name)) {
                     // fallback: just in case for older Prestashop versions
                     $taxClassName = reset($tax->name);
                 }
             }
             return $taxClassName;
         }
     }
     return '';
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:24,代码来源:Item.php

示例14: create

 public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true)
 {
     $currency = new Currency((int) $order->id_currency);
     $order_slip = new OrderSlip();
     $order_slip->id_customer = (int) $order->id_customer;
     $order_slip->id_order = (int) $order->id;
     $order_slip->conversion_rate = $currency->conversion_rate;
     if ($add_tax) {
         $add_or_remove = 'add';
         $inc_or_ex_1 = 'excl';
         $inc_or_ex_2 = 'incl';
     } else {
         $add_or_remove = 'remove';
         $inc_or_ex_1 = 'incl';
         $inc_or_ex_2 = 'excl';
     }
     $order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = 0;
     $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = 0;
     $order_slip->partial = 0;
     if ($shipping_cost !== false) {
         $order_slip->shipping_cost = true;
         $carrier = new Carrier((int) $order->id_carrier);
         $address = Address::initialize($order->id_address_delivery, false);
         $tax_calculator = $carrier->getTaxCalculator($address);
         $order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = $shipping_cost === null ? $order->{'total_shipping_tax_' . $inc_or_ex_1} : (double) $shipping_cost;
         if ($tax_calculator instanceof TaxCalculator) {
             $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($order_slip->{'total_shipping_tax_' . $inc_or_ex_1}), _PS_PRICE_COMPUTE_PRECISION_);
         } else {
             $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
         }
     } else {
         $order_slip->shipping_cost = false;
     }
     $order_slip->amount = 0;
     $order_slip->{'total_products_tax_' . $inc_or_ex_1} = 0;
     $order_slip->{'total_products_tax_' . $inc_or_ex_2} = 0;
     foreach ($product_list as &$product) {
         $order_detail = new OrderDetail((int) $product['id_order_detail']);
         $price = (double) $product['unit_price'];
         $quantity = (int) $product['quantity'];
         $order_slip_resume = OrderSlip::getProductSlipResume((int) $order_detail->id);
         if ($quantity + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
             $quantity = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
         }
         if ($quantity == 0) {
             continue;
         }
         if (!Tools::isSubmit('cancelProduct') && $order->hasBeenPaid()) {
             $order_detail->product_quantity_refunded += $quantity;
         }
         $order_detail->save();
         $address = Address::initialize($order->id_address_invoice, false);
         $id_address = (int) $address->id;
         $id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $order_detail->product_id);
         $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
         $order_slip->{'total_products_tax_' . $inc_or_ex_1} += $price * $quantity;
         if (in_array(Configuration::get('PS_ROUND_TYPE'), array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
             if (!isset($total_products[$id_tax_rules_group])) {
                 $total_products[$id_tax_rules_group] = 0;
             }
         } else {
             if (!isset($total_products[$id_tax_rules_group . '_' . $id_address])) {
                 $total_products[$id_tax_rules_group . '_' . $id_address] = 0;
             }
         }
         $product_tax_incl_line = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price) * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
         switch (Configuration::get('PS_ROUND_TYPE')) {
             case Order::ROUND_ITEM:
                 $product_tax_incl = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_) * $quantity;
                 $total_products[$id_tax_rules_group] += $product_tax_incl;
                 break;
             case Order::ROUND_LINE:
                 $product_tax_incl = $product_tax_incl_line;
                 $total_products[$id_tax_rules_group] += $product_tax_incl;
                 break;
             case Order::ROUND_TOTAL:
                 $product_tax_incl = $product_tax_incl_line;
                 $total_products[$id_tax_rules_group . '_' . $id_address] += $price * $quantity;
                 break;
         }
         $product['unit_price_tax_' . $inc_or_ex_1] = $price;
         $product['unit_price_tax_' . $inc_or_ex_2] = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
         $product['total_price_tax_' . $inc_or_ex_1] = Tools::ps_round($price * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
         $product['total_price_tax_' . $inc_or_ex_2] = Tools::ps_round($product_tax_incl, _PS_PRICE_COMPUTE_PRECISION_);
     }
     unset($product);
     foreach ($total_products as $key => $price) {
         if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
             $tmp = explode('_', $key);
             $address = Address::initialize((int) $tmp[1], true);
             $tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
             $order_slip->{'total_products_tax_' . $inc_or_ex_2} += Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
         } else {
             $order_slip->{'total_products_tax_' . $inc_or_ex_2} += $price;
         }
     }
     $order_slip->{'total_products_tax_' . $inc_or_ex_2} -= (double) $amount && !$amount_choosen ? (double) $amount : 0;
     $order_slip->amount = $amount_choosen ? (double) $amount : $order_slip->{'total_products_tax_' . $inc_or_ex_1};
     $order_slip->shipping_cost_amount = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
     if ((double) $amount && !$amount_choosen) {
//.........这里部分代码省略.........
开发者ID:ortegon000,项目名称:tienda,代码行数:101,代码来源:OrderSlip.php

示例15: getProductTaxRateViaRules

 /**
  * Return the product tax rate using the tax rules system
  *
  * @param integer $id_product
  * @param integer $id_country
  * @return Tax
  */
 public static function getProductTaxRateViaRules($id_product, $id_country, $id_state, $id_county)
 {
     if (!isset(self::$_product_tax_via_rules[$id_product . '-' . $id_country . '-' . $id_state . '-' . $id_county])) {
         self::$_product_tax_via_rules[$id_product . '-' . $id_country . '-' . $id_county] = TaxRulesGroup::getTaxesRate((int) Product::getIdTaxRulesGroupByIdProduct((int) $id_product), (int) $id_country, (int) $id_state, (int) $id_county);
     }
     return self::$_product_tax_via_rules[$id_product . '-' . $id_country . '-' . $id_county];
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:14,代码来源:Tax.php


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