News:

Support the VirtueMart project and become a member

Main Menu

Customfields total price

Started by Lars Nielsen, February 12, 2015, 13:28:33 PM

Previous topic - Next topic

Lars Nielsen

Hi.
When using customfields is there a way for the total price to show in the dropdown instead of the basepris + added price?
for example now
default 125
2 kg + 125
3 kg + 175
4 kg + 200
and so on.

I would like it to be
defalt 125
2 kg 250
3 kg 225
4 kg 325 or what ever prices used.

Regards, Lars

Lars Nielsen


PRO


Lars Nielsen

Thx Pro, gould you give me an example?
Just need to see the light when you have many different products with many different prices.

AH

the examples are given on the first post in the thread PRO pointed you to
Regards
A

Joomla 4.4.5
php 8.1

Lars Nielsen

Hi.
But when i use this:
5.Fix the price of a variant =
Config: Red,Green,Blue@=12.50
Gives prices of: Red Green = Retail, Blue = 12.50

The dropdown option turns white and dosent put in the = price.

AH

show the configuration screen - not just the frontend
Regards
A

Joomla 4.4.5
php 8.1

Lars Nielsen


AH

The dropdown option turns white and does not put in the = price.

When you use * the price is not shown


plugins/vmcustom/drop/tmpl/default.php


<?php
defined
('_JEXEC') or die();
$product $viewData[0];
$params $viewData[1];
$options explode(','$params->custom_drop);
$class='';
$selects= array();
if (!
class_exists('CurrencyDisplay')) require(VMPATH_ADMIN DS 'helpers' DS 'currencydisplay.php');
$currency CurrencyDisplay::getInstance();
foreach (
$options as $valuesWithPrice) {
$valueWithPrice explode('@'$valuesWithPrice);

if ( isset ($valueWithPrice[1]) ) {
$op $valueWithPrice[1][0];
$price substr($valueWithPrice[1], 1) ;
$variant substr($valueWithPrice[1], 01) ;
if ($variant == "*") {
$text $valueWithPrice[0] ;
} else {
$text $valueWithPrice[0].' ('.$op.$currency->priceDisplay((float)$price).')';
}
} else {
$text $valueWithPrice[0] ;
}
// $selects[] = array('value' =>$valueWithPrice[0], 'text' => $text );
$selects[] = array('value' =>$valueWithPrice[0], 'text' => htmlentities($text) );
}

$html JHTML::_('select.genericlist'$selects,'customProductData['.$product->virtuemart_product_id.']['.$params->virtuemart_custom_id.']['.$params->virtuemart_customfield_id .'][custom_drop]','class=customdrop','value','text',$selects[0],false,true);
echo 
$html;
?>



you can try editing the template to see what happens if you remove this:-

if ($variant == "*") {
         $text = $valueWithPrice[0] ;
      } else {
Regards
A

Joomla 4.4.5
php 8.1

Lars Nielsen

When i remove that, the shop dosent load.

AH

oh well - I guess this plugin is not any use for you
Regards
A

Joomla 4.4.5
php 8.1

Lars Nielsen

So i cant get an equal price for a variant is what you are telling me?

AH

Lars

The "@=" option works for my installation

If you use a comma in an "=" price the variables will not work

And Multiply is not configured to show a price in the template

You should be able to change the default.php template in the plugin to get what you require

Unfortunately you will need to do this yourself.

This plugin was designed to meet my own specific needs and it does that, I offer this for free to help others out and as a starting point for those wishing to make their own customisations.

Here are some pointers to help you

The file to adjust is plugins/vmcustom/drop/tmpl/default.php

<?php
defined('_JEXEC') or die();
$product = $viewData[0];
$params = $viewData[1];
//Lars, this is where it splits up the variables for display using the comma
$options = explode(',', $params->custom_drop);
$class='';
$selects= array();
if (!class_exists('CurrencyDisplay')) require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php');
$currency = CurrencyDisplay::getInstance();
foreach ($options as $valuesWithPrice) {
   $valueWithPrice = explode('@', $valuesWithPrice);

   if ( isset ($valueWithPrice[1]) ) {
      $op = $valueWithPrice[1][0];
      $price = substr($valueWithPrice[1], 1) ;
      $variant = substr($valueWithPrice[1], 0, 1) ;
//Lars, this is where it identifies a multiplier and does not show anything but the description e.g. 2kg, you would need to code to get a price from the multiplier here
      if ($variant == "*") {
         $text = $valueWithPrice[0] ;  //display the price result here
      } else {
         $text = $valueWithPrice[0].' ('.$op.$currency->priceDisplay((float)$price).')';
      }
   } else {
      $text = $valueWithPrice[0] ;
   }
//Lars, this is  also can cause a problem- Try changing which line is commented out
//   $selects[] = array('value' =>$valueWithPrice[0], 'text' => $text );
   $selects[] = array('value' =>$valueWithPrice[0], 'text' => htmlentities($text) );
}

$html = JHTML::_('select.genericlist', $selects,'customProductData['.$product->virtuemart_product_id.']['.$params->virtuemart_custom_id.']['.$params->virtuemart_customfield_id .'][custom_drop]','class=customdrop','value','text',$selects[0],false,true);
echo $html;
?>



Regards
A

Joomla 4.4.5
php 8.1

Lars Nielsen

:-)
Im sorry i dont know how to configure this. Perhaps an other shop system would suit me better? Even though i like this.