本文整理汇总了PHP中oledrion_utils::getVAT方法的典型用法代码示例。如果您正苦于以下问题:PHP oledrion_utils::getVAT方法的具体用法?PHP oledrion_utils::getVAT怎么用?PHP oledrion_utils::getVAT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oledrion_utils
的用法示例。
在下文中一共展示了oledrion_utils::getVAT方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProductOptionsPrice
/**
* Calcul le prix HT des options sélectionnées pour un produit
*
* @param array $choosenAttributes [clé] = attribute_id, [value] = array(valueId1, valueId2 ...)
* @param integer $product_vat_id L'ID de TVA du produit
* @param array $descriptions Tableau valorisé par la méthode [clé] = Id attribut [valeur] = array('attribute_title', array('attribute_names', 'attribute_prices'))
* @return float
* @since 2.3.2009.03.21
*/
function getProductOptionsPrice($choosenAttributes, $product_vat_id, &$descriptions = null)
{
static $vats = array();
if (is_array($vats) && isset($vats[$product_vat_id])) {
$vat_rate = $vats[$product_vat_id];
} else {
$vat = null;
$vat = oledrion_handler::getInstance()->h_oledrion_vat->get($product_vat_id);
if (is_object($vat)) {
$vats[$product_vat_id] = $vat_rate = $vat->getVar('vat_rate', 'n');
}
}
$ret = 0;
$attributesIds = $attributes = array();
if (!is_array($choosenAttributes) || count($choosenAttributes) == 0) {
return $ret;
}
$attributesIds = array_keys($choosenAttributes);
$attributes = $this->getItemsFromIds($attributesIds);
if (count($attributes) == 0) {
return $ret;
}
$oledrion_Currency = oledrion_Currency::getInstance();
foreach ($choosenAttributes as $userAttributeId => $userAttributeValues) {
if (isset($attributes[$userAttributeId])) {
$attribute = $attributes[$userAttributeId];
$dataForDescriptions = array();
$optionDescription = '';
if (is_array($userAttributeValues) && count($userAttributeValues) > 0) {
foreach ($userAttributeValues as $option) {
$optionName = oledrion_utils::getName($option);
$price = $attribute->getOptionPriceFromValue($optionName);
$optionDescription = $attribute->getOptionNameFromValue($optionName);
$vatAmount = oledrion_utils::getVAT($price, $vat_rate);
$ttc = $price + $vatAmount;
$vatAmountFormated = $oledrion_Currency->amountForDisplay($vatAmount);
$htFormated = $oledrion_Currency->amountForDisplay($price);
$ttcFormated = $oledrion_Currency->amountForDisplay($ttc);
$dataForDescriptions[] = array('option_name' => $optionDescription, 'option_value' => $optionName, 'option_price' => $price, 'option_vat' => $vatAmount, 'option_ttc' => $ttc, 'option_price_ht_formated' => $htFormated, 'option_vat_formated' => $vatAmountFormated, 'option_ttc_formated' => $ttcFormated);
$ret += $price;
// Total de toutes les options
}
} else {
$optionName = oledrion_utils::getName($userAttributeValues);
$price = $attribute->getOptionPriceFromValue($optionName);
$optionDescription = $attribute->getOptionNameFromValue($optionName);
$vatAmount = oledrion_utils::getVAT($price, $vat_rate);
$ttc = $price + $vatAmount;
$vatAmountFormated = $oledrion_Currency->amountForDisplay($vatAmount);
$htFormated = $oledrion_Currency->amountForDisplay($price);
$ttcFormated = $oledrion_Currency->amountForDisplay($ttc);
$dataForDescriptions[] = array('option_name' => $optionDescription, 'option_value' => $optionName, 'option_price' => $price, 'option_vat' => $vatAmount, 'option_ttc' => $ttc, 'option_price_ht_formated' => $htFormated, 'option_vat_formated' => $vatAmountFormated, 'option_ttc_formated' => $ttcFormated);
$ret += $price;
// Total de toutes les options
}
if (is_array($descriptions)) {
$descriptions[$attribute->getVar('attribute_id')] = array('attribute_title' => $attribute->getVar('attribute_title'), 'attribute_options' => $dataForDescriptions);
}
}
}
return $ret;
}
示例2: computeCart
//.........这里部分代码省略.........
$discountedShipping -= floatval($rule->getVar('disc_shipping_reduce_amount', 'n'));
}
// Pas de montants négatifs
oledrion_utils::doNotAcceptNegativeAmounts($discountedShipping);
break;
case OLEDRION_DISCOUNT_SHIPPING_TYPE4:
// Frais de port dégressifs
if ($quantity >= $rule->disc_shipping_degress_l1qty1 && $quantity <= $rule->disc_shipping_degress_l1qty2) {
$discountedShipping = floatval($rule->getVar('disc_shipping_degress_l1total', 'n'));
}
if ($quantity >= $rule->disc_shipping_degress_l2qty1 && $quantity <= $rule->disc_shipping_degress_l2qty2) {
$discountedShipping = floatval($rule->getVar('disc_shipping_degress_l2total', 'n'));
}
if ($quantity >= $rule->disc_shipping_degress_l3qty1 && $quantity <= $rule->disc_shipping_degress_l3qty2) {
$discountedShipping = floatval($rule->getVar('disc_shipping_degress_l3total', 'n'));
}
if ($quantity >= $rule->disc_shipping_degress_l4qty1 && $quantity <= $rule->disc_shipping_degress_l4qty2) {
$discountedShipping = floatval($rule->getVar('disc_shipping_degress_l4total', 'n'));
}
if ($quantity >= $rule->disc_shipping_degress_l5qty1 && $quantity <= $rule->disc_shipping_degress_l5qty2) {
$discountedShipping = floatval($rule->getVar('disc_shipping_degress_l5total', 'n'));
}
break;
}
// Sélection du type de réduction sur les frais de port
}
// Il faut appliquer la règle de réduction
}
// Boucle sur les réductions
// Calcul de la TVA du produit
$vatId = $cartProduct['product']->getVar('product_vat_id');
if (is_array($vats) && isset($vats[$vatId])) {
$vatRate = floatval($vats[$vatId]->getVar('vat_rate', 'n'));
$vatAmount = oledrion_utils::getVAT($discountedPrice * $quantity, $vatRate);
} else {
$vatRate = 0.0;
$vatAmount = 0.0;
}
// Calcul du TTC du produit ((ht * qte) + tva + frais de port)
$totalPrice = floatval($discountedPrice * $quantity + $vatAmount + $discountedShipping);
// Les totaux généraux
$totalHT += $discountedPrice * $quantity;
$totalVAT += $vatAmount;
$totalShipping += $discountedShipping;
// Recherche des éléments associés au produit
$associatedVendor = $associatedCategory = $associatedManufacturers = array();
$manufacturersJoinList = '';
// Le vendeur
if (isset($this->associatedVendors[$cartProduct['product']->product_vendor_id])) {
$associatedVendor = $this->associatedVendors[$cartProduct['product']->product_vendor_id]->toArray();
}
// La catégorie
if (isset($this->associatedCategories[$cartProduct['product']->product_cid])) {
$associatedCategory = $this->associatedCategories[$cartProduct['product']->product_cid]->toArray();
}
// Les fabricants
$product_id = $cartProduct['product']->product_id;
if (isset($this->associatedManufacturersPerProduct[$product_id])) {
// Recherche de la liste des fabricants associés à ce produit
$manufacturers = $this->associatedManufacturersPerProduct[$product_id];
$manufacturersList = array();
foreach ($manufacturers as $manufacturer_id) {
if (isset($this->associatedManufacturers[$manufacturer_id])) {
$associatedManufacturers[] = $this->associatedManufacturers[$manufacturer_id]->toArray();
}
$manufacturersList[] = $this->associatedManufacturers[$manufacturer_id]->manu_commercialname . ' ' . $this->associatedManufacturers[$manufacturer_id]->manu_name;