Доработка модуля Drupal (Ubercart)
В модуле для Ubercart обрабатывается цена, вот такой функцией:
function uc_vat_product_price_alter(&$price, &$context, &$options, $tax_rates, $node) {
$suffixes = array();
$original_price = $price['price'];
$currencies = variable_get('crs_currency_rates', array());
$native_currency = variable_get('uc_currency_code', 'USD');
$currencies[$native_currency] = 1.0;
$currencies[$native_currency . '_delta'] = 0;
// convert
$new_price = (float)($currencies['USD']) / (float)($currencies['RUR']);
$attributes = uc_product_get_attributes($node->nid);
foreach($attributes as $attribute) {
if ($attribute->aid=='4') {
$kargoprice = true;
break;
}
$kargoprice =false;
}
$cur=$new_price;
if ($node->type == 'product_kit') {
foreach ($node->products as $product) {
foreach ($tax_rates as $tax) {
if (in_array($product->type, $tax->taxed_product_types) && ($tax->shippable == 0 || $product->shippable == 1)) {
// This uses the original sell_price, which will not necessarily be correct if another price alterer is enabled.
// Instead, should we try to proportionally back-calculate the individual product prices from the price we were passed?
if ($context['field'] == 'sell_price') {
$price['price'] += ($product->sell_price + $product->discount) + $tax->rate *$product->weight* $cur;
}
else { if ($kargoprice) {
$price['price'] = $product->sell_price+ ($tax->rate * $product->weight)* $cur;
}
else {
$price['price'] += $product->sell_price+ ($tax->rate * $product->weight+$product->length * 260)* $cur;
более подробно во вложении. Цена товара в каталоге интернет-магазина выводится уже измененная, но фильтр в views каталога не срабатывает, вернее срабатывает по цене до обработки, необходимо доработать модуль, чтобы он мог фильтровать товар по цене, которая выводится в каталоге интернет-магазина.