public function __construct(array $args)
 {
     $this->_product = $args['product'];
     $this->_store = $args['store'];
     $this->_coreHelper = $args['core'];
     $this->_weeeHelper = $args['weee'];
     $this->_taxHelper = $args['tax'];
     $this->_product = Mage::getModel("catalog/product")->getCollection()->addAttributeToSelect(Mage::getSingleton("catalog/config")->getProductAttributes())->addAttributeToFilter("entity_id", $this->_product->getEntityId())->setPage(1, 1)->addMinimalPrice()->addFinalPrice()->addTaxPercents()->load()->getFirstItem();
     $this->_simplePricesTax = $this->_taxHelper->displayPriceIncludingTax() || $this->_taxHelper->displayBothPrices();
     $this->_minimalPriceValue = $this->_product->getMinimalPrice();
     $this->_minimalPrice = $this->_taxHelper->getPrice($this->_product, $this->_minimalPriceValue, $this->_simplePricesTax);
     $this->_setPrices();
 }
 public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null, $ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true)
 {
     $price = parent::getPrice($product, $price, $includingTax, $shippingAddress, $billingAddress, $ctc, $store, $priceIncludesTax, $roundPrice);
     if (Mage::app()->getFrontController()->getRequest()->getModuleName() == 'catalog' && Mage::getStoreConfig('dc_charge_extension/dccharge/consolidated-price')) {
         $product->load($product->getId());
         $dcHelper = Mage::helper('dccharge');
         $params = array('classify_by' => 'cat desc', 'cat[0]' => $product->getDcProductId(), 'desc[0]' => $product->getName(), 'value[0]' => $price, 'qty[0]' => 1, 'from' => Mage::getStoreConfig('shipping/origin/country_id') ? Mage::getStoreConfig('shipping/origin/country_id') : Mage::getStoreConfig('general/country/default'), 'to' => Mage::getStoreConfig('dc_charge_extension/dccharge/consolidated-price-country'), 'currency' => Mage::app()->getStore()->getBaseCurrency()->getCode(), 'output_currency' => Mage::app()->getStore()->getBaseCurrency()->getCode(), 'insurance' => 0, 'shipping' => 0, 'is_consolidated_request' => 1);
         if ($product->getCountryOfManufacture()) {
             $params['origin[0]'] = $product->getCountryOfManufacture();
         }
         $params['use_defaults'] = 1;
         if ($product->getWeight()) {
             $weigthUnit = Mage::getStoreConfig('dc_charge_extension/dccharge/weight-unit');
             $weight = Mage::getStoreConfig('dc_charge_extension/dccharge/allow-override-products-weight') ? Mage::getStoreConfig('dc_charge_extension/dccharge/overridden-products-weight') : $product->getWeight();
             if ($weigthUnit == 'lb') {
                 $itemWeightInKG = round($weight * 0.45359237, 2);
             } else {
                 $itemWeightInKG = $weight;
             }
             $params['wt[0]'] = (double) $itemWeightInKG;
         }
         $rawXml = $dcHelper->sendRequest('calculation', $params);
         if (stripos($rawXml, '<?xml') === false) {
             return $price;
         }
         $answer = new SimpleXMLElement($rawXml);
         $totals = current($answer->xpath('total-charges'));
         $totalCharges = (double) $totals->total->amount;
         $price += $totalCharges;
     }
     return $price;
 }
Beispiel #3
0
 /**
  * Get product price with all tax settings processing CM wrapper
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   float $price inputed product price
  * @param   bool $includingTax return price include tax flag
  * @param   null|Mage_Customer_Model_Address $shippingAddress
  * @param   null|Mage_Customer_Model_Address $billingAddress
  * @param   null|int $ctc customer tax class
  * @param   mixed $store
  * @param   bool $priceIncludesTax flag what price parameter contain tax
  * @return  float
  */
 public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null, $ctc = null, $store = null, $priceIncludesTax = null)
 {
     if (!$price) {
         return $price;
     }
     $store = Mage::app()->getStore($store);
     if (!$this->needPriceConversion($store)) {
         return $price;
     }
     return parent::getPrice($product, $price, $includingTax, $shippingAddress, $billingAddress, $ctc, $store, $priceIncludesTax);
 }
Beispiel #4
0
 /**
  * Get product price with all tax settings processing
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   float $price inputed product price
  * @param   bool $includingTax return price include tax flag
  * @param   null|Mage_Customer_Model_Address $shippingAddress
  * @param   null|Mage_Customer_Model_Address $billingAddress
  * @param   null|int $ctc customer tax class
  * @param   null|Mage_Core_Model_Store $store
  * @param   bool $priceIncludesTax flag what price parameter contain tax
  * @return  float
  */
 public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null, $ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true)
 {
     if (!$price) {
         return $price;
     }
     $store = Mage::app()->getStore($store);
     if (!$this->needPriceConversion($store)) {
         return $price;
     }
     Mage::app()->getStore($store)->setDoNotRoundET(true);
     $result = parent::getPrice($product, $price, $includingTax, $shippingAddress, $billingAddress, $ctc, $store, $priceIncludesTax, $roundPrice);
     Mage::app()->getStore($store)->setDoNotRoundET(false);
     return $result;
 }