Answered

How to change/add Product packaging units

Tue Feb 5, 2013 10:19 am
Hi Jumbo,

I have a very general question and if you happen to know the answer I think will help a lot of users!

How can I add a new packaging unit on Product Dimensions and Weight screen?

Currently I see "Kg", "100mg", "m2", "m", "l" etc.

I nee to add a new unit, but I can't figure out how!

Do you know how to do that?

Thank you very much in advance!

Yannis

 rkoval says thank you to yannis_r for this post.

The administrator has disabled public write access.
Wed Feb 6, 2013 12:07 am
VirtueMart 2.0 does not have this option under shop configuration. So you will have hack the helper file to add your custom Packaging Unit to the store.

Open administrator\components\com_virtuemart\helpers\shopfunctions.php

Find the following codes between lines 470 to 486:
	static function renderUnitIsoList($name, $selected){
 
		$weight_unit_default = array(
			'KG' => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_KG')
		, 'DMG' => 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')
		, 'DML'   => 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;
	}
You can add your own packaging Unit in the $weight_unit_default array.

Example:
	static function renderUnitIsoList($name, $selected){
 
		$weight_unit_default = array(
			'KG' => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_KG')
		, 'DMG' => 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')
		, 'DML'   => JText::_ ('COM_VIRTUEMART_UNIT_SYMBOL_100ML')
		, 'MT'   => 'Metric Ton' // New Unit 1
		, 'CUFT'   => 'Cubic Feet' // New Unit 2
		);
		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;
	}
Post your reviews about us on our Facebook Page.
Post your testimonials and suggestions Here.
Don't forget to Close your topic when resolved.

 rkoval says thank you to Jumbo for this post.

The administrator has disabled public write access.
Wed Feb 6, 2013 5:23 am
Thank you Jumbo!

This is almost unbelievable!
I can't understand why they did it in this way rather that setting a table!!!!

Just for answering such questions is worth the support cost!

I will implement today.

 rkoval says thank you to yannis_r for this post.

The administrator has disabled public write access.
Wed Feb 6, 2013 7:59 pm
You are most welcome.
Post your reviews about us on our Facebook Page.
Post your testimonials and suggestions Here.
Don't forget to Close your topic when resolved.

 rkoval says thank you to Jumbo for this post.

The administrator has disabled public write access.