Настраиваемые поля VirtueMart 2.0, не работает атрибут "равно" сумма (цена)

Настраиваемые поля VirtueMart 2.0, не работает атрибут "равно" сумма (цена)

Задача: в Виртумарте 2.0 в настраиваемых полях для корзины было выявлено, что знак = (равно), указывающий, что необходимо применить новую цену, не срабатывает, а вот знаки +\- (плюс\минус) работают, как и прежде, прибавляя или отнимая от базовой стоимости товара соответствующую сумму. Необходимо исправить этот недочет.

Решение:

1) Открыть скрипт: \administrator\components\com_virtuemart\helpers\calculationh.php

2) Перейти к: function getProductPrices
найти: $basePriceShopCurrency = $basePriceShopCurrency + doubleval($variant);

заменить на этот код:
$x=(!is_int($variant[0])) ? doubleval(substr($variant, 1)) : doubleval($variant);
if($variant[0]=='=') $basePriceShopCurrency = $x;
elseif($variant[0]=='-') $basePriceShopCurrency = $basePriceShopCurrency - $x;
elseif($variant[0]=='*') $basePriceShopCurrency = $basePriceShopCurrency * $x;
else $basePriceShopCurrency = $basePriceShopCurrency + $x;if($variant[0]!='=') $basePriceShopCurrency = $basePriceShopCurrency + doubleval($variant);
else $basePriceShopCurrency= doubleval(substr($variant, 1));

3) Перейти к: function calculateModificators
найти: $modificatorSum = $modificatorSum + $productCustomsPrice->custom_price;

заменить на:
if($productCustomsPrice->custom_price[0]=='=' || $productCustomsPrice->custom_price[0]=='*')
   $modificatorSum = $productCustomsPrice->custom_price[0].($modificatorSum + substr($productCustomsPrice->custom_price, 1));
else $modificatorSum = $modificatorSum + $productCustomsPrice->custom_price;
4) Открыть /administrator/components/com_virtuemart/models/customfields.php
найти строку $price = ($customPrice === '') ? '' : JText::_ ('COM_VIRTUEMART_CART_PRICE_FREE');
заменить на
$price = ($customPrice === '' || preg_match('#^[\+\-\*=]#', $customPrice)) ? '' : JText::_ ('COM_VIRTUEMART_CART_PRICE_FREE');
5) Выполнить SQL-запрос:
 ALTER TABLE `ПРЕФИКС-ДЖУМЛЫ_virtuemart_product_customfields` CHANGE `custom_price` `custom_price` VARCHAR( 20 ) NULL DEFAULT NULL COMMENT 'price'
;

И заоднем, исправим недочет при обновлении суммы, с учетом количества товара, передаваемую по AJAX.

1) Открыть скрипт: \components\com_virtuemart\controllers\productdetails.php
2) Перейти к: function recalculate(){
3) После строки: $prices = $product_model->getPrice($virtuemart_product_id,$customPrices,$quantity);
вставить это: $prices['salesPrice']*=$quantity;


http://2v3.su/blog/web/69.html

Комментарии

Популярные сообщения из этого блога

LOGOUT JOOMLA

Разработка Плагинов под Джумлу - События

Виртуемарт 2.0.26 - ONE PAGE CHECKOUT