Definition at line 30 of file Data.php.
_calculatePrice | ( | $ | price, | |
$ | percent, | |||
$ | type | |||
) | [protected] |
applyTaxAfterDiscount | ( | $ | store = null |
) |
Check what taxes should be applied after discount
mixed | $store |
Definition at line 81 of file Data.php.
00082 { 00083 $storeId = Mage::app()->getStore($store)->getId(); 00084 if (!isset($this->_applyTaxAfterDiscount[$storeId])) { 00085 $this->_applyTaxAfterDiscount[$storeId] = (int)Mage::getStoreConfig( 00086 Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT, 00087 $store 00088 ); 00089 } 00090 return $this->_applyTaxAfterDiscount[$storeId]; 00091 }
applyTaxOnCustomPrice | ( | $ | store = null |
) |
Definition at line 515 of file Data.php.
00515 { 00516 return ((int) Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_BASED_ON, $store) == 0); 00517 }
applyTaxOnOriginalPrice | ( | $ | store = null |
) |
Definition at line 519 of file Data.php.
00519 { 00520 return ((int) Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_BASED_ON, $store) == 1); 00521 }
discountTax | ( | $ | store = null |
) |
Definition at line 505 of file Data.php.
00506 { 00507 return ((int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DISCOUNT_TAX, $store) == 1); 00508 }
displayBothPrices | ( | ) |
Definition at line 365 of file Data.php.
00366 { 00367 return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH; 00368 }
displayCartBothPrices | ( | $ | store = null |
) |
Check if need display cart prices excluding and including tax
mixed | $store |
Definition at line 215 of file Data.php.
00216 { 00217 return $this->displayTaxColumn($store) == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH; 00218 }
displayCartPriceExclTax | ( | $ | store = null |
) |
Check if need display cart prices excluding price
mixed | $store |
Definition at line 204 of file Data.php.
00205 { 00206 return $this->displayTaxColumn($store) == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX; 00207 }
displayCartPriceInclTax | ( | $ | store = null |
) |
Check if need display cart prices included tax
mixed | $store |
Definition at line 193 of file Data.php.
00194 { 00195 return $this->displayTaxColumn($store) == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX; 00196 }
displayFullSummary | ( | $ | store = null |
) |
Check if need display full tax summary information in totals block
mixed | $store |
Definition at line 171 of file Data.php.
00172 { 00173 return ((int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DISPLAY_FULL_SUMMARY, $store) == 1); 00174 }
displayPriceExcludingTax | ( | ) |
Definition at line 360 of file Data.php.
00361 { 00362 return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX; 00363 }
displayPriceIncludingTax | ( | ) |
Definition at line 355 of file Data.php.
00356 { 00357 return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX; 00358 }
displayShippingBothPrices | ( | ) |
Definition at line 417 of file Data.php.
00418 { 00419 return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH; 00420 }
displayShippingPriceExcludingTax | ( | ) |
Definition at line 412 of file Data.php.
00413 { 00414 return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX; 00415 }
displayShippingPriceIncludingTax | ( | ) |
Definition at line 407 of file Data.php.
00408 { 00409 return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX; 00410 }
displayTaxColumn | ( | $ | store = null |
) |
Check if need display tax column in for shopping cart/order items
mixed | $store |
Definition at line 226 of file Data.php.
00227 { 00228 if (is_null($this->_displayTaxColumn)) { 00229 $this->_displayTaxColumn = (int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DISPLAY_TAX_COLUMN, $store); 00230 } 00231 return $this->_displayTaxColumn; 00232 }
displayZeroTax | ( | $ | store = null |
) |
Check if need display zero tax in subtotal
mixed | $store |
Definition at line 182 of file Data.php.
00183 { 00184 return Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DISPLAY_ZERO_TAX, $store); 00185 }
getIncExcTaxLabel | ( | $ | flag | ) |
Definition at line 380 of file Data.php.
00381 { 00382 $text = $this->getIncExcText($flag); 00383 return $text ? ' <span class="tax-flag">('.$text.')</span>' : ''; 00384 }
getIncExcText | ( | $ | flag, | |
$ | store = null | |||
) |
getPrice | ( | $ | product, | |
$ | price, | |||
$ | includingTax = null , |
|||
$ | shippingAddress = null , |
|||
$ | billingAddress = null , |
|||
$ | ctc = null , |
|||
$ | store = null , |
|||
$ | priceIncludesTax = null | |||
) |
Get product price with all tax settings processing
Mage_Catalog_Model_Product | $product | |
float | $price inputed product price | |
bool | $includingTax return price include tax flag | |
null|Mage_Customer_Model_Address | $shippingAddress | |
null|Mage_Customer_Model_Address | $billingAddress | |
null|int | $ctc customer tax class | |
mixed | $store | |
bool | $priceIncludesTax flag what price parameter contain tax |
Definition at line 280 of file Data.php.
00281 { 00282 $store = Mage::app()->getStore($store); 00283 if (!$this->needPriceConversion($store)) { 00284 return $store->roundPrice($price); 00285 } 00286 if (is_null($priceIncludesTax)) { 00287 $priceIncludesTax = $this->priceIncludesTax($store); 00288 } 00289 00290 $percent = $product->getTaxPercent(); 00291 $includingPercent = null; 00292 00293 $taxClassId = $product->getTaxClassId(); 00294 if (is_null($percent)) { 00295 if ($taxClassId) { 00296 $request = Mage::getSingleton('tax/calculation')->getRateRequest($shippingAddress, $billingAddress, $ctc, $store); 00297 $percent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId)); 00298 } 00299 } 00300 if ($taxClassId && $priceIncludesTax) { 00301 $request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false, $store); 00302 $includingPercent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId)); 00303 } 00304 00305 if ($percent === false || is_null($percent)) { 00306 if ($priceIncludesTax && !$includingPercent) { 00307 return $price; 00308 } 00309 } 00310 00311 $product->setTaxPercent($percent); 00312 00313 if (!is_null($includingTax)) { 00314 if ($priceIncludesTax) { 00315 if ($includingTax) { 00316 $price = $this->_calculatePrice($price, $includingPercent, false); 00317 $price = $this->_calculatePrice($price, $percent, true); 00318 } else { 00319 $price = $this->_calculatePrice($price, $includingPercent, false); 00320 } 00321 } else { 00322 if ($includingTax) { 00323 $price = $this->_calculatePrice($price, $percent, true); 00324 } 00325 } 00326 } else { 00327 if ($priceIncludesTax) { 00328 switch ($this->getPriceDisplayType($store)) { 00329 case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: 00330 case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: 00331 $price = $this->_calculatePrice($price, $includingPercent, false); 00332 break; 00333 00334 case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: 00335 $price = $this->_calculatePrice($price, $includingPercent, false); 00336 $price = $this->_calculatePrice($price, $percent, true); 00337 break; 00338 } 00339 } else { 00340 switch ($this->getPriceDisplayType($store)) { 00341 case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: 00342 $price = $this->_calculatePrice($price, $percent, true); 00343 break; 00344 00345 case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: 00346 case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: 00347 break; 00348 } 00349 } 00350 } 00351 00352 return $store->roundPrice($price); 00353 }
getPriceDisplayType | ( | $ | store = null |
) |
Get product price display tax 1 - Excluding tax 2 - Including tax 3 - Both
mixed | $store |
Definition at line 117 of file Data.php.
00118 { 00119 $storeId = Mage::app()->getStore($store)->getId(); 00120 if (!isset($this->_priceDisplayType[$storeId])) { 00121 $this->_priceDisplayType[$storeId] = (int)Mage::getStoreConfig( 00122 Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, 00123 $store 00124 ); 00125 } 00126 return $this->_priceDisplayType[$storeId]; 00127 }
getPriceFormat | ( | $ | store = null |
) |
getPriceTaxSql | ( | $ | priceField, | |
$ | taxClassField | |||
) |
Definition at line 439 of file Data.php.
00440 { 00441 if (!$this->priceIncludesTax() && $this->displayPriceExcludingTax()) { 00442 return ''; 00443 } 00444 00445 $request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false); 00446 $defaultTaxes = Mage::getSingleton('tax/calculation')->getRatesForAllProductTaxClasses($request); 00447 00448 $request = Mage::getSingleton('tax/calculation')->getRateRequest(); 00449 $currentTaxes = Mage::getSingleton('tax/calculation')->getRatesForAllProductTaxClasses($request); 00450 00451 $defaultTaxString = $currentTaxString = ''; 00452 00453 $rateToVariable = array( 00454 'defaultTaxString'=>'defaultTaxes', 00455 'currentTaxString'=>'currentTaxes', 00456 ); 00457 foreach ($rateToVariable as $rateVariable=>$rateArray) { 00458 if ($$rateArray && is_array($$rateArray)) { 00459 $$rateVariable = ''; 00460 foreach ($$rateArray as $classId=>$rate) { 00461 if ($rate) { 00462 $$rateVariable .= "WHEN '{$classId}' THEN '".($rate/100)."'"; 00463 } 00464 } 00465 if ($$rateVariable) { 00466 $$rateVariable = "CASE {$taxClassField} {$$rateVariable} ELSE 0 END"; 00467 } 00468 } 00469 } 00470 00471 $result = ''; 00472 00473 if ($this->priceIncludesTax()) { 00474 if ($defaultTaxString) { 00475 $result = "-({$priceField}/(1+({$defaultTaxString}))*{$defaultTaxString})"; 00476 } 00477 if (!$this->displayPriceExcludingTax() && $currentTaxString) { 00478 $result .= "+(({$priceField}{$result})*{$currentTaxString})"; 00479 } 00480 } else { 00481 if ($this->displayPriceIncludingTax()) { 00482 if ($currentTaxString) { 00483 $result .= "+({$priceField}*{$currentTaxString})"; 00484 } 00485 } 00486 } 00487 return $result; 00488 }
getProductPrice | ( | $ | product, | |
$ | format = null | |||
) |
getShippingPrice | ( | $ | price, | |
$ | includingTax = null , |
|||
$ | shippingAddress = null , |
|||
$ | ctc = null , |
|||
$ | store = null | |||
) |
Definition at line 427 of file Data.php.
00427 { 00428 $pseudoProduct = new Varien_Object(); 00429 $pseudoProduct->setTaxClassId($this->getShippingTaxClass($store)); 00430 00431 $billingAddress = false; 00432 if ($shippingAddress && $shippingAddress->getQuote() && $shippingAddress->getQuote()->getBillingAddress()) { 00433 $billingAddress = $shippingAddress->getQuote()->getBillingAddress(); 00434 } 00435 00436 return $this->getPrice($pseudoProduct, $price, $includingTax, $shippingAddress, $billingAddress, $ctc, $store, $this->shippingPriceIncludesTax($store)); 00437 }
getShippingPriceDisplayType | ( | $ | store = null |
) |
Definition at line 396 of file Data.php.
00397 { 00398 00399 $storeId = Mage::app()->getStore($store)->getId(); 00400 if (!isset($this->_shippingPriceDisplayType[$storeId])) { 00401 $this->_shippingPriceDisplayType[$storeId] = 00402 (int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DISPLAY_SHIPPING, $store); 00403 } 00404 return $this->_shippingPriceDisplayType[$storeId]; 00405 }
getShippingTaxClass | ( | $ | store | ) |
Definition at line 422 of file Data.php.
00423 { 00424 return (int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $store); 00425 }
getTaxBasedOn | ( | $ | store = null |
) |
Definition at line 510 of file Data.php.
00511 { 00512 return Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_BASED_ON, $store); 00513 }
getTaxRatesByProductClass | ( | ) |
Get all tax rates for all product tax classes
array( value_{$productTaxVlassId} => $rate )
Definition at line 254 of file Data.php.
00255 { 00256 $result = array(); 00257 $calc = Mage::getSingleton('tax/calculation'); 00258 $rates = $calc->getRatesForAllProductTaxClasses($calc->getRateRequest()); 00259 00260 foreach ($rates as $class=>$rate) { 00261 $result["value_{$class}"] = $rate; 00262 } 00263 00264 return Zend_Json::encode($result); 00265 }
joinTaxClass | ( | $ | select, | |
$ | storeId, | |||
$ | priceTable = 'main_table' | |||
) |
Definition at line 490 of file Data.php.
00491 { 00492 $taxClassAttribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'tax_class_id'); 00493 $select->joinLeft( 00494 array('tax_class_d'=>$taxClassAttribute->getBackend()->getTable()), 00495 "tax_class_d.entity_id = {$priceTable}.entity_id AND tax_class_d.attribute_id = '{$taxClassAttribute->getId()}' 00496 AND tax_class_d.store_id = 0", 00497 array()); 00498 $select->joinLeft( 00499 array('tax_class_c'=>$taxClassAttribute->getBackend()->getTable()), 00500 "tax_class_c.entity_id = {$priceTable}.entity_id AND tax_class_c.attribute_id = '{$taxClassAttribute->getId()}' 00501 AND tax_class_c.store_id = '{$storeId}'", 00502 array()); 00503 }
needPriceConversion | ( | $ | store = null |
) |
Check if necessary do product price conversion If it necessary will be returned conversion type (minus or plus)
mixed | $store |
Definition at line 136 of file Data.php.
00137 { 00138 $res = false; 00139 if ($this->priceIncludesTax($store)) { 00140 switch ($this->getPriceDisplayType($store)) { 00141 case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: 00142 case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: 00143 return self::PRICE_CONVERSION_MINUS; 00144 00145 case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: 00146 $res = false; 00147 } 00148 } else { 00149 switch ($this->getPriceDisplayType($store)) { 00150 case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: 00151 case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: 00152 return self::PRICE_CONVERSION_PLUS; 00153 00154 case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: 00155 $res = false; 00156 } 00157 } 00158 00159 if ($res === false) { 00160 $res = $this->displayTaxColumn($store); 00161 } 00162 return $res; 00163 }
priceIncludesTax | ( | $ | store = null |
) |
Check if product prices inputed include tax
mix | $store |
Definition at line 63 of file Data.php.
00064 { 00065 $storeId = Mage::app()->getStore($store)->getId(); 00066 if (!isset($this->_priceIncludesTax[$storeId])) { 00067 $this->_priceIncludesTax[$storeId] = (int)Mage::getStoreConfig( 00068 Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, 00069 $store 00070 ); 00071 } 00072 return $this->_priceIncludesTax[$storeId]; 00073 }
shippingPriceIncludesTax | ( | $ | store = null |
) |
Definition at line 386 of file Data.php.
00387 { 00388 $storeId = Mage::app()->getStore($store)->getId(); 00389 if (!isset($this->_shippingPriceIncludesTax[$storeId])) { 00390 $this->_shippingPriceIncludesTax[$storeId] = 00391 (int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX, $store); 00392 } 00393 return $this->_shippingPriceIncludesTax[$storeId]; 00394 }
const PRICE_CONVERSION_MINUS = 2 |
const PRICE_CONVERSION_PLUS = 1 |