News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

suggestion about allowing user to customise customFieldsCart variant

Started by whisky, November 26, 2013, 21:10:06 PM

Previous topic - Next topic

whisky

My boss want to have cart custom field price variant in the form of
   <variant title> (+ xxx <currency>) instead of the fixed <variant title>+<price>

I didn't find a way to do it, unless modifying virtuemart core or making some kind of regexp search and replace at the last stage of the view.

So I suggest to modify slightly the VirtueMartModelCustomfields::_getCustomPrice

from

static function _getCustomPrice($customPrice, $currency, $calculator) {

      if ((float)$customPrice) {
         $price = strip_tags ($currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($customPrice)));
         if ($customPrice >0) {
                           $price ="+".$price;
         }
      }
      else {
         $price = ($customPrice === '') ? '' :  JText::_ ('COM_VIRTUEMART_CART_PRICE_FREE');
      }
      return $price;
   }

to

static function _getCustomPrice($customPrice, $currency, $calculator) {

      if ((float)$customPrice) {
         $price = strip_tags ($currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($customPrice)));
         if ($customPrice >0) {
                           $price = JText::sprintf('COM_VIRTUEMART_CART_PRICE_ADDED_PRICE_VARANT',$price);
         }
      }
      else {
         $price = ($customPrice === '') ? '' :  JText::_ ('COM_VIRTUEMART_CART_PRICE_FREE');
      }
      return $price;
   }

with COM_VIRTUEMART_CART_PRICE_ADDED_PRICE_VARANT  defined in a langage file as : (+%s)

There is some place in the code, where such fixed catenation, could profit of this end-user customisation.

By the way, is there is somewhere in the documentation a recommended way to make custom langage modifications,
while keeping upcoming translations, that come with upgrades ?