VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: renegadesk on January 14, 2012, 01:40:10 AM

Title: Custom Field Type drop down not adding to product [Fix included]
Post by: renegadesk on January 14, 2012, 01:40:10 AM
Joomla: 1.7.3
VM: 2.0
Jomsocial: 2.4.1
Fresh install on WAMP. Only thing installed is Virtuemart, Virtuemart AIO and Jomsocial. Everything else is left as default.

I'm having an issue with the custom fields on a product page within Virtuemart. When I click the drop down, the custom fields that I have created appear in the dropdown but when I click on them it does nothing. If I look within firebug I can see that the JSON data that's coming back from the GET request is malformed as per the attached image. Looks like some data is being added to the end of the JSON data.

Other things I have noticed:

Any help would be very much appreciated. I really want to use the new VM but I have to get it working with Jomsocial.

Thanks

[attachment cleanup by admin]
Title: Re: Custom Field Type drop down not adding to product
Post by: morktron on January 16, 2012, 03:28:04 AM
Hi Renegadesk, well done! it looks like you've narrowed down the issue that other JomSocial users are reporting. (http://forum.virtuemart.net/index.php?topic=95180.0)

It would be great if one of the VM 2.0 developers could tell us where the offending code is and offer a possible solution that doesn't involve any core hacks.
Title: Re: Custom Field Type drop down not adding to product
Post by: renegadesk on January 24, 2012, 01:32:14 AM
OK I've got it fixed, but I'm not sure if the fix will break other stuff. If someone could help refine the code that would be awesome, especially if this can be turned in to a plugin or something so it's not messing with the core of Jomsocial.

File: /plugins/system/azrul.system/pc_includes/ajax.php
Issue: Couldn't save custom fields within Virtuemart. Some extra script text was being added to the JSON request.
Resolution: Check if on a current Virtuemart page. If it is, do not run the rest of the PHP. If not, then go ahead. Don't know if it was done right but it works.
Notes: This looks like it is within the HTTPS calls so no doubt it will have more of an affect if this is turned on.
Find this code:
//fix the uri if languagefilter plugin is enabled in J1.6
if($siteType=='1.6'){
$reqURI = $this->_fixLangSwitcher($reqURI);
}
$tokenStr = JUtility::getToken();
$html =
"<script type='text/javascript'>
/*<![CDATA[*/
var jax_live_site = '$reqURI';
var jax_site_type = '$siteType';
var jax_token_var='$tokenStr';
/*]]>*/
</script>";
$html .= "<script type=\"text/javascript\" src=\"$this->_livePath/ajax_" . AZRUL_SYSTEM . ".pack.js\"></script>\n";
return $this->_fixHTTPS($html);


And replace with this code (with or without comments as you like):


// START edited by sk
// 2012 24 01
// JSON Malformed data within VM
if(JRequest::getVar("option",false)=="com_virtuemart"){
return;
} else {
//fix the uri if languagefilter plugin is enabled in J1.6
if($siteType=='1.6'){
$reqURI = $this->_fixLangSwitcher($reqURI);
}
$tokenStr = JUtility::getToken();
$html =
"<script type='text/javascript'>
/*<![CDATA[*/
var jax_live_site = '$reqURI';
var jax_site_type = '$siteType';
var jax_token_var='$tokenStr';
/*]]>*/
</script>";
$html .= "<script type=\"text/javascript\" src=\"$this->_livePath/ajax_" . AZRUL_SYSTEM . ".pack.js\"></script>\n";
return $this->_fixHTTPS($html);
}
// End edited by sk



[attachment cleanup by admin]
Title: Re: Custom Field Type drop down not adding to product
Post by: DaggaTora on March 06, 2012, 11:14:55 AM
OH MAN YOUR ARE A GENIUS!!!!

:)  ;)  :D  ;D

I was cray during weeks because of this problem!! I couldn't imagine it was jomsocial!


Thanks!!!!
Title: Re: Custom Field Type drop down not adding to product
Post by: renegadesk on March 06, 2012, 22:20:54 PM
Stoked to know it worked for someone else, cheers for letting me know DaggaTora!
Title: Re: Custom Field Type drop down not adding to product
Post by: Infule on March 08, 2012, 19:39:37 PM
Way to go! This worked perfectly, thanks!
Title: Re: Custom Field Type drop down not adding to product
Post by: renegadesk on March 11, 2012, 10:15:57 AM
No worries noelj07! that's great that it's worked for you.
Title: Re: Custom Field Type drop down not adding to product [Fix included]
Post by: cheops on March 22, 2012, 14:48:49 PM
Damn... it kills my admin site with this message:

Parse error: syntax error, unexpected $end in /var/www/my-website.coom/public_html/plugins/system/azrul.system/pc_includes/ajax.php on line 580

:'(

I have the same error on this config:

(running J2.5.3, jomsocial, 2.6_Strike_Beta_3, WM  2.0.2)

any idears..?
Title: Re: Custom Field Type drop down not adding to product [Fix included]
Post by: renegadesk on March 22, 2012, 23:50:36 PM
Hey Cheops, double check to make sure your code is exactly how I've done it as the unexpected $end would mean that something is out of place.

Can you do a screenshot of your code with line numbers?
Title: Re: Custom Field Type drop down not adding to product [Fix included]
Post by: cheops on March 23, 2012, 08:25:37 AM
sorry my mistake.. I missed a snip of your code.. it works like a charm now... THANKS A MILLION for your reply :-)
Title: Re: Custom Field Type drop down not adding to product [Fix included]
Post by: renegadesk on March 23, 2012, 09:08:20 AM
No probs buddy!
Title: Re: Custom Field Type drop down not adding to product [Fix included]
Post by: mountain91074 on May 19, 2012, 01:23:24 AM
Super Solution!
Thank you very much!
Title: Re: Custom Field Type drop down not adding to product [Fix included]
Post by: jthrongard on March 01, 2013, 18:58:52 PM
Thanks a million poster.  This would have seriously put the kibosh on my project if not for this.  Now who's plugin is this?  What updating will screw this up? 
Title: Re: Custom Field Type drop down not adding to product [Fix included]
Post by: Milbo on March 01, 2013, 20:40:40 PM
Nice, thank you for this post. We had also some customers having this problem. We also wrote to joomsocial, no response.