コード例 #1
0
ファイル: Products.php プロジェクト: kokkez/shineisp
 /**
  * Get the suggested price
  * @param integer $productid
  * @param boolean $taxincluded
  */
 public static function getPriceSuggested($productid, $taxincluded = false)
 {
     $currency = Shineisp_Registry::getInstance()->Zend_Currency;
     $price = 0;
     if (is_numeric($productid)) {
         $product = self::getAllInfo($productid);
         // Get the tax percentage
         $tax = Taxes::getTaxbyProductID($productid);
         if (!empty($product)) {
             if (!empty($product['price_1']) && $product['price_1'] > 0) {
                 // Taxes calculation
                 if (!empty($tax['percentage']) && is_numeric($tax['percentage'])) {
                     $price = $product['price_1'] * ($tax['percentage'] + 100) / 100;
                     $price = $currency->toCurrency($price, array('currency' => Settings::findbyParam('currency')));
                 } else {
                     $price = $currency->toCurrency($product['price_1'], array('currency' => Settings::findbyParam('currency')));
                 }
             } else {
                 $tranches = ProductsTranches::getSuggestedTranche($productid);
                 if (!empty($tranches[0])) {
                     $price = $tranches[0]['price'] * $tranches[0]['BillingCycle']['months'];
                 } else {
                     if (!empty($product['ProductsTranches'])) {
                         $price = $product['ProductsTranches'][0]['price'] * $product['ProductsTranches'][0]['BillingCycle']['months'];
                     }
                 }
             }
         }
         // Taxes calculation
         if ($taxincluded && $price > 0 && !empty($tax['percentage']) && is_numeric($tax['percentage'])) {
             $price = $price * ($tax['percentage'] + 100) / 100;
             $price = $currency->toCurrency($price, array('currency' => Settings::findbyParam('currency')));
         }
         return $price;
     }
 }