Component Hacks
Various hacks for largely used Joomla components, as VirtueMart, jEvents, and others.
The hack for Converted Custom Attribues Extended Hack (CAE) is no more hosted at this site, the latest version is posted at http://forum.virtuemart.net/index.php?topic=39666.

The original hack is described - and discussed - in VirtueMart Forums
I added to the original pack the "surface" type of extended attribute, leaving the rest unaltered.
In the example used here the sizes are in centimeters, the price is set per square meter.
The extra attribute's syntax for surface calculation is simple:
Banner (surface)(Some nice tip to be shown|title-hover)(100|100|1|18|10|16|25|14|100)
Where:
- Banner is the freely replaceable name of the attribute - you need to have something there ;)
- (surface) is the type of the attribute, this must remain as is
- (Some nice tip to be shown|title-hover) is the tooltip text as per original syntax, first part is the tooltip, second id the placement (where will be shown).
The third part break downs as follows:
(100|100|1|18|10|16|25|14|100) - or -
(default width|default length|limit1|price1|limit2|price2|limit3|price3|multiplier)
Default width and length are used to prefill the boxes. For normal operation of the hack the values should not be zero. These values are in the example in centimeters. It's recommended to prefill them with some minimal sizes, under winch you charge the default price, no matter what.
- limit1 is the first step, in example in square meters. All sizes below that are charged with the original price - this case 18 euro. Price1 is the price to use for sizes between limit1 and limit2 - this time the same 18 euro -MUST BE THE SAME OR BIGGER AS THE PRODUCT'S BASE PRICE, the hack calculates the additional price for the extra surface above the default one.
- limit2 is the second step, price2 is applied for sizes between limit2 and limit3.
- limit3 is the last limit, price3 is applied for all sizes above limit3.
Multiplier is a parameter to let you choose different units for length/width attributes (for example centimeters) and for surfaces (limits, prices/surface units for example in square meters) For the above example the "multiplier" must be set to 100 - obviously, 1 meter = 100 centimeters. Can be ignored, defaults to 1 - so the hack presumes that you use same units for all variables.
If you use the English language, and you did not modified it for some reason, just overwrite it with the content of the hack.
If you already modified it - or you need to use the hack on a non-english site, then edit the /administrator/components/com_virtuemart/langguages/common/YOURLANGUAGE.php,
where YOURLANGUAGE is obviously your language , locate at the end this code:
); $VM_LANG->initModule( 'common', $langvars );
?>
and add before:
'PHPSHOP_HEIGTH' => 'Height',
'PHPSHOP_WIDTH' => 'Width'
And, of course, add a comma (,) at the end of previous line, otherwise you will generate an error.
Translate the strings after => to your language, and you're done!

Often you can meet the following situation:
In the shop you have at least 2 shopper groups active: the default shoppers which may have discounts on some products (time limited promotions mostly) and another group (typically the wholesalers group/groups), which can have a permanent (and consistent) group discount on all products.
The problem this hack solves is, that the product specific discounts will not be added to other groups, that the one designated as being the default (like the wholesaler's group), so if product A has a promotion set to 50% and the wholesaler group has a general discount of 50%, then the wholesalers will no more get the price for product A at 25% of the original price (50% applied twice).
So the solution in this package solves this problem: prevents that the product specific discounts to be applied for other shoppers than those from shopper group designated as being the default group (if you did not tweaked that, this is the -default- group, but the hack below locates the group set actually as being the default - the group where new users are assigned by default).
We have 2 solutions packed here, you can use one fits your needs and skills - depending on version of VirtueMart you use. First solution, wich was tested and works on VirtueMart versions 1.1.2, 1.1.3 and 1.1.4 need a core hack (hacking the ps_product.php class file - not quite a solution for beginners), the second works only on VirtueMart 1.1.4, without the need to change core code. Thanks for "rb" on VirtueMart forums for the second solution!
The original hack is described - and discussed - in VirtueMart Forums. The code here is based in an older version of the hack, I no more update it, if you need it, and you don't manage to do it yourself, drop me a mail.
There are 3 extra attributes added to the original hack:
1. The "surface" type of extra attribute.
It was added to cover an obvious need - to dynamically calculate the price for products (as for example printed banners) with changing width and heigth.
The extra attribute's syntax for surface calculation is simple:
Banner (surface)(Some nice tip to be shown|title-hover)(100|100|1|18|10|16|25|14)
Where: Banner is the freely replaceable name of the attribute - you need to have something there ;)
(surface) is the type of the attribute, this must remain as is
(Some nice tip to be shown|title-hover) is the tooltip text as per original syntaxt, first part is the tooltip, second id the placement (where will be shown).
the third part break downs as follows:
(100|100|1|18|10|16|25|14)
(default width|default lenght|limit1|price1|limit2|price2|limit3|price3)
and works as follows:
Default widht and lenght are used to prefill the boxes. For normal operation of the hack the values should not be zer. these are in centimeters, so it's recommended to prefill them with some minimal sizes
limit1 is the first step, in meters. All sizes below that are charged with the original price - this case 18 euro. Price1 is the price to use for sizes between limit1 and limit2 - this time the same 18 euro - can be different for default.
limit2 is the second step, price2 is applied for sizes between limit2 and limit3.
limit3 is the last limit, price3 is applied for all sizes above limit3.
2. The "window" type of extra attribute
The "window" type of extra attribute is based on the "surface" type, with couple of changes.
Is destinated for calculating "window" type of products, with "rolo" (window blinds) included.
The syntax is:
Window (window)(Some nice tip to be shown|title-hover)(min_width|min-height|max_width|max_height|price_per_sqm|window_blinds_price_per_sqm|extra_blinds_height);
The parameters are self explanatory, let's see how it looks in a real life example: Fenetre (window)(|)(350|350|1800|2100|10|2|200);
So, 350*350 mm is the min_width*min_height of the window (all length units are in mm)
1800*2100 mm is the max_height*max_width of the window
10 is the price in the shop currency (in the example, 10 euro) of the window ABOVE THE DEFAULT PRICE, for the surface which exceeds the minimal dimensions.
2 is the price of the window blinds per square meters (full surface is calculated, including the extra height, see below)
200 mm is the extra height added to the window blinds, needed (or not) by technological reasons, so if the whndow choosen by the client is 1000 mm height, he will need
1200 mm blinds to function correctly in the above example.
The blinds related parameters can be zero, but must be present!
3. The "windowsill" type of attribute
The "windowsill" type of attribute can be used ONLY TOGETHER WITH THE ABOVE!, so works only when "window" type of attribute is present, and it's BEFORE of
this attribute. It's very important, because uses in calculations the "width" value collected by that.
The syntax is:
Windowsill (pervaz)(Some nice tip to be shown|title-hover)(attribute1 [price1],attribute2 [price2],...)
There can be an unlimited amount of attributes, comma separated. Prices can be zero - no price to be added - in that case the square brackets are don't needed,
or will be in form of [+price_of_a_meter].
Let's see a real life example:
Pervaz (pervaz)(|)(none,Blue [+5.00],Red[+10.00])
So, first attribute means no windowsill is needed.
Blue [+5.00] is a windowsill named Blue with price of 5 euro/m, so if the window choosen above is 500 mm widht, the attached windowsill will be obviously also 500 mm, and will cost 2,5 euro.
If you use the English language, and you did not modifyed it for some reason, just overwrite it with the content of the hack.
If you allready modifyed it - or you need to use the hack on a non-english site, then edit the /administrator/components/com_virtuemart/langguages/common/YOURLANGUAGE.php,
where YOURLANGUAGE is obviously your language ;), locate at the end this code:
); $VM_LANG->initModule( 'common', $langvars );
?>
and add before:
'PHPSHOP_ROLO' => 'Window blinds',
'PHPSHOP_WITH_ROLO' => 'with window blinds',
'PHPSHOP_HEIGTH' => 'Heigth',
'PHPSHOP_HEIGTH_ALLOWED' => ' Allowed heigth is between %s mm and %s mm',
'PHPSHOP_HEIGTH_ERROR' => 'Heigth not in allowed limits, values entered for dimensions will be ignored, defaults will be used instead.',
'PHPSHOP_WIDTH' => 'Width',
'PHPSHOP_WIDTH_ALLOWED' => ' Allowed width is between %s mm and %s mm',
'PHPSHOP_WIDTH_ERROR' => 'Width not in allowed limits, values entered for dimensions will be ignored, defaults will be used instead.'
And, of course, add a comma (,) at the end of previous line, otherwhise you will generate an error.
Translate the strings after => to your language, and you're done!
Here you can find the latest version of the Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5 listed on VirtueMart's forum .
Manuals can be found here: {phocadownload view=file|id=31|target=s}
Beta-version of the user manual of Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5.
Check back, file will be regularly updated!