Esempio n. 1
0
                         $optionName = oledrion_utils::getName($attributeValue);
                         $optionPrice = $attribute->getOptionPriceFromValue($optionName);
                         $productPrice += $optionPrice;
                     }
                 } else {
                     $optionPrice = $attribute->getOptionPriceFromValue(oledrion_utils::getName($attributeValues));
                     $productPrice += $optionPrice;
                 }
             }
         }
         // Mise en template
         include_once XOOPS_ROOT_PATH . '/class/template.php';
         $template = new XoopsTpl();
         $vat = null;
         $vat = $handlers->h_oledrion_vat->get($vat_id);
         $productPriceTTC = oledrion_utils::getAmountWithVat($productPrice, $vat_id);
         $oledrion_Currency = oledrion_Currency::getInstance();
         $templateProduct = $product->toArray();
         $templateProduct['product_final_price_ht_formated_long'] = $oledrion_Currency->amountForDisplay($productPrice, 'l');
         $templateProduct['product_final_price_ttc_formated_long'] = $oledrion_Currency->amountForDisplay($productPriceTTC, 'l');
         if (is_object($vat)) {
             $templateProduct['product_vat_rate'] = $vat->toArray();
         }
         $templateProduct['product_vat_amount_formated_long'] = $oledrion_Currency->amountForDisplay($productPriceTTC - $productPrice, 'l');
         $template->assign('product', $templateProduct);
         $return = $template->fetch('db:oledrion_product_price.tpl');
     }
     break;
     // ajax search
 // ajax search
 case 'search':
Esempio n. 2
0
 /**
  * Retourne le montant TTC du prix normal du produit
  *
  * @return floatval
  */
 public function getTTC()
 {
     return oledrion_utils::getAmountWithVat($this->getVar('product_price', 'e'), $this->getVar('product_vat_id'));
 }
 /**
  * Retourne une liste combinée des options de l'attribut
  *
  * @param string $format				Format dans lequel renvoyer les données
  * @param boolean $withFormatedPrices	Faut il retourner les prix formatés ?
  * @param object $product				Le produit de travail
  * @return array
  * @since 2.3.2009.03.11
  */
 function getAttributeOptions($format = 's', $withFormatedPrices = false, oledrion_products $product = null)
 {
     $ret = array();
     $counter = 0;
     if (!is_null($product)) {
         $vat_id = $product->getVar('product_vat_id');
     }
     $names = $this->getOption('attribute_names', $format);
     $values = $this->getOption('attribute_values', $format);
     if (oledrion_utils::getModuleOption('use_price')) {
         $prices = $this->getOption('attribute_prices', $format);
     }
     if (oledrion_utils::getModuleOption('attributes_stocks')) {
         $stocks = $this->getOption('attribute_stocks', $format);
     }
     if ($withFormatedPrices) {
         $oledrion_Currency = oledrion_Currency::getInstance();
     }
     if (count($names) > 0) {
         foreach ($names as $key => $name) {
             $price = $stock = 0;
             if (oledrion_utils::getModuleOption('use_price')) {
                 $price = $prices[$key];
                 if ($withFormatedPrices) {
                     $priceFormated = $oledrion_Currency->amountForDisplay($price);
                     $priceTtc = oledrion_utils::getAmountWithVat($price, $vat_id);
                     $priceTtcFormated = $oledrion_Currency->amountForDisplay($priceTtc);
                     $vat = $priceTtc - $price;
                     $vatFormated = $oledrion_Currency->amountForDisplay($vat);
                 }
             }
             if (oledrion_utils::getModuleOption('attributes_stocks')) {
                 $stock = $stocks[$key];
             }
             if (!$withFormatedPrices) {
                 $ret[] = array('name' => $name, 'value' => $values[$key], 'price' => $price, 'stock' => $stock);
             } else {
                 $ret[] = array('name' => $name, 'value' => $values[$key], 'price' => $price, 'priceFormated' => $priceFormated, 'priceTTC' => $priceTtc, 'priceTTCFormated' => $priceTtcFormated, 'vat' => $vat, 'vatFormated' => $vatFormated, 'counter' => $counter, 'stock' => $stock);
             }
             $counter++;
         }
     }
     return $ret;
 }
 /**
  * Retourne les informations formatées de l'attribut pour affichage dans la facture
  *
  * @param oledrion_products $product	Le produit concerné par l'attribut
  * @return array
  * @since 2.3.2009.03.23
  */
 function renderForInvoice(oledrion_products $product, $format = 's')
 {
     $names = $prices = $ret = array();
     $names = $this->getOption('ca_attribute_names', $format);
     if (oledrion_utils::getModuleOption('use_price')) {
         $prices = $this->getOption('ca_attribute_prices', $format);
     }
     $oledrion_Currency = oledrion_Currency::getInstance();
     $counter = 0;
     foreach ($names as $name) {
         $price = 0;
         if (oledrion_utils::getModuleOption('use_price')) {
             if (isset($prices[$counter])) {
                 $price = oledrion_utils::getAmountWithVat(floatval($prices[$counter]), $product->getVar('product_vat_id'));
                 $price = $oledrion_Currency->amountForDisplay($price);
             }
         }
         $ret[] = array('ca_attribute_name' => $name, 'ca_attribute_price_formated' => $price);
         $counter++;
     }
     return $ret;
 }