Author Topic: Custom Field Type drop down not adding to product [Fix included]  (Read 6977 times)

renegadesk

  • Beginner
  • *
  • Posts: 13
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

  • Jr. Member
  • **
  • Posts: 120
    • digital solutions for sentient bipeds
Re: Custom Field Type drop down not adding to product
« Reply #1 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.

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

  • Beginner
  • *
  • Posts: 13
Re: Custom Field Type drop down not adding to product
« Reply #2 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:
Code: [Select]
//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):

Code: [Select]
// 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

  • Jr. Member
  • **
  • Posts: 253
Re: Custom Field Type drop down not adding to product
« Reply #3 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!!!!
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

renegadesk

  • Beginner
  • *
  • Posts: 13
Re: Custom Field Type drop down not adding to product
« Reply #4 on: March 06, 2012, 22:20:54 pm »
Stoked to know it worked for someone else, cheers for letting me know DaggaTora!

Infule

  • Beginner
  • *
  • Posts: 7
    • Fort Collins Web Design
Re: Custom Field Type drop down not adding to product
« Reply #5 on: March 08, 2012, 19:39:37 pm »
Way to go! This worked perfectly, thanks!

renegadesk

  • Beginner
  • *
  • Posts: 13
Re: Custom Field Type drop down not adding to product
« Reply #6 on: March 11, 2012, 10:15:57 am »
No worries noelj07! that's great that it's worked for you.

cheops

  • Beginner
  • *
  • Posts: 3
Re: Custom Field Type drop down not adding to product [Fix included]
« Reply #7 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..?

renegadesk

  • Beginner
  • *
  • Posts: 13
Re: Custom Field Type drop down not adding to product [Fix included]
« Reply #8 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?

cheops

  • Beginner
  • *
  • Posts: 3
Re: Custom Field Type drop down not adding to product [Fix included]
« Reply #9 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 :-)

renegadesk

  • Beginner
  • *
  • Posts: 13
Re: Custom Field Type drop down not adding to product [Fix included]
« Reply #10 on: March 23, 2012, 09:08:20 am »
No probs buddy!

mountain91074

  • Beginner
  • *
  • Posts: 1
Re: Custom Field Type drop down not adding to product [Fix included]
« Reply #11 on: May 19, 2012, 01:23:24 am »
Super Solution!
Thank you very much!

jthrongard

  • Beginner
  • *
  • Posts: 30
    • Simple CMS Design
Re: Custom Field Type drop down not adding to product [Fix included]
« Reply #12 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? 
Small Business Joomla! Website Design - Simple CMS Design
http://www.simplecmsdesign.com

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9943
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Custom Field Type drop down not adding to product [Fix included]
« Reply #13 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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/