本文整理汇总了PHP中oledrion_utils::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP oledrion_utils::getName方法的具体用法?PHP oledrion_utils::getName怎么用?PHP oledrion_utils::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oledrion_utils
的用法示例。
在下文中一共展示了oledrion_utils::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
if (count($attributes) == 0) {
return _OLEDRION_NA;
}
// Et on recalcule le prix
foreach ($attributes as $attribute) {
$attributeNameInForm = xoops_trim($attribute->getVar('attribute_name') . '_' . $attribute->getVar('attribute_id'));
if (isset($data[$attributeNameInForm])) {
$attributeValues = $data[$attributeNameInForm];
if (is_array($attributeValues)) {
foreach ($attributeValues as $attributeValue) {
$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)) {
示例2: 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;
}