VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: Lars Nielsen on February 12, 2015, 13:28:33 PM

Title: Customfields total price
Post by: Lars Nielsen on February 12, 2015, 13:28:33 PM
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
Title: Re: Customfields total price
Post by: Lars Nielsen on February 15, 2015, 11:09:58 AM
Anyone please :-)
Title: Re: Customfields total price
Post by: PRO on February 15, 2015, 14:11:43 PM
I use this plugin
http://forum.virtuemart.net/index.php?topic=127362.0


and do "equal price"

Title: Re: Customfields total price
Post by: Lars Nielsen on February 18, 2015, 18:08:48 PM
Thx Pro, gould you give me an example?
Just need to see the light when you have many different products with many different prices.
Title: Re: Customfields total price
Post by: AH on February 20, 2015, 11:31:59 AM
the examples are given on the first post in the thread PRO pointed you to
Title: Re: Customfields total price
Post by: Lars Nielsen on February 21, 2015, 17:48:23 PM
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.
Title: Re: Customfields total price
Post by: AH on February 21, 2015, 17:54:42 PM
show the configuration screen - not just the frontend
Title: Re: Customfields total price
Post by: Lars Nielsen on February 21, 2015, 19:34:02 PM
See image 2 posted
and this one
Title: Re: Customfields total price
Post by: AH on February 21, 2015, 20:25:04 PM
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 {
Title: Re: Customfields total price
Post by: Lars Nielsen on February 21, 2015, 21:52:41 PM
When i remove that, the shop dosent load.
Title: Re: Customfields total price
Post by: AH on February 22, 2015, 00:31:11 AM
oh well - I guess this plugin is not any use for you
Title: Re: Customfields total price
Post by: Lars Nielsen on February 22, 2015, 10:59:46 AM
So i cant get an equal price for a variant is what you are telling me?
Title: Re: Customfields total price
Post by: AH on February 22, 2015, 11:59:33 AM
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;
?>



Title: Re: Customfields total price
Post by: Lars Nielsen on February 23, 2015, 16:23:04 PM
:-)
Im sorry i dont know how to configure this. Perhaps an other shop system would suit me better? Even though i like this.