VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Development Projects, Modifications, Hacks & Tweaks. VM1.1 => Topic started by: webgobe on November 23, 2011, 11:33:40 am

Title: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on November 23, 2011, 11:33:40 am
Since the original hack is greatly extended I decided to start a new thread for the update.
The current version, which will be attached there (and you will have a link to the download in my signature) will be available from my homepage too.
There are still rough corners, and the documentation needs update - this is the main reason I postponed the launch of this version - but the hack is perfectly usable, and the code is updated for VM 1.1.9 and Joomla 1.5.
It's backward compatible to VM versions 1.1.4 (tested) and might work even with earlier versions (1.1.2 and 1.1.3) too.
It's a core hack, use it on your risk!! Support is free, but it's only in the limits of free time I can dedicate to it (that's it, milk and bread is still sold on real money at my place too, and I am a professional freelancer, not a hobbyist). I'm usually overwhelmed with commercial jobs, so you can expect some delays in the responses.
If you want a quick and effective response, send me the following data along with your support request:
Prepare yourself to the eventuality that I MAY need full access to the site in the case you cannot fix it yourself based on the tips provided.
And remember! This hack is built upon a work of couple of dedicated VM professionals, and contains code released as "side effect" of some commercial assignments, code released to the public with approval of the  people who where paid for it. And this trend will be continued, all code added will be shared - if I can obtain the consent of the buyer.

A relatively long, but incomplete list of contributors is found in the docs, and in the previous threads dedicated to this hack:
Converted Custom Attributes Extended Hack 2.1 for VM 1.1 + J1.5 - http://forum.virtuemart.net/index.php?topic=39666.0
Custom Attributes Extended 2.1 [Hack]  - http://forum.virtuemart.net/index.php?topic=28192.0
PS1. Since the new regulations in the forum does not let me put a link on the signature, you must came back here... or find my site where I also will list the hack.
PS2. Pay credits to ALL contributors. I am only a humble contributor to this hack, there are others, who developed it to the stage where I picked it up (first for my own needs) and weaken up in one day as the sole supporter of the hack. But this does not mean, that would be possible to read this and use this hack without work of Barnett (author of original hack), Joseph Kwan (who ported it to VM 1.1/Joomla 1.5), Nemesis02, Cer, Ben Stovall, Ruppert, Mike Taylor and many others I may forgot - my apologies for them!


[attachment cleanup by admin]
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: mizou125 on November 23, 2011, 22:01:30 pm
Hi,
Thank you for this version,
i have a error :
Fatal error: Class 'ps_product_custom_type_file ' not found in \administrator\components\com_virtuemart\classes\ps_product_custom_attribute.php on line 92

Can you help me please ??
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: cyb3r on November 23, 2011, 22:07:43 pm
Hello webgobe,

really nice work! It is a nice hack for virtuemart. I have testet the functions a little bit and i have a problem with the addition of many price values from checkboxes.

I have created a product and add this to custom attributes list: Donate (checkbox)(Who do you want to donate to?|title-hover)(Widows [+5.00], Orphans[+10.00], Test[+20.00]). Now in the cart the values get not sum up. It works only if one checkbox is selected, but not for multiple selection.

Can you help me please to fix it?

Best Regards,
cyb3r
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on November 24, 2011, 08:23:40 am
Fatal error: Class 'ps_product_custom_type_file ' not found in \administrator\components\com_virtuemart\classes\ps_product_custom_attribute.php on line 92
Send me an URL. Seemingly you didn't installed the hack correctly - or you use a VirtueMart template other, than the default one, and didn't made the modifications needed for the template.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on November 24, 2011, 08:26:09 am
I have created a product and add this to custom attributes list: Donate (checkbox)(Who do you want to donate to?|title-hover)(Widows [+5.00], Orphans[+10.00], Test[+20.00]). Now in the cart the values get not sum up. It works only if one checkbox is selected, but not for multiple selection.
Hmm, probably will need SuperAdmin access to debug it. But let me try on local testbed site your attribute, to be sure that is working on my setup.
Update:
Works on my end, so it's something wrong with your setup
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: themiffs on November 24, 2011, 13:07:09 pm
Hi Webgobe,

I have the latest custom attribute hack working well on my site but i use a paid add on called product builder, when this add on loads a product with the hack in it the page prints out the contents of what is typed into admin and does not run the code as it does on the normal fly page (which works fine) i use the window attributte. i wondered if anyone or yourself new if i could add some code into the product builder page to get the code running as it should.

Thank you very much

Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on November 24, 2011, 13:28:08 pm
Hope someone will pick up your request. I am fully booked next couple of weeks. Maybe after 5-6th December may have some time...
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: amthucgiaitri on November 28, 2011, 08:17:52 am
Hi webgobe,

I wonder that can we put a hyperlink on the radio option. What i want is whenever click on the images on the option box, it's will load a lightbox for the larger image or html.

Can we do that?

Thanks in advance,
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on November 28, 2011, 08:43:24 am
The code which creates the radio boxes (with images) is found in /administrator/components/com_virtuemart/classes/ps_product_custom_type.php lines 146-240 and components/com_virtuemart/themes/default/templates/product_details/inclused/ps_product_custom_type_radiobutton_selector.tpl.php. You can play with the code, as you wish.
To add a lightbox to a larger image is something already implemented, check line 195 of the code. You can simply add the full image to the attribute's syntax, with adding a second image to each option, and that will be shown in a lightbox.
To add a link would need some extra coding, including changing/tweaking the syntax. It's not a 2 line tip.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: amthucgiaitri on November 28, 2011, 09:00:27 am
Hi webgobe,

Thanks for your so fasting reply. Now i can load a light box as your instruction on putting the 2nd image on the attribute.

Now, i trying make it load an html link.

Thanks again for your reply and wonderfull hack.  ;)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: hothotheat on November 29, 2011, 14:40:56 pm
Hello webgobe,

really nice work! It is a nice hack for virtuemart. I have testet the functions a little bit and i have a problem with the addition of many price values from checkboxes.

I have created a product and add this to custom attributes list: Donate (checkbox)(Who do you want to donate to?|title-hover)(Widows [+5.00], Orphans[+10.00], Test[+20.00]). Now in the cart the values get not sum up. It works only if one checkbox is selected, but not for multiple selection.

Can you help me please to fix it?

Best Regards,
cyb3r

Same problem here. I have tested it on a fresh installation with the default theme.

I am using Joomla 1.5.23 and Virtuemart 1.1.9.

And while using the radio buttons i get a javascript error:
handleCheck is not defined

Best regards,
Stephan
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on November 29, 2011, 16:34:23 pm
If you want a quick and effective response, send me the following data along with your support request:
  • VM version
  • Joomla version
  • URL of the shop
  • VM template used
  • List of eventual VM hacks used others, that most recent version of CAE
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on December 02, 2011, 01:09:49 am
Hi!
It is a great hack
Is it possible to provide information about the exact changes in the vm files because I have made so many hacks and it is very hard to just copy and paste your hack.
I have extracted the changes.
Also:
Is it possible to add a description (tool tip with text or modal pop up including a joomla article) for each attribute (radio buttons)?
I try to do that by myself but when I add the product to the cart it stays empty.  I have changed the code of ps_product_custom_type.php.
Is it possible to make an add to cart button with quantites for eack custom attribute group?
Thanks!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 02, 2011, 08:39:03 am
Is it possible to add a description (tool tip with text or modal pop up including a joomla article) for each attribute (radio buttons)?
I try to do that by myself but when I add the product to the cart it stays empty.  I have changed the code of ps_product_custom_type.php.
Humm, need to explore the possibilities here, probably can be done, but you need to be VERY careful, all CAE - related trickery takes place in fact in the cart. If wrong things are passed to cart that can render the whole thing unusable.
Is it possible to make an add to cart button with quantites for eack custom attribute group?
Don't think so. You need to adopt another approach for that. CAE modifies the behavior of a PRODUCT. Different attribute groups are just different properties of the same product - and you can put in the cart only PRODUCTS.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on December 02, 2011, 10:19:12 am
Humm, need to explore the possibilities here, probably can be done, but you need to be VERY careful, all CAE - related trickery takes place in fact in the cart. If wrong things are passed to cart that can render the whole thing unusable.
I know it simply does not function. I will explorer.
Don't think so. You need to adopt another approach for that. CAE modifies the behavior of a PRODUCT. Different attribute groups are just different properties of the same product - and you can put in the cart only PRODUCTS.
May be I will try with child products, or to link a product, or to make an attribute with quantity box.

Have you ever tryed to make price update for that hack.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 02, 2011, 13:09:16 pm
Price update? Yes, I attempted it once, and then abandoned. You would need to replicate the cart functionality in the product page for that. Don't worth the effort. (At least nobody needed in a commercial project - or offerefd the finacing for developing it). don't have it in plans - I have other things, more useful ones I guess on my list.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ir_valentin on December 04, 2011, 00:07:48 am
Can u re-upload the files please, the links are dead :( ?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: frankele on December 04, 2011, 04:56:08 am
Fatal error: Class 'ps_product_custom_type_file ' not found in \administrator\components\com_virtuemart\classes\ps_product_custom_attribute.php on line 92
Send me an URL. Seemingly you didn't installed the hack correctly - or you use a VirtueMart template other, than the default one, and didn't made the modifications needed for the template.

Hi mizou125,
Did you figure out what was wrong, why you were getting that error message? I don't know why I'm getting the same message.
Please help.
Thanks.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 05, 2011, 10:11:01 am
Can u re-upload the files please, the links are dead :( ?
sh404SEF generated some bad links for the Romanian version of my page. Fixed. If anyone else is running into similar issues, please, check other language variants (English, Hungarian) or download the files from this thread.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on December 07, 2011, 06:29:54 am
Fatal error: Class 'ps_product_custom_type_file ' not found in \administrator\components\com_virtuemart\classes\ps_product_custom_attribute.php on line 92
Send me an URL. Seemingly you didn't installed the hack correctly - or you use a VirtueMart template other, than the default one, and didn't made the modifications needed for the template.

Hi mizou125,
Did you figure out what was wrong, why you were getting that error message? I don't know why I'm getting the same message.
Please help.
Thanks.

Just remove the white space in code. Look carefully when you copy paste the code from the manual.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: davidyv on December 13, 2011, 04:00:25 am
Hello webgobe,

Thank you for this version, It is a nice hack for virtuemart. I wonder that can we to add the disabled Attribute to these input element. The disabled attribute can be set to keep a user from using an input field until some other condition has been met (like selecting a checkbox, etc.).

Can we do that?

Thanks in advance
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 13, 2011, 08:45:34 am
Not that easy... because these attributes are built to work independently from each other, but isn't impossible. In fact there are couple of similar functionalities implemented, you can create a group of couple of (specific) attributes controlled by a checkbox, and there are another ones - like the "pizza" or the "reservations", "windows" attributes, which have some kind of "cascading" behavior implemented. Read the manual and the old thread, you will find good examples.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: blueargylemedia on December 13, 2011, 19:43:07 pm
I could not find my answer in the threads on this and I am hoping someone could shed some light for me.  I have used this hack on a number of sites and it works great but the group options are not working in some versions of ie and I cannot figure out what the heck.

The site is:  lunch dot oslsedu dot org

PHP Built on:    Linux p3slhssl12.shr.phx3.secureserver.net 2.6.18-238.19.1.el5PAE #1 SMP Fri Jul 15 08:15:44 EDT 2011 i686
Database Version:    5.0.91-log
Database Collation:    utf8_general_ci
PHP Version:    5.2.17
Web Server:    Apache
Web Server to PHP interface:    cgi-fcgi
Joomla! Version:    Joomla! 1.5.10 Production/Stable [ Wohmamni ] 27-March-2009 23:00 GMT
VirtueMart 1.1.9 stable

Thanks!

Oh and I am using the default template.  Thanks!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 13, 2011, 20:09:03 pm
In IE8 looks okay. I don't have IE9 on any of my PC's to test...
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: blueargylemedia on December 13, 2011, 20:39:38 pm
Thank you! A shopper today who has 8 said it would not work for her.  The dropdowns did not show up and I have been unable to replicate the error in any browser I have. Darn, and she is kinda done with all my questions.  She is just going to order at home.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on December 20, 2011, 05:11:07 am
Hi! I saw that there is an option to add big image in radio type, but when I do so it gives me a massage - the cart is empty:
the coda I use is:
Soup(radio-r)(Please choose a soup|title-hover)(Soup 1[+5.00]|images/img_blue.jpg|images/img_bluebig.jpg,Soup 2[+10.00]|images/img_red.jpgSoup 3[+10.00]|images/img_red.jpg,Soup 4[+10.00]|images/img_red.jpg)
Any idea
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 20, 2011, 10:06:53 am
Hmm, need to play with your code... but might be that you did not added big images to all... This part of hack is not my development, so need to play with code to see where fails. I'm swamped right now, but I added it to the shortlist of possible bugs.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on December 20, 2011, 11:04:57 am
OK! But there is no problem with the other products in the code. I will try to add "|" to the other one too to see what will become. And I saw some other small problems with code, but I will send them later may be.
I tryed with description but it fails as the big image. I will post the code I use later today.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ivannk on December 20, 2011, 11:56:17 am
I have same problem with images. I dont see image but there are only name of attributes.
Jomla 1.5.22 and VirtueMart 1.1.7 stable
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on December 20, 2011, 14:10:13 pm
As I told earlier - the problem is in the code. I have tested with the old hack and it is OK.
I will look to compare.
In ps_product_custom_type.php -> line 200 -> $html .= "<div class='radio_box' overflow:hidden' align='center' float='left'>"; // Style

I've compared the scripts and there is no problem with them at all. Just a small styling mistakes.
I've succeeded to add description (text, link to joomla article or K2 item) to the attributes and they pop up with modal as the big image.
I also have changed the path for storing the images to images/stories/vm, because I think it will be easy to upload and manage them.
There are some other things to figure, for example to show the attribute image in cart and to make a custom add to cart template (I just should find it in my archive).
There are some other ideas in my mind but I have and other things to do.
The problem before may be is a result of K2 v2.5.4, or Mootools version 1.2.5, or one of my custom plugins which manages the scripts (I will find).

Regards!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on December 21, 2011, 03:00:59 am
I have same problem with images. I dont see image but there are only name of attributes.
Jomla 1.5.22 and VirtueMart 1.1.7 stable
Check the path....
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 21, 2011, 08:04:45 am
Thanks, dido76bg for the update!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ir_valentin on December 22, 2011, 18:07:22 pm
I have 56 images like radio selection, added as custom attributes, one under the other and I want to arranged them on multiple columns and lines. I need a big help because i don't know how to modify files for that.
The link is that: http://www.alluflex.it/home/tende-alla-veneziana/15-mm.html

Thanks in advance !
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 22, 2011, 19:24:33 pm
It's not a 2 click thing, but basically this is what you need to know:
There are 2 files you need to modify. One is the VM template's CSS file, and another is the ps_product_custom_type_radiobutton_selector.tpl.php, also found in the default VM template, in templates/product_details/includes/custom_attribute folder.
This is the code you will need to play with.
Code: [Select]
<div style="width:20%;float:left;text-align:right;margin:3px;">
<input type="radio" id="custom_attr_checkbox_' . $custom_type_checkbox_group . '" name="custom_attr_checkbox" onclick="toggleCustomType' . $custom_type_checkbox_group . '(this)" />
</div>
<div style="width:75%;float:left;margin:3px;">
' . $custom_type_checkbox_label . '
</div>
<br clear="both" />
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ir_valentin on December 22, 2011, 21:26:29 pm
I solved the problem, i used checkbox instead radio , i modified the file ps_product_custom_type.php , all colors are now aligned in three columns and also created the lightbox full image for checkbox. Code for all changes


Code: [Select]
***************************************************
 *
 * CHECKBOX element class
 * The class is is used to manage the product custom attribute type.
 *
***************************************************/
class ps_product_custom_type_checkbox extends ps_product_custom_type_base {
var $classname = "ps_product_custom_type_checkbox";

    /**
* Outputs HTML for Custom Attribute
*/
function customTypeHTML($field=array()) {
global $mosConfig_live_site;
    $html = "";
$titlevar = trim($field['attr_pagevar']);

$values=explode(",",$field['attr_value']);
foreach($values as $valueWhole) {
   
$valueArr = explode('|',$valueWhole);
$value = $valueArr[0];
$value_img = $valueArr[1];
$value_full_img = $valueArr[2];
        $checked = strstr($value, '*') ? ' checked="yes" ' : '';
$value = str_replace("*","",$value);

if(strrpos($value,'[')){
$base_var=substr($value,0,strrpos($value,'['));
} else {
$base_var = $value;
}
$base_var=trim($base_var);
$base_var=str_replace(" ","_",$base_var);

            if ( isset($_POST[$titlevar]) && in_array($base_var, $_POST[$titlevar]) ){
                    $checked = ' CHECKED';
            } else if ( isset($_POST[$titlevar]) ){
    $checked = '';
        }

      //~ $show_value = str_replace("[+","+",$value);
//~ $show_value = str_replace("[-","-",$show_value);
//~ $show_value = str_replace("[=","+",$show_value);
      //~ $show_value = str_replace("]","",$show_value);
$show_value=$this->getPriceWithTax($value);
if($value_img){
if($value_full_img){
$show_value = "<a title='".$show_value."' rel='lightbox' href='".$mosConfig_live_site."/components/com_virtuemart/shop_image/".$value_full_img."'><img src='".$mosConfig_live_site."/components/com_virtuemart/shop_image/".$value_img."' alt='".$show_value."' class='".$titlevar."_img' border=0 align='center' /></a><br />".$show_value;
}
else {
$show_value .= "<img src='".$mosConfig_live_site."/components/com_virtuemart/shop_image/".$value_img."' alt='".$show_value."' class='".$titlevar."_img' border=0 align='left' />";
}}
$html .= "<div class='checkbox_box' style='border: 1px dotted #CCC; width:150px; margin: 2px; padding: 2px; float: left;'>"; // CSS Style
$html .= "<input type=\"checkbox\" class=\"inputbox\" id=\"".$titlevar."_field\" name=\"".$titlevar."[]\" value=\"".$base_var."\" ". $checked ."/>".$show_value;
$html .= "</div>";
}

return $html;
}
Thanks for all your advice.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 23, 2011, 09:45:30 am
Great solution, I recommend it for anyone needing something similar!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ivannk on December 23, 2011, 11:24:01 am
I have same problem with images. I dont see image but there are only name of attributes.
Jomla 1.5.22 and VirtueMart 1.1.7 stable
Check the path....

I think everythink is OK. I inserted images to folder images with *.jpg extension. Then I put code just fo test.

Quote
Name(radio)(tip here|location)(option1|images/img_blue.jpg,option2*|images/img_blue.jpg,option3 [+5.00] |images/img_blue.jpg)
and result is (http://)

[attachment cleanup by admin]
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 23, 2011, 11:53:23 am
http://forum.virtuemart.net/index.php?topic=93745.msg312578#msg312578
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ivannk on December 23, 2011, 12:43:26 pm
\www\joomla\images\img_blue.jpg    665 B   17.12.11 16:19   -a--
copy from file manager
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 23, 2011, 13:11:55 pm
And you checked the source of the page you don't seeing them ;) - just rightclick on, to see where the page seeks for these images!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ivannk on December 23, 2011, 14:06:45 pm
ahhh yeah Fire bug
path is /components/com_virtuemart/shop_image/images/img_blue.jpg
thanks 
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ma57er on January 10, 2012, 22:03:16 pm
Hello guys! This hack ROCK! I have simillar problem like other person here: I get this error:

Code: [Select]
Fatal error: Class 'ps_product_custom_type_file ' not found in ...../administrator/components/com_virtuemart/classes/ps_product_custom_attribute.php on line 92J version: 1.5.23
VM Version: 1.1.9.
URL: http://vrati-bg.eu/gamers/index.php?option=com_virtuemart&page=shop.browse&category_id=1&Itemid=119 (try product "product")
Default template
No other hacks - clean installations

Anyone have any suggestions?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on January 11, 2012, 09:08:27 am
Did you have overwritten ALL the files with files found in the package? It's mandatory - or you must apply the differences found in files.
Is the most common error regarding this hack - and generates this kind of errors.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on January 11, 2012, 09:47:19 am
Hi now I have some problems with production site:
User cannot order more than one item. aftethat cannot add. In local host everithing is OK
Any idea.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on January 11, 2012, 11:48:19 am
check your VM main configuration. The URL's are all okay? Often when moving from development to production site people forgot to update the VM settings... wich are pointing back to the old location, creating all sorts of weird problems.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on January 11, 2012, 12:44:57 pm
The URLs are OK! I have made a clean install on the web server and after that I updated the hacked files.
You can check your self http://www.bgfresh.com
The problem comes when I add two options for the product and rty to order with them two.
It gives an error page, when I do not use ajax to update catr
Help please
Thanks!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ma57er on January 11, 2012, 13:02:31 pm
Webgobe - yes, i overwritte all files. I tried on two different sites and error is same. Now ill try manual to make this
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on January 11, 2012, 13:19:04 pm
The URLs are OK! I have made a clean install on the web server and after that I updated the hacked files.
You can check your self http://www.bgfresh.com
The problem comes when I add two options for the product.

Thanks!
There are two problems: 1 and most important - The attributes MUST have a name. Withouth that, the hack does not work...  So, first of all, be sure you don't left the name of the attribute blank, and there are no two similar attributes with same name.
2. seems to be a minor problem with the checkbox type of attribute too. Will check it as I have some time for it, but right now I'm swamped...
In mean time you can revert to the earlier version of the hack - see the older thread. That also works with the latest vm 1.1.9, and does not have this problem. Will get back to you as I find the pronlems.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: ma57er on January 11, 2012, 14:48:12 pm
The problem with this error is all mine!

I was copy examples from the manual and for radio/seclect/ceckboxes examples are on two rows. When i paste them, the code is on two rows and this is the problem :) When i write all need things - all work like charm!

Thanks for attention webgobe!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on January 11, 2012, 16:37:44 pm
Hi!
They all have names. I installed VM on that address only for testin (the font is white).
I have checked the old versions, but no success, do you know exactly which one I should use.
Thanks
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on January 11, 2012, 16:54:48 pm
Converted Custom Attributes Extended Hack 2.1 for VM 1.1 + J1.5 - http://forum.virtuemart.net/index.php?topic=39666.0
Or you will find it on my homepage
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: dido76bg on January 11, 2012, 17:18:33 pm
I will check and will write back.
I have tested with radio, check, select and multiple (with and without Ajax, with old and newer hack) and the result is:
problems with all of them if I try to put two radio (check, select or multiple) options
What can be wrong
I am leaving an example (not working) to see it.
http://bgfresh.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=1&category_id=1&option=com_virtuemart&Itemid=1 (http://bgfresh.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=1&category_id=1&option=com_virtuemart&Itemid=1)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: bardossi on January 14, 2012, 16:02:13 pm
Hi!
I am glad I found this hack, this is what I have been looking for so long, especially the file upload feature.
However, I am not a coder and I may messed up something. When I add a custom attribute there is the possibility to write a tooltip. In my shop it looks different on localhost and different on the server (attached pictures). Does anyone know where can I fix this?

Thanks in advance!

bardossi


[attachment cleanup by admin]
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on January 16, 2012, 09:08:19 am
The styling of the tooltips is related not with the server you use (local or live), but the template - more specifically the CSS rules from your template(s) used. Don't forget, that there are couple of CSS files active on any single VM/Joomla page.
Check this, may help you fixing the issue.
PS. (Irj egy direkt uzenetet, ha nem megy)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: bardossi on January 16, 2012, 11:43:40 am
Thanks for your reply. No, it was not the CSS, I messed up something with one of the .php files in themes\default\templates\product_details folder. Now I overwrote all of them and now the tooltips are looking good.

PS: Yes, I noticed we speak the same language...:) Küldök majd PM-et, ezzel a projekttel kapcsolatban kérnék majd ajánlatot tőled!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: 2maz on February 01, 2012, 19:11:28 pm
Hi all, the hack "surface" based on the old version work well for me, after turning around a little bit. On VM 1.1.9 + J1.5 offline for now.
I have two questions :
Did the surface option still work in cae9 ?
Do you have a way to calculate the discount based on the total surface for one product ? I explain, the shopper can buy by surface and he can choose, for exemple the color with the same product.
Then I disconnect the discount on the product something like (100|100|5|18|10|18|20|18|100) and the price is not affected as I wanted. Now I would like to obtain someting like this :

Piece of shirt  Colour red   100X200 (+18€)                         36€
Piece of shirt  Colour blue  200X200 (+54€)                        72€
Piece of shirt  Colour green  200X200 (+54€)                     72€

Total Discount for piece of shirt is :   10 meters at discounted price 15€  = 150€   you win 30€  (180 - 150)
 (based on surface or price, it's the same because if the price for one meter is 18 than you know that 72 is for 4 meters)

I hope my questions are clear, I'm searching.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 01, 2012, 19:43:49 pm
Yes, the surface works in cae9. There are some minor things in CAE9 needing fixes  - as the bug with multiple checkboxes - but 99% of things are working.
As for your other question... since all the maths regarding the CAE hack are happening in the cart I donát see an out-of-the-box solution for your problem. But with some extra coding what you want can be implemented. You need to do something similar what I did with the Window/Window shield attributes, which are enhanced variants of Surface attribute (or with  Pizza  or Registration) - to pass the outcome of the Surface to a linked attribute, wich does the magic - this time to apply the discount.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: 2maz on February 01, 2012, 19:55:10 pm
Incredible quick answer ! Thank's a lot. I will try to follow the way you show me, with my small php knowledge. If I don't find, I will contact you.
Thank's again !
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 01, 2012, 20:10:14 pm
LOL, I am just taking seriously what Yoda said: "You will find only what you bring in."
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: kamstrup on February 05, 2012, 20:00:02 pm
So, I have difficulties with this.
On a fresh install Joomla 1.5.25 and VM1.1.9, template is an Artisteer template.
I want at text subject box, a text area and radio or checkbox with 3 options and 3 different prices.

So my first question: in the manual 3.2 Virtuemart, it states it is for VM 1.1.13 and up.... what am I missing? 1.1.9 is the latest 1.1.x version?

Adding a text box is simple.
Now, when I want to add my options, things start to crash. I just get an error: Connection to server was reset.

Subject(text)(|field-above)();Q(textarea)(|field-above)();Details(radio)(Choose level of details|title-hover)(Short|,Long|,Detailed|);

Adding prices does not work either.

So I was wondering, I'm of course using ISO numbering, i.e. decimal commas etc in the shop. If I use decimal commas in the line, it will not work. And I assume that using decimal points gets translated correctly? I've tried changing from ISO to decimal points, removing decimal, writing just [34] insted of [+34] or [+34.00]. None seems to work.

I use Firefox 9 and IE 9.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 06, 2012, 09:22:40 am
First issue is a typo - 1.1.3 is the correct number, obviously.
Second - to find out what is causing that crash, I need to examine the site - inside out. But, a first question:
Do you use the DEFAULT VirtueMart template for your shop? Did you overwrote ALL files with the ones found in the package? Did you installed VM first on another server then moved it to the actual location? - these are the top mistakes here. The forum is full with issues related with these 3 things.
To be able to find out wazzup and to eventually fix your site, I need FULL access to it (Superadmin, FTP - and maybe even phpMyAdmin - less likely)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: kamstrup on February 07, 2012, 00:22:08 am
First I would have answered yes, yes, no. I have read the forum posts... :-)
But...you made me think.
I installed Joomla in a different folder and moved the install from one folder to another.... no packing/unpacking. Kept the same server.
And, come to think of it, had VM 2.0 installed for a few hours before I uninstalled it to avoid stress :-) Attributes should be smart in 2.0.... Maybe it will be that in a few revisions. Had difficulties even making child products.
Then I installed VM 1.1.9
Default template.

Ok, I'll do a fresh reinstall, try the whole deal again, and then turn back if needed.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 07, 2012, 08:06:47 am
The reason I asked if you relocated the Joomla install is simple - in these cases the VM configuration is also needs to be adjusted! More specifically the live shop/secure shop URL's.
OK, I'm here, tuned.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 07, 2012, 08:15:15 am
Check now the site - works. As I suspected, was a de-synchronization between the Joomla site's live URL and the SiteURL/SECUREURL settings in VirtueMart's main configuration.
These MUST match! And not only for CAE hack.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: 2maz on February 08, 2012, 08:13:46 am
Hi Padawans, here is the result of my searchings. The solution I've found is not exactly what I was looking for but it's a first step. My problem is to use the surface attribute but the friend for whom I make a website is not really satisfied by the possibility to make a discount on only one product. In fact, he will sell some furnitures by square meter and the shopper can choose differents version of this product, for exemple a piece in blue + a piece in red + another one with a different finish (plastic, shinny, etc...) So it's logical to try to apply a discount on the category because it's basically the same product and many pieces produce a total square meter. So how to apply the discount. I'm still searching and maybe coupons can be the solution, I will explore thoses days, but for now here is what I have done.
In surface attribute, as I say'd in my posts before, I don't use the inself discount by using the same price for each step of discount, than it calculate  the surface only (thank's for the work made by all devs of this solution) and I combinate it with the "Discount Modul for VirtueMart"  know as "Rabatt"  and the result work's well. The only thing is that the discount is applied on all the cart. So I suggest to my friend to calculate the prices of all his products with this kind of discounts, but I understand it's an half solution. Maybe coupons... and some nights to search.
I hope this post can help, if anybody have any idea I believe in brainstorming.
May the force be with you !   -)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Mike_Griffiths on February 10, 2012, 22:43:05 pm
Hello to all,

I hope someone can help me shed some light on my situation. My setup is Joomla 1.5.18, VM 1.1.4 and I have upgraded the Custom Attribute Hack from the old one to the file CAE9 found on this discussion. The upgrade seemed to go very well, no problems that I can see and the hack is working as it should so far.

My problem is, I am using the checkbox attribute to add a picture against the option, like metioned in a previous post in this discussion, which works absolutely fine. However, in Mozilla Firefox the 'Add to Cart' button has disappeared. I can only assume it is there somewhere but hidden under this hack. Tried to view my hack in IE8 an Safari with no problems at all, the 'Add to cart' button displays under the hack.

The web address for you to look at is http://www.gee-embroideryandprint.co.uk/products/menswear/hooded-tops/details/123/27/menswear/hooded-tops/jh001-awdis-college-hoodie.html

I am hoping there is a quick fix, or there may be a workaround to get my 'Add to cart' button back in Mozilla Firefox. Or some more elegant way to make sure the 'Add to Cart' always remains below the hack. Sorry, but my php skills are non existent at the moment, any advice would be great.

If someone could point me in the right direction I would be a very happy chappy!  ;)

EDIT: I have found this to do with my css, nothing to do with the hack. Still I have extended the padding to get it back in Mozilla, still looking for a more elegant solution if anyone has any ideas?

EDIT 2: I have had to remove the hack and revert back to the earlier version of this hack. This was to do with the Hack causing problems with the backend admin side of Virtuemart. It was throwing the backend display out and I read this was something to do with Javascript errors. I am not using the default theme and probably need to perform the hack on my selected virtuemart theme instead.
 Another reason for reverting back was so that I could re-introduce Forrests' Meta Hack which seems to use some of the same files as this hack. So if you are wondering where the styling and hack has gone, its work in progress. Would love to be able to get the CAE9 hack and Forrests' Meta hack working together. Will keep you updated if I manage to get this sorted, and if someone has already got them both to work I would love to know.

EDIT 3: Sorry to keep replying to my own post. But I have cracked it. I can confirm that Forrests' META hack and this CAE9 hack do in fact work nicely together for those who are interested. I started from a backup with no sign of META hack and CAE9 hack and applied them both again (META hack first). Checked the META hack was functional first of course. The META hack shares 2 of the same files as CAE9 so after implementing the META hack on my site it was a case of opening ps_product.php and product.product_form.php in both hacks and copying the clearly marked META hack into the CAE9 files. The META hack is clearly marked in both the mentioned files so was easy to find and slot in. After this, just FTP all the CAE9 files over aswell as the 2 newly modified ones and viola! I Hope this helps someone looking to do the same.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Eddzor on March 08, 2012, 10:33:55 am
can I get custom attributes on category browse page with this? or is it some hack out there to fix that?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 08, 2012, 10:55:21 am
Mike:
Yes, if you don't use the -default- VM template, you need to add the hack to your template files too. And one of the edits you need to made is on the Add-to-cart button code.
And yes, the button is there, just some CSS fixes are needed. You can do that in your VM template's CSS files, as I see on your template the Add-to-cart button is  placed in
Code: [Select]
   <div class="details-cart-form">you need to tweak the settings for that div.
Eddzor:
This hack can't do that. And i don't know any additional hack "to fix that" ;) To accomplish what you might need needs a hack performed on top of this hack.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Eddzor on March 08, 2012, 11:21:51 am
Thanks for your reply webgobe! Damn, I'm looking desperately for a solution to it. The only thing I need is the input text on category browse page. I have managed to add dropdown and add to cart, but not input text :(
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Mike_Griffiths on March 12, 2012, 11:32:33 am
Webgobe:

Thanks for your information. I am able to pull the add to cart button back in on Mozilla by altering the css code you mentioned. Thanks for your help.  :)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 12, 2012, 11:36:51 am
Glad to hear that!
Congrats!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on March 12, 2012, 12:28:03 pm
I have a question. I've got group attibutes (2 groups) each of them has a select list with items that should add a certain amount to the price. But they don't. When I choose one of them in the frontend and add the product to the cart, the additional price is correctly depicted in the product's desciption but the product's price remains the same. Is it known bug or only my problem?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on March 12, 2012, 12:33:40 pm
Hello to all,

I hope someone can help me shed some light on my situation. My setup is Joomla 1.5.18, VM 1.1.4 and I have upgraded the Custom Attribute Hack from the old one to the file CAE9 found on this discussion. The upgrade seemed to go very well, no problems that I can see and the hack is working as it should so far.

My problem is, I am using the checkbox attribute to add a picture against the option, like metioned in a previous post in this discussion, which works absolutely fine. However, in Mozilla Firefox the 'Add to Cart' button has disappeared. I can only assume it is there somewhere but hidden under this hack. Tried to view my hack in IE8 an Safari with no problems at all, the 'Add to cart' button displays under the hack.

The web address for you to look at is http://www.gee-embroideryandprint.co.uk/products/menswear/hooded-tops/details/123/27/menswear/hooded-tops/jh001-awdis-college-hoodie.html

I am hoping there is a quick fix, or there may be a workaround to get my 'Add to cart' button back in Mozilla Firefox. Or some more elegant way to make sure the 'Add to Cart' always remains below the hack. Sorry, but my php skills are non existent at the moment, any advice would be great.

If someone could point me in the right direction I would be a very happy chappy!  ;)

EDIT: I have found this to do with my css, nothing to do with the hack. Still I have extended the padding to get it back in Mozilla, still looking for a more elegant solution if anyone has any ideas?

EDIT 2: I have had to remove the hack and revert back to the earlier version of this hack. This was to do with the Hack causing problems with the backend admin side of Virtuemart. It was throwing the backend display out and I read this was something to do with Javascript errors. I am not using the default theme and probably need to perform the hack on my selected virtuemart theme instead.
 Another reason for reverting back was so that I could re-introduce Forrests' Meta Hack which seems to use some of the same files as this hack. So if you are wondering where the styling and hack has gone, its work in progress. Would love to be able to get the CAE9 hack and Forrests' Meta hack working together. Will keep you updated if I manage to get this sorted, and if someone has already got them both to work I would love to know.



EDIT 3: Sorry to keep replying to my own post. But I have cracked it. I can confirm that Forrests' META hack and this CAE9 hack do in fact work nicely together for those who are interested. I started from a backup with no sign of META hack and CAE9 hack and applied them both again (META hack first). Checked the META hack was functional first of course. The META hack shares 2 of the same files as CAE9 so after implementing the META hack on my site it was a case of opening ps_product.php and product.product_form.php in both hacks and copying the clearly marked META hack into the CAE9 files. The META hack is clearly marked in both the mentioned files so was easy to find and slot in. After this, just FTP all the CAE9 files over aswell as the 2 newly modified ones and viola! I Hope this helps someone looking to do the same.
I think there's no better solution than to edit your CSS. You can find which eactly file you should edit if you examine the element with Firebug or so.
There was a topic on this forum how to fix some of the problems with the hack's layout, but i don't remember where it is. Google it. I edited my files just for my needs. As far as i remember those were ccs as wel as some php file(s) having occasional ccs and thml  codes .
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 12, 2012, 12:39:59 pm
I have a question. I've got group attibutes (2 groups) each of them has a select list with items that should add a certain amount to the price. But they don't. When I choose one of them in the frontend and add the product to the cart, the additional price is correctly depicted in the product's desciption but the product's price remains the same. Is it known bug or only my problem?
Do you have an URL where I can take a look?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on March 12, 2012, 13:17:15 pm
http://www.affischkungen.se/layout.html?page=shop.product_details&flypage=flypage.tpl&product_id=43&category_id=7
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 12, 2012, 13:24:07 pm
Did you tried to configure the price not with (+ 990.00 :-), but simply as (+ 990.00) in one hand, and secondly, be sure that ALL attributes have separate, different names, so not Antall for both A2 and A3 versions, but for example Antall A2 and Antall A3 - or something like that.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on March 12, 2012, 13:46:29 pm
Did you tried to configure the price not with (+ 990.00 :-), but simply as (+ 990.00) in one hand, and secondly, be sure that ALL attributes have separate, different names, so not Antall for both A2 and A3 versions, but for example Antall A2 and Antall A3 - or something like that.

That was exactly 990.00 without any :- . This is just Swedish currency symbol that is added automatically. And I'm aware about same names in the hack so I entered Antal and Antall. Hope they're treated as different names. So here's my code:
Code: [Select]
Antal(select)(Välj Antal|title- hover)(100 st [+1100.00],250 st[+1350.00],500 st[+1550.00],1000 st[+1850.00])(radiobutton:group1,A2);
Antall(select)(Välj Antal|title- hover)(250 st[+990.00],500 st[+1000.00],1000 st[+1200.00])(radiobutton:group2,A3);
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 12, 2012, 13:53:09 pm
Humm, well, then is another thing, code looks okay. Let me run some local tests...
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on March 22, 2012, 17:22:32 pm
Hi and many thanks WebGobe!

Your hack is perfect, so I managed to let it work with Excel calculation for the price.

Now I will be glad if I could know how to change the prefix of the uploaded files through the (file) custom attribute.

I'd like the prefix to be the order id, rather than the date...

What do you think about? Many thanks however!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 22, 2012, 18:31:10 pm
With a little code hack you can MIGHT do that. Let me explain, why the MIGHT is there in the previous sentence. The code of the prefix is pretty simple.
The code controlling the name of the uploaded file is in ps_product_custom_type.php, in the class "ps_product_custom_type_file extends ps_product_custom_type_base",
more precisely this line:
Code: [Select]
$save_file_name=date('Y-m-d').'.'.strtolower($file_name);As you see, the current date is simply pre-pended to the actual uploaded file name. Simple enough so far, so you cand add virtually anything there, but the problem is, that when the file is uploaded and saved on the server, you DON'T know yet the order number... and I don't see a fail safe algorithm there which could be used to safely determine what will be the order id, since that will be reserved on the system much later, during the checkout process (which might not even occur....).
So I don't see a simple solution to your request. Maybe one can hack the checkout process (not altered by this hack, so should be developed from scratch) to find out the files uploaded, rename them accordingly and change the content of the database too, to have the files named as you want... I don't think, that worth the effort.
An enhancement wich mighy make things easier I see, tough, you can use one or more of system variables avaiable at the moment of upload, as the user name, user_id or something similar to prefix the files. That might indeed make the files easier to locate.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on March 23, 2012, 09:08:28 am
Thanks a lot, WebGobe! This sounds pretty right!
Now I try, but could you imagine a way to let the customer upload its file after the placement of an order?
Let's imagine that the user clicks on "Add to Cart" and right after he get the page for uploading the content, then he continues to shop.
Could you suggest me a way, or some clue?

Thanks in advance.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on March 23, 2012, 11:34:44 am
 i use two file uploads at one product page. How can i make them to be different if two files with one name are uploaded? And how can i add time of upload?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 23, 2012, 17:58:28 pm
@carmineaep - I used jUploader - a standalone PHP component to build in a similar functionality to one shop, ~ 2 years ago.  Not a simple thing, but you can do it.
@timkolm - play with the code... as the date is added to filename, you can add for example the time - which will be different enough to make the difference - or even the file upload attribute's name. It's a very simple PHP programming issue having the info from Message #79 .
Code: [Select]
$save_file_name=time('H-i-s').'.'.strtolower($file_name); will add the time of the upload with hours (in 24 hour format, minutes, seconds with leading zeros like 12-39-59.userfilename.ext
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on March 26, 2012, 14:10:38 pm
Thanks WebGobe, I'll give it a try!

Very useful, however!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on March 26, 2012, 15:38:15 pm
Thanks, WebGobe.
I made every file look differently even inspite if two of them entered with the same name.
Here's my code:

Code: [Select]
$save_file_name=date('Y-m-d_H-i-s').'.'.$titlevar.'.'.strtolower($file_name);
To every file added it's date, time, and name of the field it was upoloaded from.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 26, 2012, 18:28:58 pm
Great, congrats!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on March 28, 2012, 15:12:13 pm
Hello to the gentlemen,

I added a custom attribute with the hack of WebGobe to my products. It is called "Job Name", and I wish to use it for naming my uploaded files, in this fashion:

<upload folder>/<folder named after username of customer>/<job name custom attribute>_<date>_<upload file field name>_<filename>.pdf

Now the question is: how can I get the value of the custom attributes inside ps_product_custom_type for making those gears works?

I appreciate even any clue, so I thank you in advance.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 28, 2012, 16:14:20 pm
Take a look for example to the Pizza attribute. I would do the same: with a 2 line java-script I would add it the value of the job_attribute to a hidden input filed, wich can be read same way in another attribute.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on April 03, 2012, 14:28:04 pm
For WebGobe:

could you please suggest me how to retrieve the value of my hidden input within the File custom attribute?
Or even better, how to get a value from an HTML object for using within PHP?

I checked your Pizza custom class, but can't reach the point where I can gather the value from hidden field.

Any help would be appreciated.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 03, 2012, 16:43:46 pm
OK, here you go: there are two attributes involved, Pizza and Topping.
The hidden attribute is added in pizza:
Code: [Select]
<input  name=\"pizzasize\" type=\"hidden\" readonly=true /> and the value is added by triggering a JavaScript few lines above:
Code: [Select]
$html .= "<select class=\"inputbox\" id=\"".$titlevar."_field\" name=\"".$titlevar."\" onchange=\"pizza_size();\">";the Java Srcipt itself is also there, only you need to go up with a few lines again:
Code: [Select]
function pizza_size()
{
var selectmenu=document.getElementById('".$titlevar."_field')
a=selectmenu.options[selectmenu.selectedIndex].text.indexOf('(+')
if(a>0){
b=selectmenu.options[selectmenu.selectedIndex].text.indexOf(')')
c=selectmenu.options[selectmenu.selectedIndex].text.substring(a+3,b)
e=selectmenu.options[selectmenu.selectedIndex].text.substring(0,a-1)
document.addtocart.pizzasize.value = e
} else {
document.addtocart.pizzasize.value = selectmenu.options[selectmenu.selectedIndex].text
}
}
Now, the second - the "reading" - part, is located in the Topping attribute:
Code: [Select]
needle = document.addtocart.pizzasize.valueAnd here you go!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on April 04, 2012, 11:10:52 am
Nice and thanks!

But how I can put "needle" in a PHP variable?
I feel real close to the solution, but cannot reach it!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 04, 2012, 14:25:53 pm
Kind of impossible.... PHP is executed SERVER side, before the page is sent to browser. JavaScript is executed after PHP is parsed ainto HTML and sent to the browser.
You need to find another trick...  :(
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 04, 2012, 14:26:56 pm
http://stackoverflow.com/questions/4375779/i-need-to-initialise-php-variable-inside-the-javascript-function (http://stackoverflow.com/questions/4375779/i-need-to-initialise-php-variable-inside-the-javascript-function)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on April 12, 2012, 14:51:37 pm
Many thanks WebGobe!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Christopher on April 12, 2012, 17:37:16 pm
Hi WebGobe

First, an excellent hack - thank you very much indeed!

Second, I'm not sure if it's something I am doing wrong or a limitation of the CAE9 but I cannot use option names which are longer than one word. Here's a link to an example product using the hack:

http://www.skiptonhirecentre.co.uk/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=111&category_id=36&option=com_virtuemart&Itemid=77

The site is an online tool hire shop, so customers need to hire, say, a cement mixer for 1 day or 1 day plus an extra day - if I have an option called 'Extra Day' then CAE will not add the correct value to the shopping cart - it reverts to the main original price - if I have an option called 'Extra-Day', it works fine, as in the code shown below:

Hire Period (radio)(Select a Hire Period|title-hover)(Daily [=27.50], Weekend [+6.88], Extra-Day [+11.00], Weekly [+27.50])

... Is this correct? Is there a work-around

Thanks in advance
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 12, 2012, 18:06:13 pm
Yes, it is correct. The hack uses a mix of JavaScript and PHP trickery to do it's magic. The names of the custom attributes are used in the process. So... the fix would be to rewrite large parts of code to make the process "space-proof" - to not wreak havoc in the system when you use multi-word attribute names. The problem is not general, on "plain" attributes you don't have this problem. On the one you try to use it... well, there you hit the wall. Simplest is to use a workaround - try to use one-word names. Can't promise a quick fix, I am swamped.... But you might be able to figure it out, is not that complicated, the file you need to check is the ps_product_custom_type.php.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Christopher on April 12, 2012, 18:23:25 pm
OK - thanks for the confirmation... I am also swamped with work, so I think I'll just use hyphens for the moment.

Again... A great hack - thank you!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Christopher on April 13, 2012, 12:03:33 pm
Hi WebGobe

OK - another little glitch I need to iron out...

Here's the code I'm using for the custom attribute:

Hire Period (radio)(Select a Hire Period|title-hover)(Daily [=27.50], Weekend [+6.88], Extra-Day [+11.00], Weekly [+27.50])

And here's a link to the product which is displaying the pricing options:

http://www.skiptonhirecentre.co.uk/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=111&category_id=36&option=com_virtuemart&Itemid=77

As you can see, although the code shows the first option as:

Daily [=27.50]

...the webpage shows '+£27.50' - this is confusing for the customer, especially with the full Weekly hire also showing '+£27.50'

Ideally, I want the "Daily" rate to show "=£27.50"

The only other way around the problem is to set the cost of the item as £0.00 and then to set each of the rates to +£27.50, +£34.38, +£38.50 and +£55.00 but the problem with this approach is that every product would then show a 'headline' price of £0.00 - unless there's a way of replacing the product price with the 'Daily' rate??

VM 1.1.9
J! 1.5.24

Any help or advice will be gratefully received

Many thanks

Christopher
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: carmineaep on April 13, 2012, 13:02:50 pm
Hello Gents!

Thanks to WebGobe I solved all my questions.

Now I'm asking all of you this:
the user come into the site, choose a product and then begin to customize it, through checkboxes, dropdown lists and input field.
The user now wants to save this configuration for further reference.

How I can arrange this? It's not saving the cart, because the user wants only to save the configuration of the custom attributes field, or better, he wants to save the whole form for maybe retrieving another time.

Anyone could give me any clue?

Thanks in advance!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 13, 2012, 14:37:12 pm
Christopher!
The entire CAE hack's core philosophy is built on ADDING various amounts to the base price. To implement something else, you need to hack deeper. I would hide simply the base price of the product in the flypage - easiest. But if you dig in the hacked files, you might be able to change the display too - but IMHO the flypage-trick is easiest - and safest - to implement.
carmineaep:
Humm, yea, it is a real challenge... sincerely, have no clue how to solve it. Anyway, one thing is sure no tricks based on saving the cat are working - the entire hack is incompatible with VirtueMart's savecart feature. More... parts of the trickery is working only based on actions of customer in a given session... for example Pizza attribute, or the Window attribute...
Need to think about, but if you can name the attributes you want to use in your setup, might be able to crop up something.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Christopher on April 13, 2012, 14:49:57 pm
Fair enough, WebGobe... I just thought it was odd that the code says [=27.50] and the website produces +£27.50 and wondered if there was a way to either ensure the '=' sign is reproduced or the first '+' sign isn't displayed - I appreciate that it's impossible to produce a hack that is all things to all people - what you have achieved is still outstanding.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 13, 2012, 16:38:06 pm
Yea.. Just FYI: the + is inserted by the core part of the VirtueMart - the core Custom Attributes functionality.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: malta on April 17, 2012, 02:50:19 am
I have two questions the first is that I could not download the file Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + 1.5?, Then tried to use the Custom Attributes Extended version 2.1, but it strikes me the following on the product detail page appears product with a value of 5.49 for example, and the code that the value is 5.00, so I do not understand why they do not sell a product with value appearing in the cart and another, another thing is not to use the radio with ckeckbox, can someone help me because searched all looking for a light and got nothing if you can answer I'm thankful
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 17, 2012, 09:11:35 am
1. From where you did tried to download it?
2. Clearly is a configuration problem. You have the default settings for taxes in place. Get rid of them.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: jimmyngf on April 18, 2012, 08:05:35 am
Hi,
 I am using VM1.1.9 and joomla 1.5

I have created a product and add this to custom attributes list: Donate (checkbox)(Who do you want to donate to?|title-hover)(Widows [+5.00], Orphans[+10.00], Test[+20.00]). Now in the cart the values get not sum up. It works only if one checkbox is selected, but not for multiple selection.

Can you help me please to fix it? thank you  :)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 18, 2012, 10:23:46 am
Version 3.0 has a problem with multiple selections, it's a known issue. Didn't had the time lately to find the bug and fix it. But the previous versions are working fine in this regard. And if you don't need the new attributes added (as I guess) you can safely use the previous one.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: jimmyngf on April 18, 2012, 15:17:15 pm
Version 3.0 has a problem with multiple selections, it's a known issue. Didn't had the time lately to find the bug and fix it. But the previous versions are working fine in this regard. And if you don't need the new attributes added (as I guess) you can safely use the previous one.

Hi, Webgobe

Let me know if you have time to fix this problem and i can pay extra time for you, and i know a lot people need same solution. thank you  :)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: Amokossi on April 24, 2012, 07:41:44 am
Hi.

What about Joomla 2.5.4 +VM 2.0.6. Will this work with this version?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on April 24, 2012, 09:29:05 am
No, at least not too soon.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: MasterDKLB on June 15, 2012, 00:41:19 am
Thank you for the nice hack :) Really works well. I have installed and was able to manage the attributes to display the way i want it.

I have 2 problems left. For background i am using VM1.1.9 and Joomla 1.5.24 and After i installed this hack (i changed the theme name in your zip file from default to my theme name) i am now getting a problem with the arrows next to the quantity box (the up and down arrows) only when i am in flypage.

The second problem is on the administrator side (backend), when i go to virtuemart administrator and choose configuration->site i am getting the following warning:

"
Warning: file_exists(): open_basedir restriction in effect. File(/customers/8/8/7/360itsolutions.dk/httpd.www/oasen/components/com_virtuemart/themes/.DS_Store/theme.php) is not within the allowed path(s): (/customers/_8/8/7/360itsolutions.dk/:/customers/8/8/7/360itsolutions.dk/httpd.www:/customers/8/8/7/360itsolutions.dk/httpd.private:/customers/8/8/7/360itsolutions.dk/tmp:/customers/360itsolutions.dk/360itsolutions.dk:/var/www/diagnostics:/usr/share/php) in /customers/8/8/7/360itsolutions.dk/httpd.www/oasen/administrator/components/com_virtuemart/classes/ps_html.php on line 514"

The right column on this side is getting so much wider due to this error and its not rendering correctly, this warning is displayed on the top of the theme selection block. I could still select my theme configuration.

I tried turning off AJAX with no luck to solve the problem.

Any ideas what could have gone wrong? I could of course restore the files but i really like the hack so i would rather fix this small problems instead, hopefully with your help.


Thank you in advance.


Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on June 15, 2012, 12:21:12 pm
These Open Basedir errors are the culprit - you have too restrictive settings on your server what can be loaded where... you need to eliminate that - probably by working with your hoster's technical staff - and the rest should work just fine.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: MasterDKLB on June 20, 2012, 10:02:29 am
Thank  you for the information webgobe. I have one question i am not able to figure out.

I have created a long list of attributes to use as checboxes for customers to choose extra toppings and different things on their food they want to order. The problem is that this list is so long and add to cart button is totally down. Is there a way to display these custom attributes in several columns instead of one long one?

Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on June 20, 2012, 10:23:23 am
Yes, can be done, but you need to hack the hack for that ;) in one of my previous messages I described, on how this can be done. Let me know, if you can't figure out. I'm on phone now, can't copy-paste code examples.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: MasterDKLB on June 20, 2012, 18:02:56 pm
I have tried but with no luck. I have found your entry in this post about that. I have tried the code right after your entry but didn't change anything. I have like 40 of those extras which have different prices, i have done them with your fantastic custom attributes hack to be checkboxes but would like to display them instead of long list in the table to be kind of a table with 5 x10 columns and rows.

I would be so grateful if someone have an idea on how to do that and can help me :)

Regards,
MasterDKLB
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: MasterDKLB on June 25, 2012, 00:35:00 am
Anyone who could help me with that? :(

I also have another problem when a customer checks an attribute (im using checkbox) the attribute appears in the cart and checkout showing the price twice.

For example if the customer selects a pizza and choose extra cheese for +1. it then displays the product price: 5 and below the attribute: extra cheese (+1.00)(+1£) which is confusing for the customer.

How to fix this issue?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: leorobles on June 25, 2012, 19:22:13 pm
Excuse my English, I am Brazilian, I'm having problems with the system checkbox on my site, but only in the browser Chrome, IE, Firefox and Opera is ok if you can give me a hint of what may be the problem.
http://atitudeti.no-ip.org:8080/redstar/peca-online.html?page=shop.product_details&flypage=flypage.tpl&product_id=59&category_id=2
Thank you. And congratulations for the work.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on June 25, 2012, 21:28:16 pm
Guys, give me couple of days to recover - I am having some medical problems right now. Ping me again towards the week's end, will try to answer your questions giving you some solutions too.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on July 05, 2012, 20:59:25 pm
I had such a problem with doubled prices in the cart. As I can see you shouldn't use the same name for two different attributes even if they are in different groups. Check if there are any similar and correct them.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on July 06, 2012, 19:43:30 pm
This is correct. There are exceptions - not all attributes are build in the same manner - but the safe way is to not use the same names.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: bardossi on July 08, 2012, 10:57:19 am
Hi,

I would like to add a new option to my product (which is a tax really), which is based on the product weight.

Here is an example (this online shop is for a printshop):
Flyer - 1250pcs, price is 13.000 HUF, the product weight is 2kg and I want to add 2 kg x 64 HUF =128 HUF additional cost to my product. This tax has a fix rate, which is 64 HUF/kg. Is it possible with this hack? Thanks in advance.


Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: smart123 on July 09, 2012, 11:53:34 am
Hello,

this is great hack Thanks for it but i have couple of problems.

1. The file upload doesn't rename the file rightly. It renames like date+file name so if another customer uploads the file with the same name and same day then it may overwrite
2. Can you please guide me how to link the file under order details with the file name customer uploaded?

please these are urgent issues I am sure u can help me

thanks again
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on July 09, 2012, 13:26:11 pm
bardossi: You need to add a new attribute to handle that. None of existing ones handles this as you need it.
smart123: Search for the "file" attribute's code in the ps_product_custom_type.php, and tweak it as you need. The observation is right, the code right now adds the current date to the filename to prevent dome of possible overwriting. Of course this is not the prefect solution... but is better, than nothing, and can be further developed!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: bardossi on July 09, 2012, 15:34:42 pm
webgobe: thank, I will send you a PM about it.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: smart123 on July 09, 2012, 19:58:32 pm
webgobe: thank, I will send you a PM about it.
bardossi: You need to add a new attribute to handle that. None of existing ones handles this as you need it.
smart123: Search for the "file" attribute's code in the ps_product_custom_type.php, and tweak it as you need. The observation is right, the code right now adds the current date to the filename to prevent dome of possible overwriting. Of course this is not the prefect solution... but is better, than nothing, and can be further developed!

Thanks alot for the reply. Can you please guide me how to link the uploaded file by the customer to the account order details? I am newbie and have no idea :(

Thanks
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on July 10, 2012, 12:13:49 pm
The filename should be allready there... let me check, will get back to you. (Can't remember, that part of hack was made long before I joined to the team.)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 19, 2012, 15:17:39 pm
A bug is found.
The Pervaz function doesn't work in my case. By the way not all users use Euro sign as a currency. Thus the calculation in the JS doesn't work properly.
This worked for me. In the ps_product_custom_type i found the code:
Code: [Select]
$html .= "<script type=\"text/javascript\">
function pervazprice()
{
var selectmenu=document.getElementById('".$titlevar."_field')
a=selectmenu.options[selectmenu.selectedIndex].text.indexOf('(+')
if(a>0){
b=selectmenu.options[selectmenu.selectedIndex].text.indexOf(')')
c=selectmenu.options[selectmenu.selectedIndex].text.substring(a+3,b)
e = selectmenu.options[selectmenu.selectedIndex].text.substring(0,a)
d = c*document.addtocart.wwidth.value/1000
selectmenu.options[selectmenu.selectedIndex].text=e+\" ( +\u20AC\" +d.toFixed(2)  +\")\"
selectmenu.options[selectmenu.selectedIndex].value=e+\" [+\" +d.toFixed(2)  +\"]\"
}
}
</script>"

and replaced with this:
Code: [Select]
$html .= "<script type=\"text/javascript\">
function pervazprice()
{
var selectmenu=document.getElementById('".$titlevar."_field');
a=selectmenu.options[selectmenu.selectedIndex].text.indexOf('(+');
if(a>0){
b=selectmenu.options[selectmenu.selectedIndex].text.indexOf(')');
c=selectmenu.options[selectmenu.selectedIndex].text.substring(a+2,b-2);
e = selectmenu.options[selectmenu.selectedIndex].text.substring(0,a);
d = c*document.addtocart.wwidth.value/1000;
selectmenu.options[selectmenu.selectedIndex].text=e+\" ( +\" +d.toFixed(2)  +\")\";
selectmenu.options[selectmenu.selectedIndex].value=e+\" [+\" +d.toFixed(2)  +\"]\";
}
}
</script>"

At least it's calculating something now.
The line: c=selectmenu.... should be modified according to the currency symbol(s) before or after the amount. In my case i have two symbols after (not before) amount ":-". So I put a+2 and b-2
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 20, 2012, 09:42:01 am
Good catch.
The "pervaz" function vas developed for a client form Belgium with some special needs... (that's for explanation)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: kenwong on August 20, 2012, 16:09:12 pm
I found this hack have encoding error when checkout...
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 20, 2012, 17:21:15 pm
It's not the hack's problem. If you read earlier posts in this thread you will find an explanation and a workaround.The guilty here is the way the cart content is encoded and stored by the core of VM 1.1
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: kenwong on August 20, 2012, 17:57:18 pm
It's not the hack's problem. If you read earlier posts in this thread you will find an explanation and a workaround.The guilty here is the way the cart content is encoded and stored by the core of VM 1.1

Thanks, you are the best!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 20, 2012, 19:11:09 pm
Sorry, it is in the older thread:
http://forum.virtuemart.net/index.php?topic=39666.0
 Namely here for example:
http://forum.virtuemart.net/index.php?topic=39666.msg348401#msg348401
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 23, 2012, 23:58:25 pm
Webgobe, I want to add some functionality to the hack, so I've made another class in the ps_product_custom_type.php file, and called it ps_product_custom_type_kanaler.
I copied the function customTypeSecureValue from the pervaz class.  Then in the customTypeProcess function I tried to pass the variable $adjusted_price's value on like this:      
Code: [Select]
                $pagevar = trim($field['attr_title']);
$charge[$pagevar][$value] = '[+'.$adjusted_price.']';
return $value;
But doesn't work.
In the cart i can only see the name of the attribute and after ":" is empty space...
How to fix it? Can you give a hint?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 24, 2012, 09:10:20 am
I should see the entire new class to see where the problem occurs. Obviously the value is not filled correctly, but I need the code - a bit more than these 3 lines - to see where the problem might be.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 24, 2012, 10:23:42 am
Here's my code:

Code: [Select]
class ps_product_custom_type_kanaler extends ps_product_custom_type_base {
var $classname = "ps_product_custom_type_kanaler";

    /**
* Outputs HTML for Custom Attribute
*/
function customTypeHTML($field=array()) {
global $mosConfig_live_site,$wwidth,$wheight;
    $html = "";
$titlevar = trim($field['attr_pagevar']);
$html .= "<script type=\"text/javascript\">
function channelsprice() {
val = \"\";
if(document.addtocart.".$field['attr_pagevar']."3.checked) val += \"Up\";
if(document.addtocart.".$field['attr_pagevar']."4.checked) val += \"+Down\";
if(document.addtocart.".$field['attr_pagevar']."5.checked) val += \"+Left\";
if(document.addtocart.".$field['attr_pagevar']."6.checked) val += \"+Right\";
document.addtocart.getElementById('kanaler1').value = val;
document.addtocart.getElementById('kanaler2').value = document.addtocart.wwidth.value;
document.addtocart.getElementById('kanaler3').value = document.addtocart.wheight.value;
}
</script>";

$html .= "<span >Sydda kanaler: </span></br>";
$html .= "<span class=\"inputbox\"><input type=\"checkbox\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field3\"  name=\"".$field['attr_pagevar']."3\" value=\"up\" onchange=\"channelsprice();\" /> </span>-Up</br>";
$html .= "<span class=\"inputbox\"><input type=\"checkbox\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field4\"  name=\"".$field['attr_pagevar']."4\" value=\"down\" onchange=\"channelsprice();\" /> </span>-Down</br>";
$html .= "<span class=\"inputbox\"><input type=\"checkbox\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field5\"  name=\"".$field['attr_pagevar']."5\" value=\"left\" onchange=\"channelsprice();\" /> </span>-Left</br>";
$html .= "<span class=\"inputbox\"><input type=\"checkbox\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field6\"  name=\"".$field['attr_pagevar']."6\" value=\"right\" onchange=\"channelsprice();\" /> </span>-Right</br>";
$html .= "<input id=\"kanaler1\" name=\"".$field['attr_pagevar']."[0]\" type=\"hidden\"  readonly=true />";
$html .= "<input id=\"kanaler2\" name=\"".$field['attr_pagevar']."[1]\" type=\"hidden\"  readonly=true value=\"100\" />";
$html .= "<input id=\"kanaler3\" name=\"".$field['attr_pagevar']."[2]\" type=\"hidden\"  readonly=true value=\"100\" />";

return $html;
}

/**
* Outputs Secure Value for Custom Attribute
*/
function customTypeSecureValue($field=array()) {
global $charge, $vmLogger;
$pagevar = trim($field['attr_title']);
$vm_charge = '';
if (is_array($charge[$pagevar])) {
foreach ($charge[$pagevar] as $value=>$price) {
if ($vm_charge) $vm_charge.=',';
$vm_charge .= $value.$charge[$pagevar][$value];

}
}
return $vm_charge;
}

/**
* Outputs & Processes the submitted data for Custom Attribute to Cart
*/
function customTypeProcess($value, $field=array()) {
global $charge, $vmLogger, $cwidth, $cheight;
$ch_kan = $value[0];
$ch_w = $value[1];
$ch_h = $value[2];
$chanvalues = explode("+",$ch_kan);
$channel_price_per_meter = 15;
$ch_price = 0;
$w = ceil($ch_w/100);
$h = ceil($ch_h/100);

foreach ($chanvalues as $side) {
if ($side == "Up") {
$ch_price += $w*$channel_price_per_meter;
}

if ($side == "Down") {
$ch_price += $w*$channel_price_per_meter;
}

if ($side == "Left") {
$ch_price += $h*$channel_price_per_meter;
}
if ($side == "Right") {
$ch_price += $h*$channel_price_per_meter;
}
}


$adjusted_price = $ch_price;
$pagevar = trim($field['attr_title']);
$charge[$pagevar][$value] = '[+'.$adjusted_price.']';
return $value;
}

}


   

May be it's a bad coding but i'm only what is written under my nickname.

The idea is to show four checkboxes which represent four sides of a given material (pvc banner in my case) which were chosen in the previous attribute "window" (also modified). Then if client checks one or several checkboxes, the code adds a price according to the length of that side rounded to meters.

This is the modified code for "windows" attribute:

Code: [Select]
class ps_product_custom_type_window extends ps_product_custom_type_base {
var $classname = "ps_product_custom_type_window";

    /**
* Outputs HTML for Custom Attribute
*/
function customTypeHTML($field=array()) {

global $mosConfig_absolute_path, $mosConfig_live_site, $VM_LANG;
$html = "";
$attr_value = explode('|',$field['attr_value']);
$default_width = $attr_value[0];
$default_height = $attr_value[1];
$max_width = $attr_value[2];
$max_height = $attr_value[3];
$price = $attr_value[4];
$chan_price = 15;
//$rolo_price = $attr_value[5];
//$rolo_xheight = $attr_value[6];
//$with_rolo = "*".$VM_LANG->_('PHPSHOP_WITH_ROLO');
$html .= "<script type=\"text/javascript\">
function totalprice()
{
if(document.addtocart.".$field['attr_pagevar']."1.value)
a = document.addtocart.".$field['attr_pagevar']."1.value
else
a = $default_width
if(document.addtocart.".$field['attr_pagevar']."2.value)
b = document.addtocart.".$field['attr_pagevar']."2.value
else
    b = $default_height

c = a+\"*\"+b
document.addtocart.".$field['attr_pagevar'].".value = c
document.addtocart.wwidth.value = a
document.addtocart.wheight.value = b

}
</script>";
if(!$field['attr_post_value']){
$html .= "Bredd: <span class=\"inputbox\"><input type=\"text\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field1\" size=\"5\" name=\"".$field['attr_pagevar']."1\"  value=\"".$default_width."\" onblur=\"totalprice();\" /> cm ". sprintf($VM_LANG->_('PHPSHOP_WIDTH_ALLOWED'),$default_width, $max_width)."</span><br />";
$html .= "Höjd: <span class=\"inputbox\"><input type=\"text\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field2\" size=\"5\" name=\"".$field['attr_pagevar']."2\" value=\"".$default_height."\" onblur=\"totalprice();\" /> cm ". sprintf($VM_LANG->_('PHPSHOP_HEIGTH_ALLOWED'),$default_height, $max_height)."</span><br />";
if($chan_price){
//$html .= $VM_LANG->_('PHPSHOP_ROLO',false)." <span class=\"inputbox\"><input type=\"checkbox\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field3\"  name=\"".$field['attr_pagevar']."3\" value=\"".$field['attr_post_value']."\"  onblur=\"totalprice();\" /> </span>";
}
$html .= "<input  name=\"".$field['attr_pagevar']."\" type=\"hidden\"  readonly=true />";
$html .= "<input  name=\"wwidth\" type=\"hidden\"   readonly=true />";
$html .= "<input  name=\"wheight\" type=\"hidden\"  readonly=true />";
} else {
$html .= "Bredd: <span class=\"inputbox\"><input type=\"text\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field1\" size=\"5\" name=\"".$field['attr_pagevar']."1\" value=\"".$field['attr_post_value']."\" /> cm</span><br />";
$html .= "Höjd: <span class=\"inputbox\"><input type=\"text\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field2\" size=\"5\" name=\"".$field['attr_pagevar']."2\" value=\"".$field['attr_post_value']."\" /> cm</span><br />";
if($chan_price){
//$html .= $VM_LANG->_('PHPSHOP_ROLO',false)." <span class=\"inputbox\"><input type=\"checkbox\" class=\"inputbox\" id=\"".$field['attr_pagevar']."_field3\"  name=\"".$field['attr_pagevar']."3\" value=\"".$field['attr_post_value']."\"  /> </span>";
}
$html .= "<input  name=\"".$field['attr_pagevar']."\" type=\"hidden\"  readonly=true />";
$html .= "<input  name=\"wwidth\" type=\"hidden\"  readonly=true />";
$html .= "<input  name=\"wheight\" type=\"hidden\"  readonly=true />";

}
return $html;
}

/**
* Outputs Secure Value for Custom Attribute
*/
function customTypeSecureValue($field=array()) {
global $charge,$vmLogger, $VM_LANG;
$attr_value = explode('|',$field['attr_value']);
$default_width = $attr_value[0];
$default_height = $attr_value[1];
$max_width = $attr_value[2];
$max_height = $attr_value[3];
$price = $attr_value[4];
//$rolo_price = $attr_value[5];
//$rolo_xheight = $attr_value[6];

if (!$price) {
return '';
} else {
  $pagevar = trim($field['attr_title']);
$vm_charge = '';
if (is_array($charge[$pagevar])) {
foreach ($charge[$pagevar] as $value=>$price) {
if ($vm_charge) $vm_charge.=',';
$vm_charge .= $value.$charge[$pagevar][$value];
}
}
// $vmLogger->err( $value." ".$pagevar." ".$vm_charge);
return $vm_charge;
}
}

/**
* Outputs & Processes the submitted data for Custom Attribute to Cart
*/
function customTypeProcess($value, $field=array()) {
global $charge,$vmLogger, $VM_LANG;
$attr_value = explode('|',$field['attr_value']);
$default_width = $attr_value[0];
$default_height = $attr_value[1];
$max_width = $attr_value[2];
$max_height = $attr_value[3];
$price = $attr_value[4];
$chan_price = 15;
//$rolo_price = $attr_value[5];
//$rolo_xheight = $attr_value[6];


$surface = explode('*',$value);

if (($surface[0] < $default_width) || ($surface[0] > $max_width))  {
$vmLogger->err( $VM_LANG->_(PHPSHOP_WIDTH_ERROR)." ".$surface);
return (false);
}
if (($surface[1] < $default_height) || ($surface[1] > $max_height)) {
$vmLogger->err( $VM_LANG->_(PHPSHOP_HEIGTH_ERROR)." ".$surface);
return (false);
}
$d_surface =($default_width*$default_height)/10000;
$b_surface =($surface[0]*$surface[1])/10000-$d_surface;
//$r_surface =($surface[0]*($surface[1]+$rolo_xheight))/10000;

if (!$price || !$value) {
return $value;
} else {
$adjusted_price = $price * $b_surface;

$pagevar = trim($field['attr_title']);
$charge[$pagevar][$value] = '[+'.$adjusted_price.']';
// $vmLogger->err( $value." ".$pagevar." ".$charge[$pagevar][$value] );
return $value;
}
}

}
 
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 24, 2012, 11:09:49 am
Aha, I see the logic. At first sight looks okay, but I need to play a bit with the code to see where it fails. Probably (hopefully) I will have some time over weekend for this.
What I would do in your place is that I would echo  or use the VM error mechnanism (you have examples for both in the code) to check, if the variables are set and calculates as they should.
Probably is something really minor... a typo maybe.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 24, 2012, 12:57:26 pm
Oh, I figured it out!
The $value in the output of the process function can't be an array. Only single. Now it's working!!!
Thanx Webgobe, you inspired me!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 24, 2012, 13:05:11 pm
Be welcome!  :-*
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 27, 2012, 22:23:38 pm
I've added some code. So now i can hide/show any attribute i need. For instance for some "advanced options" in your product that you don't want to show up upon page load, but as soon as you click "More options" (can be other text) you will see any additional attributes. It's not dependant on the type of the attributes, you only put the start and the end attributes, and everything between them will be hidden. I think it's a good alternative to the group attributes. I can share if somebody's interested.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 28, 2012, 08:07:28 am
I am ;)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 28, 2012, 08:26:38 am
Just add these two classes to the ps_product_custom_type.php file.

Code: [Select]
/***************************************************
 *
 * Advoptions element class
 * The class is is used to manage the product custom attribute type.
 *
***************************************************/
class ps_product_custom_type_advoptions extends ps_product_custom_type_base {
var $classname = "ps_product_custom_type_advoptions";

    /**
* Outputs HTML for Custom Attribute
*/
function customTypeHTML($field=array()) {
    $attr_value = explode('|',$field['attr_value']);
$opt_id = $attr_value[0];
$opt_name = $attr_value[1];
//$opt_items = $attr_value[2];
$html = "";
if( ($field['attr_tip_position'] == 'title-hover') && ($field['attr_tip']) ){

//$mainframe->addCustomHeadTag( '<script type="text/javascript" src="'. $mosConfig_live_site . '/includes/js/overlib_mini.js"></script>' );
$html .= "<br/><div style='text-align: center' id=\"".$opt_id."\" onclick=\"hide_or_show();\" class=\"tip\" onMouseOver=\"change_cursor(); return overlib('".trim($field['attr_tip'])."',CAPTION, '".$opt_name."', BELOW, RIGHT);\" onmouseout=\"restore_cursor(); return nd();\" ><b>______________<font color='red' face='Arial'>↓_".$opt_name."_↓</font>______________</b></div><br/><br/>";
} else {
$html .= "<br/><div style='text-align: center' id=\"".$opt_id."\" onMouseOver=\"change_cursor();\" onmouseout=\"restore_cursor();\" onclick=\"hide_or_show();\"><b>______________<font color='red' face='Arial'>↓_".$opt_name."_↓</font>______________</b></div><br/><br/>";
}
$html .= "
<script type=\"text/javascript\">
function change_cursor() {
document.getElementById('".$opt_id."').style.cursor = 'pointer';
}
function restore_cursor() {
document.getElementById('".$opt_id."').style.cursor = 'default';
}
var hos = 0;
function hide() {

alldivs = document.getElementsByTagName('div');
var start = 0;
for(var i=0; i<alldivs.length; i++){
if (start == 1){
alldivs[i].style.display = 'none';
}
if (alldivs[i].id == \"".$opt_id."\") start = 1;
if (alldivs[i].id == \"".$opt_id."_end\") start = 0;
}
hos = 1;
}
function show() {
alldivs = document.getElementsByTagName('div');
var start = 0;
for(var i=0; i<alldivs.length; i++){
if (start == 1){

alldivs[i].style.display = 'block';
}
if (alldivs[i].id == \"".$opt_id."\") start = 1;
if (alldivs[i].id == \"".$opt_id."_end\") start = 0;
}
hos = 0;
}
function hide_or_show(){
if (hos == 1) {
show();  return;
}

if (hos == 0) {
hide();  return;
}
}




";

$html .= "</script>";
return $html;
}

/**
* Outputs Secure Value for Custom Attribute
*/
function customTypeSecureValue($field=array()) {
return '';
}

/**
* Outputs & Processes the submitted data for Custom Attribute to Cart
*/
function customTypeProcess($value, $field=array()) {
return '';
}

}

/***************************************************
 *
 * Advoptionsend element class
 * The class is is used to manage the product custom attribute type.
 *
***************************************************/
class ps_product_custom_type_advoptionsend extends ps_product_custom_type_base {
var $classname = "ps_product_custom_type_advoptionsend";

    /**
* Outputs HTML for Custom Attribute
*/
function customTypeHTML($field=array()) {
    $attr_value = $field['attr_value'];
$opt_id = $attr_value;
$html = "";
$html .= "<div id=\"".$opt_id."_end\"></div>";
$html .= "
<script type=\"text/javascript\">
hide_or_show();
</script>";
return $html;
}

/**
* Outputs Secure Value for Custom Attribute
*/
function customTypeSecureValue($field=array()) {
return '';
}

/**
* Outputs & Processes the submitted data for Custom Attribute to Cart
*/
function customTypeProcess($value, $field=array()) {
return '';
}

}
 

Now to make it working, put a "advoptions" attribute on the product page, the syntax is very simple:
(advoptions)(some very nice tip | location)(ID , title);
ID should start with a letter and may have (a-z, A-Z, 0-9, -, _) it must be unique (try to make up something sophisicated), title - is what visitors will see.
Then put any number of attributes after this one.
Afterwards, make the closing attribute as follows:
(advoptionsend)(|)(ID)
The ID should be the same as in the beginning attribute (i.e. advoptions). It's important, otherwize it will hide half of your page.
That's it.
You can, of course, customize the appearance and color of the title in the code.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 28, 2012, 11:44:14 am
thanks!
If you agree, I will add it to the "official" hack  ;)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 28, 2012, 12:01:57 pm
Yes, let it be useful to all.
By the way i have customized the hack even more to meet my needs (banner printing company).  For example i added a possibility of having the edges of a surace be sewed around or not so the code will take in account the given perimeter and the sides chosen and will add a corresponding price to the banner's surface previously calculated. You can see the hack in action on this page  (http://www.banderollkungen.se/layout.html?page=shop.product_details&flypage=flypage2rollup.tpl&product_id=1&category_id=1). Sorry, in Swedish. There you can see standard options and if you hit "Mer alternativ", you wil see the rest of the options. "Sydda kanaler"represents four sides of the banner (up,down,left,right). The "Keder" option is almost the same but only with upper and lower sides. It's quite a specific hack, so i'll leave it to your advice.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on August 28, 2012, 12:15:21 pm
Aha, I have something similar for the Surface (or the windowshield??) attribute allready in plance. Indeed, is very specific, might not be needed to be included in the mainstream.
OK, will put together anyway a new version - with couple of minor bugfixes, etc, and will publish it!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on August 28, 2012, 12:52:56 pm
And you may probably want to change the way the hack behaves when a hovered title with a tip "title-hover" is accidentally clicked (it leads to the homepage on my site).
You can put some div  instead in the file ps_product_custom_attribute.php:

this:
Code: [Select]
$html .= "<div class=\"tip\" onMouseOver=\"return overlib('".trim($field['attr_tip'])."',CAPTION, '".trim($field['attr_title'])."', BELOW, RIGHT);\" onmouseout=\"return nd();\" ><label for=\"".trim($field['attr_pagevar'])."_field\">".trim($field['attr_title'])."</label>:</div>";
instead of this:
Code: [Select]
$html .= "<a href=\"\" class=\"tip\" onMouseOver=\"return overlib('".trim($field['attr_tip'])."',CAPTION, '".trim($field['attr_title'])."', BELOW, RIGHT);\" onmouseout=\"return nd();\" ><label for=\"".trim($field['attr_pagevar'])."_field\">".trim($field['attr_title'])."</label>:</a>";
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on September 08, 2012, 23:24:20 pm
Some  clients can't wait untill a file upload finishes they just can't determine whether the site is working or something went wrong, especially when file is quite big. All they see is their browser's spinner showing them that the page is about to load in uncertain time.
I managed to implement a simple upload spinner near the file upload input field. You can watch it's work in here:
http://www.banderollkungen.se/layout.html?page=shop.product_details&flypage=flypage2rollup.tpl&product_id=1&category_id=1
It will turn on if you've chosen a file and clicked "Add to Cart" button.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crisware on September 28, 2012, 18:54:15 pm
Hello and congrats for this extremely useful hack! Where can I find the last version of this hack?

Thank you!
Regards
Christopher
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on September 28, 2012, 21:15:11 pm
Link in the first post of the thread or on my homepage.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crisware on September 29, 2012, 01:02:43 am
Thank you!!! :)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crisware on October 04, 2012, 02:39:50 am
Hello again,

I just installed VM 1.1.9 on Joomla 1.5.25 and replaced files with yours for Custom Attributes features!
It is really such a nice extension!
Although I have a problem. If I set an attribute as checkbox and more than one values have price difference (e.g. -> Select Values (checkbox)(test1|test1)(value1 [+0.20], value2 [+0.40]); ) and more than one values are checked by customer, it is not calculates at all attribute prices and they are not summarized on the final price.

What have I done wrong?

Thank you!

Regards,
Christopher
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on October 04, 2012, 09:17:54 am
Nothing. In fact is a bug around since VM 1.1.3 and I has planned to smash it - is on my shortlist. Just too many to solve and too little time...
I suggest you a workaround: use 2 separate checkboxes, that works. As I will have time, I will fix that annoying bug... but can't promise a deadline. Joomla 1.5 and VM 1.* are fading out, and I am pretty overwhelmed with tasks.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crisware on October 04, 2012, 13:22:29 pm
I like Virtuemart 1.1 and Joomla 1.5 and I use them for years. Although I tried to upgrade to VM 2 but also it is not include multiple choice custom fields (checkboxes or multilists). I am very disappointed with that and I cannot understand why they don't include that feature in their script. Many people need it but unfortunately nobody from VM developers seems to mind...

Anyway!

Thank you for your help!

Since last year I use your extension in older versions of VM and I REALLY love it!!!!!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on October 04, 2012, 13:39:49 pm
I also still use Joomla 1.5 EXCLUSIVELY because VM 1.9 runs uder that  - so I know your feelings :)
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crisware on October 04, 2012, 14:28:21 pm
BTW I think I have found the BUG and I Fixed it...

in ps_product.php you must change this (line about 1914):

Code: [Select]
for($i=0; $i < sizeof($attribute_keys); $i++ ) {
$temp_desc = $attribute_keys[$i];

$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );
$this_value = addslashes( $this_value ); // since advanced attribute values are saved quote-escaped in db, we should give a similar string

if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}
               
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];

// if we have a number, allow the adjustment
if (true == is_numeric($modifier) ) {
                   
// Now add or sub the modifier on
if ($operand=="+") {
$adjustment += $modifier;
}
else if ($operand=="-") {
$adjustment -= $modifier;
}
else if ($operand=='=') {
// NOTE: the +=, so if we have 2 sets they get added
// this could be moded to say, if we have a set_price, then
// calc the diff from the base price and start from there if we encounter
// another set price... just a thought.

$setprice += $modifier;
$set_price = true;
}
}
} else {
continue;
}
}
}

to this:

Code: [Select]
for($i=0; $i < sizeof($attribute_keys); $i++ ) {
$temp_desc = $attribute_keys[$i];

$temp_desc_keys = explode( ",", $temp_desc );
foreach ($temp_desc_keys as $temp_desc){

$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
if(strpos($temp_desc, ":")){
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );
} else {
    $this_key = $this_key;
$this_value = $temp_desc;
}

if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}
               
$this_value=str_replace("_"," ",$this_value);
if( !isset( $product_attributes[$this_key]['values'][$this_value] )) {
$this_true_value = $this_value;
$this_value = 'vm_charge';
}
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];
if($this_value == 'vm_charge'){
$this_value = this_true_value;
}
// if we have a number, allow the adjustment
if (true == is_numeric($modifier) ) {
                   
$modifier = $GLOBALS['CURRENCY']->convert( $modifier, $price['product_currency'], $GLOBALS['product_currency'] );
// Now add or sub the modifier on
if ($operand=="+") {
$adjustment += $modifier;
}
else if ($operand=="-") {
$adjustment -= $modifier;
}
else if ($operand=='=') {
// NOTE: the +=, so if we have 2 sets they get added
// this could be moded to say, if we have a set_price, then
// calc the diff from the base price and start from there if we encounter
// another set price... just a thought.

$setprice += $modifier;
$set_price = true;
}
}
} else {
continue;
}
}
}
}


and this (line about 2111):

Code: [Select]
foreach( $attribute_keys as $temp_desc ) {
$finish = strpos($temp_desc,"]");
$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );

if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}
           
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];

$value_notax = $GLOBALS['CURRENCY']->convert( $modifier, $product_currency );
if( abs($value_notax) >0 ) {
$value_taxed = $value_notax * ($my_taxrate+1);
/* modified by JK for fixing incorrect values matching
$temp_desc_new  = str_replace( $operand.$modifier, $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ), $temp_desc );
                    $description = str_replace( $this_key.':'.$this_value,
$this_key.':'.$this_value.' ('.$operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')',
$description); */
        $temp_desc_new  = str_replace( $this_value, $this_value . ' (' . $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')', $temp_desc );
$description = str_replace( $temp_desc, $temp_desc_new, $description);

}
//$temp_desc = substr($temp_desc, $finish+1);
}

}


to this:

Code: [Select]

foreach( $attribute_keys as $temp_desc ) {
$temp_desc_keys = explode( ",", $temp_desc );
foreach ($temp_desc_keys as $temp_desc){
$finish = strpos($temp_desc,"]");
$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
if(strpos($temp_desc, ":")){
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );
} else {
//$temp_desc .= $this_key.':'.$temp_desc;
$this_key = $this_key;
$this_value = $temp_desc;
}
if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}

            $this_value = str_replace("_"," ",$this_value);
if( !isset( $product_attributes[$this_key]['values'][$this_value] )) {
$this_true_value = $this_value;
$this_value = 'vm_charge';
}
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];
if($this_value == 'vm_charge'){
$this_value = $this_true_value;
}
$value_notax = $modifier;
if( abs($value_notax) >0 ) {
$value_taxed = $value_notax * ($my_taxrate+1);
// modified by JK for fixing incorrect values matching
// $temp_desc_new  = str_replace( $operand.$modifier, $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ), $temp_desc );
// $description = str_replace( $this_value,
// $this_value.' ('.$operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')',
// $description);

$temp_desc_new  = str_replace( $this_value, $this_value . ' (' . $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')', $temp_desc );
$description = str_replace( $temp_desc, $temp_desc_new, $description);
}
//$temp_desc = substr($temp_desc, $finish+1);
}
}
}



Also I removed this (line 2910) as it had problems:

Code: [Select]
// Check if there is an extended class in the Themes and if it is allowed to use them
// If the class is called outside Virtuemart, we have to make sure to load the settings
// Thomas Kahl - Feb. 2009
if (!defined('VM_ALLOW_EXTENDED_CLASSES') && file_exists(dirname(__FILE__).'/../virtuemart.cfg.php')) {
include_once(dirname(__FILE__).'/../virtuemart.cfg.php');
}
// If settings are loaded, extended Classes are allowed and the class exisits...
if (defined('VM_ALLOW_EXTENDED_CLASSES') && defined('VM_THEMEPATH') && VM_ALLOW_EXTENDED_CLASSES && file_exists(VM_THEMEPATH.'user_class/'.basename(__FILE__))) {
// Load the theme-user_class as extended
include_once(VM_THEMEPATH.'user_class/'.basename(__FILE__));
} else {
// Otherwise we have to use the original classname to extend the core-class
class ps_product extends vm_ps_product {}
}
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: PolishedGeek on October 04, 2012, 15:46:06 pm
For those who need more advanced custom fields and attributes for VM2, you might want to look into integrating a custom designed form in your products to handle complex attributes and dependent options. We're still accepting interested beta testers who have good use cases for this type of functionality -  http://forum.virtuemart.net/index.php?topic=107973.msg362481#msg362481
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on October 04, 2012, 16:40:57 pm
@crisware: will test it, and eventually include it in the pack. Thanks!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: flaszlo on October 19, 2012, 13:42:28 pm
Hi,

I need some help about CAE.

I found a strange behaviour: right after I add a product to the cart it uses good prices (sum of all options price), but after a refresh it loses its prices, and it calculates just with the base price.

After several hours we found that the $_SESSION['cart']['extra_charge'] loses its values somehow. Do you have any idea to find a solution?

Best regards,

Cheers,

Laszlo
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on October 19, 2012, 16:19:59 pm
If that is indeed what you are loosing, then this is not a CAE specific problem. CAE just piggybacks on the existing custom attributes mechanisms built in the VM core, extending it's usefulness. Ne new variable storage or handling techniques are used. So it's probably something with your concrete setup, not the hack itself. But I am curious to see your site and to find and eventually fix the bug.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on October 20, 2012, 21:53:51 pm
Hi Webgobe,
What would you suggest if I wish to find a way to affect the weight of a selected product according to the area (and some other options) selected? I need it for the shipping module to calculate the shipping-price correctly. Maybe to create some new global variable to pass it to a special shipping module which will handle it?... Or i can use the standard shipping module and only pass a temporarily changed weight variable to it???.
What would you do?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on October 22, 2012, 10:26:48 am
I would try to overwrite the weight in the cart. Sounds the simplest way to do it, and I think can be done relatively easily by extending the hack a bit.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: leorobles on October 25, 2012, 23:47:58 pm
You always helped me and now it's time to help you, have you seen this? VM 1.2 (VM 1.1.9 is for Joomla 2.5)
The link is below:
http://joomlacode.org/gf/project/vm11j25/frs/
The latest version of your hack is CAE9.zip?
Hugs and thanks.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on December 22, 2012, 16:46:59 pm
One more question. Can i make the attribute description in the cart to be in several lines, i.e. use a <br/> tag? So that it would be like that:

Item name
Attribute:
Description line1
Description line2
Description line3
Description line....
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on December 22, 2012, 17:22:55 pm
Good question. Short answer: maybe. Longer one - better avoid to place there any kind of code - even HTML code, since the attributes are handled by the VM cart code, it's dangerous attempt. After Xmas I might have the time to look for a possible (and foolproof) solution for you, but I am not sure that can be easily done.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on January 29, 2013, 14:27:44 pm
What file is responsible for the tip text of attributes? I want to implement some layout in there. Can I?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on January 29, 2013, 14:37:23 pm
It is in  one of core VM files - can't remember right now, as I arrive home, will check it for you.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on January 29, 2013, 17:07:38 pm
function customAttributeHTML from ps_product_custom_attribute.php, is inherited from core ps_product_attribute.php
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crywolf on February 06, 2013, 23:57:02 pm
hallo, how would you make a browse_page so? http://opladen.pizzafreunde.de/index.php?option=com_content&view=article&id=1&Itemid=1&reload_done=true (http://opladen.pizzafreunde.de/index.php?option=com_content&view=article&id=1&Itemid=1&reload_done=true)

click on price to open a window with the custom attributes!
thanks
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: timkolm on February 07, 2013, 06:39:14 am
function customAttributeHTML from ps_product_custom_attribute.php, is inherited from core ps_product_attribute.php
Yes, this file is responsible for showing tips. But I saw that tips are already detached from any html tags, so it's some file that responsible for packing the tips into the database. Do you know what it is?
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 07, 2013, 17:43:04 pm
@timkolm: CAE is piggybacking on core VirtueMart Custom Attribute, the data is stored along with other product data using standard functions. And yes, all HTML is wiped out. I generally use a workaround, I have aslightly modified file letting me to use a new "tip" location attibute - a number. And this has the side effect of generating a RokBox popup window with and atricel - the number is that articles ID. This way you can add nearly anything as tip. Here is a live variant:
http://server-elcadia.com/denes/DBR/index.php?page=shop.product_details&flypage=flypage_images.tpl&product_id=6&category_id=1&option=com_virtuemart&Itemid=2
You need to log in, use test/test
Then click on the Start Rental process under the Availability date calendars, to enter the product details. Here click on Adult Lifejackets to see the trick in action.
The solution is not GPL, is result of a commercial assignment.
@crywolf:  You have everything handy in the CAE pack ;) Custom attributes are listed in a <div> - another custom attribute, and the template is a bit tweaked to add a link to the price wich triggers a 2 line little havascript wich shows/hides the div.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crywolf on February 10, 2013, 13:05:10 pm
@ webgobe
Thanks a lot for the answer, but they are still inexperienced I did not succeed

update
I think the link to the price I have succeeded but I can not make out the window with the custom attribute

<div class="browseProductContainer">
       
       
        <h3 class="browseProductTitle"><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>">
            <?php echo $product_name ?></a>
        </h3>
       
        <div class="browsePriceContainer">
           <a href="<?php echo $product_flypage ?>"><?php echo $product_price ?></a>
            <div style="float:left;width:60%"><?php echo $product_s_desc ?><br />
        </div>
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 12, 2013, 09:09:22 am
You need to import the cart functions into the category browsepage. CAE need them, the entire hack relies on cart related functionality. by default in the category browsepage the needed functions aren't used. A bit tricky, but can be done.
First of all, you need to change some settings, like Virtuemart --> Configuration --> Site > Layout > Configuration > Show the Add-to-cart-button on the product list is set to YES, - this enables the use of a simple add-to-cart button on category browsepage, but this is crucial, then you need to import couple of needed libraries. I never did this to the end myself, but I saw some posts around here in the forum.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crywolf on February 20, 2013, 20:06:28 pm
@Webgobe :)
Sorry to bother  you-it is possible that in the browse page by clicking on the product detail to open a popup or lightbox containing the flypage or better yet, only the custom-attribute, but every time we have to go in the flypage and then go back into the browse-page to continue with the order? thank you very much!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on February 20, 2013, 20:36:36 pm
Probably can be done. But that's a hard work... and I don't really have free "slots" these days... Opening the flypage is the easier way to do it. As I allready pointed out, the entire Custom Attribute Hack works INSIDE of the ADD TO CART code... So for an easy solution (relatively easy, I mean) you need to reuse the entire context where the hack works.
Popup of flipage is the way to go.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crywolf on March 27, 2013, 15:27:47 pm
@webgobe
 hi I have a problem with the display of products with custom attributes in google chrome (Ie and Firefox ist ok) you have an idea how to solve?
example:  http://doncamillo-freisenbruch.de/index.php?page=shop.product_details&flypage=flypage_new.tpl&category_id=1&product_id=17&option=com_virtuemart&Itemid=3 (http://doncamillo-freisenbruch.de/index.php?page=shop.product_details&flypage=flypage_new.tpl&category_id=1&product_id=17&option=com_virtuemart&Itemid=3)
thank you very much!
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: webgobe on March 27, 2013, 17:06:14 pm
It is a CSS problem in your template. For some reason the size of the div holding the cart is mis-interpreted by Chrome.
Title: Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
Post by: crywolf on March 29, 2013, 10:56:17 am
Thanks for the reply Webgobe!
I attach the template css template in use and the default theme css template in the hope that you have time to check them!
again thank you very much!

[attachment cleanup by admin]