Custom Field Type drop down not adding to product [Fix included]

Started by renegadesk, January 14, 2012, 01:40:10 AM

Previous topic - Next topic

renegadesk

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:

  • If I remove the /administrator/com_community folder and refresh the page I can add custom fields (but rest of the site is effed)
  • I'm not sure if this is worth mentioning but the extra bit of data at the end of the JSON request (image attached) is within the HEAD section of every page of the website. Frontend and backend.
  • It all was working fine before installing Jomsocial

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]

morktron

Hi Renegadesk, well done! it looks like you've narrowed down the issue that other JomSocial users are reporting.

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.

renegadesk

#2
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]

DaggaTora

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!!!!
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

renegadesk

Stoked to know it worked for someone else, cheers for letting me know DaggaTora!

Infule


renegadesk

No worries noelj07! that's great that it's worked for you.

cheops

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..?

renegadesk

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?

cheops

sorry my mistake.. I missed a snip of your code.. it works like a charm now... THANKS A MILLION for your reply :-)



jthrongard

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? 
Small Business Joomla! Website Design - Simple CMS Design
http://www.simplecmsdesign.com

Milbo

Nice, thank you for this post. We had also some customers having this problem. We also wrote to joomsocial, no response.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/