Author Topic: How to add another Product Unit  (Read 4925 times)

edudflog

  • Beginner
  • *
  • Posts: 31
How to add another Product Unit
« on: September 06, 2012, 03:37:10 am »
I am truly new to Virtuemart and have had several challenges.  I've worked through most on my own but this one has me stumped.

On the Product Dimensions and Weight tab in the product module, the Product Unit drop down list only shows the following:

kg, 100 mg, m, m2, m3, l and 100ml.  It does not show "pieces" which is what I need.  How do I get "pieces" onto the list so it will display?

Thanks for anyone's assistance

Joomla v 2.5.6
VM 2.0.10
PHP ver: 5.2.17


[attachment cleanup by admin]

ivus

  • Full Member
  • ***
  • Posts: 535
  • - YAY me... proud member of the 500 club...
Re: How to add another Product Unit
« Reply #1 on: September 06, 2012, 05:33:10 am »
Hi edudflog,

HMMM... this is odd. The list has been hard coded into a function.

To modify it you'll need to open the following file "/administrator/components/com_virtuemart/helpers/shopfunctions.php" @ line 467. Look for the function "static function renderUnitIsoList($name, $selected){}"

Code: [Select]

static function renderUnitIsoList($name, $selected){

$weight_unit_default = array(
'KG' => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_KG')
, '100MG' => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_100MG')
, 'M'   => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_M')
, 'SM'   => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_SM')
, 'CUBM'   => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_CUBM')
, 'L'   => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_L')
, '100ML'   => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_100ML')
);
foreach ($weight_unit_default as  $key => $value) {
$wu_list[] = JHTML::_ ('select.option', $key, $value, $name);
}
$listHTML = JHTML::_ ('Select.genericlist', $wu_list, $name, '', $name, 'text', $selected);
return $listHTML;
}


to add you own, just copy and adjust the last item:

      , '100ML'   => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_100ML')

to

      , 'YOUR VALUE'   => JText::_ ('YOUR TEXT')

I hope this helps.

edudflog

  • Beginner
  • *
  • Posts: 31
Re: How to add another Product Unit
« Reply #2 on: September 06, 2012, 22:49:08 pm »
This helped immensely.  Thank you very much for providing the information.

Regards

Bill

mykee

  • Beginner
  • *
  • Posts: 4
Re: How to add another Product Unit
« Reply #3 on: September 11, 2012, 12:33:06 pm »
Please add this unit to list by default, because TV or DVD Player not sell with kg or m3, just pieces...
Thanks!

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 8809
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: How to add another Product Unit
« Reply #4 on: September 18, 2012, 10:25:55 am »
but TV or DVD DONT HAVE A UNIT PRICE!

man, guys, come on, put your brain together. Look here http://www.mathsisfun.com/measure/unit-price.html.
You cannot do this with a DVD, or TV. You buy stuff like this in whole pieces. The unitprice is done for fluids, meterware, cutware and products which can be sold in different units.
you cannot buy a 0.5 TV. So if you sell something like this, just leave it empty. Furthermore in this list are only units, which are legal according to EU law.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

edudflog

  • Beginner
  • *
  • Posts: 31
Re: How to add another Product Unit
« Reply #5 on: September 18, 2012, 18:17:27 pm »
Milbo:

Your reply is a bit surprising.  Last things first - Virtuemart may have included only those units that are legal according to EU law, however unless I am mistaken, you are trying to distribute this excellent shop system worldwide.  By restricting it to only EU sanctioned units, you are doing a disservice to all other people trying to use Virtuemart in non-EU countries.  Unless VM has been developed with the financial support of the EU with a caveat that only EU units are acceptable, I don't quite understand the logic.

Second, as foolish as it sounds to you, there are reasons to have "pieces" or other unit descriptors in the list (or at least an easy way to add other units.)  If I sell widgets and each widget unit has 3 pieces, a buyer should know that, the same way a buyer should know that each unit weighs 100 KG.  If nothing else, would it not be helpful to end users to add an easy way to supplement the list with other units?

Finally, like many others, I am new to Virtuemart and am using it to make building a website a bit easier for someone who does not know coding.  As far as I can see in my version of Virtuemart, Kg is a default unit and I cannot leave the box blank.  Please correct me if I am wrong.

I hope you take these comments constructively.

Thanks

efocus

  • Jr. Member
  • **
  • Posts: 57
Re: How to add another Product Unit
« Reply #6 on: September 19, 2012, 03:37:19 am »
I want to chime in. I'm assuming this feature allows customers to order decimal quantities or product? If that's right, I'm thrilled.

I had to have VM 1.2 custom hacked in the past to allow for purchasing yards of fabric. It would be great if I could add in yards so customers can order 1.75 yards without hacking VM in the future. I know others sell things by the inch, foot, pound, etc. I was told as a schoolchild that we were changing to the metric system here in the U.S. Well, that was 40 years ago and we're still using old measurements so we have to deal with them.

sandomatyas

  • Jr. Member
  • **
  • Posts: 97
Re: How to add another Product Unit
« Reply #7 on: September 13, 2016, 06:16:12 am »
I have to migrate a VM 1.1.3 shop to 3.0.16 where the customer uses "product unit" a lot because this is a free text field.
They don't want to display the unit price but the sales price like this:
Price $123 / piece
Price $123 / pair
Price $123 / box
Price $123 / clew
Price $123 / bottle
Price $123 / hour
etc
So no way to do this with VM?

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 8809
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: How to add another Product Unit
« Reply #8 on: September 13, 2016, 13:41:49 pm »
The best way would be to add another table, which keeps this entries.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

  • Jr. Member
  • **
  • Posts: 97
Re: How to add another Product Unit
« Reply #9 on: November 30, 2016, 12:14:23 pm »
Please consider extending VirtueMart's funcionality with this. It would be great using a table to store units even it doesn't have admin form yet but it would be easily extendable. :)
Maybe it's only around renderUnitIsoList function in class ShopFunctions

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2075
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: How to add another Product Unit
« Reply #10 on: November 30, 2016, 13:16:44 pm »
The best way would be to add another table, which keeps this entries.

Hi max,
I have the same problem, and i hacked the list, because this is a migration from VM 1 and client cannot use another one, the price per unit use real price and using another field for ajax price refresh is not possible.
I think that a good idea is perhaps to add 1 or 2 Customizable option in the list
For my hack, i added "custom and COM_VIRTUEMART_UNIT_SYMBOL_CUSTOM, because i always use same.
But adding other option can be usefull too as COM_VIRTUEMART_UNIT_SYMBOL_PACK,COM_VIRTUEMART_UNIT_SYMBOL_BOTTLE or hour ...

Greets,
Patrick


Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2075
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: How to add another Product Unit
« Reply #11 on: November 30, 2016, 13:26:27 pm »
Hi
I found here sample of code easy to implement, to do editable list : http://stackoverflow.com/questions/264640/how-can-i-create-an-editable-dropdownlist-in-html
This can be a solution, to use custom options.

sandomatyas

  • Jr. Member
  • **
  • Posts: 97
Re: How to add another Product Unit
« Reply #12 on: December 23, 2016, 12:29:03 pm »
If I'm right from next year there will be a law in Hungary which says that every online shop needs to display unit price, but if you are using a bit different units as the list in Virtuemart (e.g. bottle, pair, event) you can't display it properly. So it would be quite important for Hungarian VM users

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2075
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: How to add another Product Unit
« Reply #13 on: December 23, 2016, 13:12:31 pm »
If I'm right from next year there will be a law in Hungary which says that every online shop needs to display unit price, but if you are using a bit different units as the list in Virtuemart (e.g. bottle, pair, event) you can't display it properly. So it would be quite important for Hungarian VM users
It's important for 2 of my customers.
So yes, i think this a needed feature for many shops, because the VM unit list is very short !

sandomatyas

  • Jr. Member
  • **
  • Posts: 97
Re: How to add another Product Unit
« Reply #14 on: January 28, 2017, 14:21:13 pm »
you're right :)