Forums

form for virtuemart

creezi 30 Mar, 2011
I posted earlier about this issue, but now I have learned so much more, which makes it a different problem.

I use Chronoforms with Virtuemart and Bixie module. Everything works fine, except one thing.

When someone places a order, the form data is stored as a parameter in VM with a form-id. This form-id, with the data from the form, is stored in a table from bixie.
With the form-id as parameter, the data is printed in the order confirmation.

But when someone places a order, this form-id data (from the chronoforms form) is also in the cache of joomla (eventhough caching is off). So the next user gets the data (form-id) from the previous user, untill I clear the cache of joomla.

Did anyone have problems with formdata being stored in cache?
Does anyone have an idea on how to fix this?
GreyHead 30 Mar, 2011
Hi creezi,

I'm finding it very difficult to understand where and how this data is being stored. The Joomla! cache is off, ChronoForms doesn't cache anything. Is this something that is resulting from Bixie or VirtueMart?

Bob
creezi 30 Mar, 2011
Hi Bob,
Thanks for your reply. I think it has to do with the bixie module. I don't understand it at all.
I have been looking at this issue for almost two weeks and don't understand. After I cleared the cache, the first order goes well, after that the next order is a copy of the first untill I clear the cache again. It doesn't matter if the order is from a different computer, or even ip address.

Perhaps it is somewhere in the module php. After working on the new site for three months straight, everything is finished, only this final issue is killing me.😉
Perhaps someone knows how to solve this issue, I would be so grateful!!
Thanks in advance for everyone who will take a look.
Btw, the Bixie module developer is not responding to the forum or support questions, unfortunately!
Regards,
Creezi

mod_bix_vmchrono.php
<?php
/**
 * Module mod_bix_vmchrono
 * (c) 2010 Matthijs Alles All rights reserved
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Include the helper functions only once
require_once( dirname(__FILE__).DS.'helper.php' );
$document	=& JFactory::getDocument();
$mainframe 	=& JFactory::getApplication();

$template	= $params->get('mode', 'default');
$hideAttribs	= $params->get('hideAttribs', 0);
$hideAddtocart	= $params->get('hideAddtocart', 0);
$addtocart	= $params->get('addtocart', 0);
$addtocart_conf	= $params->get('addtocart_conf', 0);

$chronoformname	= $params->get('chronoformname', '');
if ($chronoformname	== '') {
	echo "Define Chronoform-formname in module parameters!<br/>";
}
$vm_attrib		= $params->get('vm_attrib', '');
if ($vm_attrib	== '') {
	echo "Define VirtueMart Attribute in module parameters!<br/>";
}
$form_req   		= $params->get('form_req', 1);
$ajax_atc   		= $params->get('ajax_atc', 1);
if ($template == 'default') {
	$mess_width		= $params->get('mess_width', '100%');
	$moduletext		= nl2br($params->get('moduletext', ''));
	$none			= JText::_('NONE');
	$waittxt		= JText::_('WAITTXT');
	$errortxt		= JText::_('ERRORTXT');
	$successtxt		= JText::_('SUCCESSTXT');
	$mclass 		= false;
	if ($params->get('showWait', 1)) {
		$mclass		= 'wait';
	}
	$formkey = uniqid($chronoformname."|");
	$mainframe->setUserState( "bix_vmc_formkey", $formkey );
		
	$javascript = "";
	$javascript .= "
	window.addEvent('domready',function(){ 
		var formattr =  $('".$vm_attrib."_field');
		if (formattr) {
			formattr.readOnly = true;
			formattr.className = 'readonly';
			formattr.size = 10; 
			if (formattr.value == '') {
				formattr.value = '".$none."';
			}
		}";
	if ($mclass) {
		$javascript .= "
		var status = $('bix_vmc_status');
		status.addClass('".$mclass."');
		status.innerHTML = '".$waittxt."';
		";
	}
	$javascript .= "
		$('ChronoContact_".$chronoformname."').target = 'bix_vmc_target';
		var formkeyfield = document.ChronoContact_".$chronoformname.".formkey;
		formkeyfield.value = '".$formkey."';
	";
	if ($form_req == 1) {
	$javascript .= "
		addtocartbutton = $('vmMainPage').getElements('input.addtocart_button');
		if (addtocartbutton) {
			addtocartbutton.addEvent('click', function(e) {
				e = new Event(e);
				e.stop();
				if (formattr.value == '".$none."') {
					var status = $('bix_vmc_status').empty();
					var statusclass = status.className;
					status.removeClass(statusclass);
					status.addClass('error');
					status.innerHTML = '".JText::_('REQUIREDTXT')."';
					return false;
				} else { ";
		if ($ajax_atc) {
			$javascript .= "
					formid = document.addtocart.id;
					handleAddToCart( formid );	";
		} else {
					$javascript .= "
					document.addtocart.submit();";
		}
		$javascript .= "
				} 
			});
		}";
	}
	$javascript .= " 
	})"; //end domready

	$javascript .= "
	function BixFormUpdate () {
			var status = $('bix_vmc_status').empty();
			var statusclass = status.className;
			status.removeClass(statusclass);
			status.addClass('ajax-loading');
			
			var iframe = $('bix_vmc_target');
			if (iframe.addEventListener) {
				iframe.addEventListener(\"load\", BixformDone, false); // firefox
			} else if (iframe.attachEvent) {
				iframe.attachEvent(\"onload\", BixformDone); // IE
			}
	}
	function bix_addtocart () {
";
	if ($ajax_atc) {
		$javascript .= "
				formid = document.addtocart.id;
				handleAddToCart( formid );	";
	} else {
				$javascript .= "
				document.addtocart.submit();";
	}
	$javascript .= "
	}
	function BixformDone () {
		var statustxt=new Array();
		statustxt['wait']='".$waittxt."'; 
		statustxt['error']='".$errortxt."'; 
		statustxt['success']='".$successtxt."'; 
		var ret = frames['bix_vmc_target'].document.getElementsByTagName(\"body\")[0].innerHTML;
		var matchPos1 = ret.search(/{/);
		var matchPos2 = ret.search(/}/);
		ret = ret.substring(matchPos1,matchPos2+1);
		var data = eval(\"(\"+ret+\")\");  
		var formattr =  $('".$vm_attrib."_field');
		if (formattr) {
			formattr.value = data.rec_id;
		}
		var formkeyfield = document.ChronoContact_".$chronoformname.".formkey;
		formkeyfield.value = data.formkey;
		var status = $('bix_vmc_status').empty();
		var statusclass = status.className;
		status.removeClass(statusclass);
		status.addClass(data.mclass);
		status.innerHTML = statustxt[data.mclass];
		";
		if ($addtocart) {
			$javascript .= "
			if (data.mclass == 'success') {
		";
			if ($addtocart_conf) {
				$javascript .= "

				var notice_lbl = '".JText::_('POPUP_LABEL')."';
				var responseText = '<div class=\"shop_info\">".JText::_('FORM_PROCESSED')."</div>';
				var back_lbl = '".JText::_('BACK')."';
				var cart_lbl = '".JText::_('ORDER')."';
				if (document.boxB) {
					document.boxB.close();
				}
				document.boxB = new MooPrompt(notice_lbl, responseText, {
						buttons: 2,
						width:400,
						height:150,
						overlay: false,
						button1: back_lbl,
						button2: cart_lbl,
						onButton2: 	bix_addtocart
					});
				setTimeout( 'document.boxB.close()', 15000 );
				";
				} else {
						$javascript .= "
				bix_addtocart();	";
			}
			$javascript .= "
			}
			";
		}

					$javascript .= "
	}";
	
	$document->addScriptDeclaration($javascript);
} else {
	$uri = JFactory::getURI();
	$actionurl = $uri->_uri;
	$ajax_form_task_text = '';
	$ajax_form_task = false;
	$form_redirect_task_text = '';
	$form_redirect_task = false;
	$form_onsubmit_task_text = '';
	$form_onsubmit_task = false;
	if ( JRequest::getVar('Submit',0) ) {
		$ajax_form_task = JRequest::getVar('ajax_form_task', 0);
		$form_redirect_task = JRequest::getVar('form_redirect_task', 0);
		$form_onsubmit_task = JRequest::getVar('form_onsubmit_task', 0);
	}
	if ($ajax_form_task) {
		if ($ajax_form_task == 'create') {
			$ajax_form_task_text = modBixvmChronoHelper::MakeAjaxForm (0);
		} elseif ($ajax_form_task == 'reset') {
			$ajax_form_task_text = modBixvmChronoHelper::MakeAjaxForm (1);
		}
	}
	if ($form_redirect_task) {
		if ($form_redirect_task == 'create') {
			$form_redirect_task_text = modBixvmChronoHelper::MakeRedirect (0, $chronoformname);
		} elseif ($form_redirect_task == 'reset') {
			$form_redirect_task_text = modBixvmChronoHelper::MakeRedirect (1, $chronoformname);
		}
	}
	if ($form_onsubmit_task) {
		if ($form_onsubmit_task == 'create') {
			$form_onsubmit_task_text = modBixvmChronoHelper::MakeonSubmit (0, $chronoformname);
		} elseif ($form_onsubmit_task == 'reset') {
			$form_onsubmit_task_text = modBixvmChronoHelper::MakeonSubmit (1, $chronoformname);
		}
	}
	
	//check form
	$javascript .= "
	window.addEvent('domready',function(){ 
		var formattr =  $('".$vm_attrib."_field');
		var allfine =  $('allfine');
		var chronoform = $('ChronoContact_".$chronoformname."');
		var formkeyfield = document.ChronoContact_".$chronoformname.".formkey;
		var attrtext =  $('vm_attr_text');
		var formtext = $('vm_form_text');
		var formkeytext = $('vm_formkey_text');
		var attrmess = '<span style=\"color:green;\">".JText::_('VM_ATTR_OK')."</span>';
		var formmess = '<span style=\"color:green;\">".JText::_('VM_FORM_OK')."</span>';
		var formkeymess = '<span style=\"color:green;\">".JText::_('FORMKEY_OK')."</span>';
		if (!formattr) {
			attrmess = '<span style=\"color:red;\">".JText::_('NO_VM_ATTR')."</span>';
			if (allfine) {allfine.style.display = 'none'};
		} else {
			formattr.value = '".JText::_('VM_ATTR_OK')."';
		}	
		if (!chronoform) {
			formmess = '<span style=\"color:red;\">".JText::_('NO_VM_FORM')."</span>';
			if (allfine) {allfine.style.display = 'none'};
		}
		if (!formkeyfield) {
			formkeymess = '<span style=\"color:red;\">".JText::_('NO_FORMKEY')."</span>';
			if (allfine) {allfine.style.display = 'none'};
		}
		attrtext.innerHTML = attrmess;
		formtext.innerHTML = formmess;
		formkeytext.innerHTML = formkeymess;
	})";
	$document->addScriptDeclaration($javascript);
	//check ajax_return form
	$allfine = true;
	$check_ajaxform = modBixvmChronoHelper::CheckAjax_return ();
	switch ($check_ajaxform) {
		case 0:
		$ajax_form_text = '<span style="color:red;">'.JText::_('NO_AJAX_FORM').'</span>';
		$ajax_form_task = 'create';
		$allfine = false;
		break;
		case 1:
		$ajax_form_text = '<span style="color:green;">'.JText::_('AJAX_FORM_OK').'</span>';
		$ajax_form_task = 0;
		break;
		case 2:
		$ajax_form_text = '<span style="color:red;">'.JText::_('AJAX_FORM_FALSE').'</span>';
		$ajax_form_task = 'reset';
		$allfine = false;
		break;
	}
	//check redirects form
	$check_redirect = modBixvmChronoHelper::CheckFormRedirect ($chronoformname);
	switch ($check_redirect['redirect']) {
		case 0:
		$form_redirect_text = '<span style="color:red;">'.JText::_('NO_REDIRECTS').'</span>';
		$form_redirect_task = 'create';
		$allfine = false;
		break;
		case 1:
		$form_redirect_text = '<span style="color:green;">'.JText::_('REDIRECTS_OK').'</span>';
		$form_redirect_task = 0;
		break;
		case 2:
		$form_redirect_text = '<span style="color:red;">'.JText::_('REDIRECTS_FALSE').'</span>';
		$form_redirect_task = 'reset';
		$allfine = false;
		break;
	}
	switch ($check_redirect['submit']) {
		case 0:
		$form_onsubmit_text = '<span style="color:red;">'.JText::_('NO_ONSUBMIT').'</span>';
		$form_onsubmit_task = 'create';
		$allfine = false;
		break;
		case 1:
		$form_onsubmit_text = '<span style="color:green;">'.JText::_('ONSUBMIT_OK').'</span>';
		$form_onsubmit_task = 0;
		break;
		case 2:
		$form_onsubmit_text = '<span style="color:red;">'.JText::_('ONSUBMIT_FALSE').'</span>';
		$form_onsubmit_task = 'reset';
		$allfine = false;
		break;
	}
	//check database form
	$check_database = modBixvmChronoHelper::CheckFormDatabase ($chronoformname);
	if ($check_database['db'] == true) {
		$formdb_database_text = '<span style="color:green;">'.JText::_('FORMDB_OK').'</span>';
	} else {
		$formdb_database_text = '<span style="color:red;">'.JText::_('FORMDB_FALSE').'</span>';
		$allfine = false;
	}
	if ($check_database['formkey']) {
		$formdb_formkey_text = '<span style="color:green;">'.JText::_('FORMDB_KF_OK').'</span>';
	} else {
		$formdb_formkey_text = '<span style="color:red;">'.JText::_('FORMDB_KF_FALSE').'</span>';
		$allfine = false;
	}
}
//show template
require( JModuleHelper::getLayoutPath( 'mod_bix_vmchrono', $template ) );
?>


helper.php
<?php
/**
 * Module mod_bix_vmchrono Helper
 * (c) 2010 Matthijs Alles All rights reserved
 */


jimport('joomla.application.module.helper');

class modBixvmChronoHelper {
	function getFormInfo() {
		$mainframe 	=& JFactory::getApplication();
		$db	   		=& JFactory::getDBO();
		$formkeyold 	= $mainframe->getUserState( "bix_vmc_formkey", 0 );
		$formkey 	= $mainframe->getUserState( "bix_vmc_formkey", 0 );
		$formkey_arr = explode ("|",$formkey);
		$chronoformname = $formkey_arr[0];
		$chronoform = modBixvmChronoHelper::getChronoForm ($chronoformname);
		$formparams = new JParameter($chronoform->paramsall);
		$tablename = $formparams->get('tablenames');
		$query = "SELECT * FROM $tablename WHERE formkey = '$formkey'";
		$db->setQuery ( $query );
		$formrecord = $db->loadObject ();
		if ($formrecord->cf_id > 0) {
			$mclass = 'success';
		} else {
			$mclass = 'error';
		}
		//new formkey
		$formkey = uniqid($chronoformname."|");
		$mainframe->setUserState( "bix_vmc_formkey", $formkey );
		$info->rec_id		= $chronoformname."|".$formrecord->cf_id;
		$info->mclass		= $mclass;
		$info->formkey		= $formkey;
		
		return $info;
	}
	function getFormValues( $product, $vm_attrib = '' ) {
		$lang =& JFactory::getLanguage();
		$loadlang = $lang->load('mod_bix_vmchrono');
		$none = JText::_('NONE');
		if ($product['product_sku']) {
			$mod_position = modBixvmChronoHelper::getModPositionSku ( $product['product_sku']);
		} else {
			$mod_position = modBixvmChronoHelper::getModPosition ( $product['product_id']);
		}
		$mod_params = modBixvmChronoHelper::getModParams ( $mod_position );

		$prod_attribs = $product['product_name'];
		if ($vm_attrib == '') {
			$vm_attrib = $mod_params->get('vm_attrib');
		}
		$formid 	=  str_replace(' ','', modBixvmChronoHelper::FormidfromAttrib ($prod_attribs, $vm_attrib) );
		$hmtl = $prod_attribs;
		if ($formid && $formid != $none ) {
			$prod_attribs_clear = modBixvmChronoHelper::RemovefromAttrib ($prod_attribs, $vm_attrib);
			$hmtl = $prod_attribs_clear;
			$html .= JHTML::stylesheet('mod_bix_vmchrono.css','modules/mod_bix_vmchrono/assets/');
			$html .= '<ul class="bix_forminfo">';
			$hmtl .= modBixvmChronoHelper::ValuesfromFormid ( $formid, $mod_params );
			$html .= '</ul>';

		}
		return $hmtl;
	}
	function ValuesfromFormid ( $formid, $mod_params, $object = 0, $showfields_arr = Array() ) {
        $lang =& JFactory::getLanguage();
        $loadlang = $lang->load('mod_bix_vmchrono');
		$html = '';
		$parts 		= explode ("|",$formid);
		$chronoformname = $parts[0];
		$cf_id 		= $parts[1];
		$db	   	=& JFactory::getDBO();
		$chronoform = modBixvmChronoHelper::getChronoForm ($chronoformname);
		$formparams = new JParameter($chronoform->paramsall);
		$tablename = $formparams->get('tablenames');
		$query = "SELECT * FROM $tablename WHERE cf_id = $cf_id";
		$db->setQuery ( $query );
		$formrecord = $db->loadObject();
		if ($formrecord->cf_id > 0) {
			//hide fields
			$hide = array("cf_id", "uid", "recordtime", "ipaddress", "cf_user_id", "formkey");
			$hidefields_arr = explode(',',str_replace(' ','', $mod_params->get('hidefields')));
			$hide = array_merge($hide,$hidefields_arr);
			$values = new stdClass;
			foreach ($formrecord as $key => $value) {
				if ( !in_array($key, $hide) && $value != '' || $key == in_array($key,$showfields_arr) ) {
					$values->$key = $value;
				}
			}
		$html .= JHTML::stylesheet('mod_bix_vmchrono.css','modules/mod_bix_vmchrono/assets/');
		$html .= '<ul class="bix_forminfo">';
		foreach ($values as $key => $value) {
			//price adjust clean
			$start = strpos($value,'|');
			if ( $start == true ) {
				$value_cl = substr($value,0,$start);
				$mark = substr($value,($start+1),1);
				$price = $mark.trim($mod_params->get('currency')).' '.substr($value,($start+2));
				$value = $value_cl.' <small>('.$price.')'.'</small>';
			}
			
			$html .= '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="125"><li><span class="bix_vmc_label"><strong>'.JText::_($key).'</strong>:</span></td><td width="150" STYLE="text-align: left;"><span class="bix_vmc_value">'.$value.'</span></li></td></tr></table>';

		}
 
		$html .= '</ul>';
		}
		if ( $object == true && $formrecord->cf_id > 0 ) {
			return $values;
	}
	
		return $html;
	
	}
	function RemovefromAttrib ($prod_attribs, $vm_attrib) {
		$lang =& JFactory::getLanguage();
		$loadlang = $lang->load('mod_bix_vmchrono');
		$none = JText::_('NONE');
		$length = strlen ($vm_attrib) + 2;
		$search = $vm_attrib.":";
		if (stripos ( $prod_attribs , $search ) !== false) {
			$end1 = stripos ( $prod_attribs , $search );
			$start = stripos ( $prod_attribs , $search ) + $length;
			$upload_id_str = substr ( $prod_attribs , $start );
			if (substr ( $upload_id_str,0 ,strlen($none) ) == $none) {
				$length = $length + strlen($none);
			} else {
				$upload_id_arr = explode ( "|", $upload_id_str );
				$part1 = $upload_id_arr[0];
				$part2 = intval(substr($upload_id_arr[1], 0, 5));
				$length = $length + strlen($part1."|".$part2);
			}
			$start2 = $end1 + $length;
			$pc1 = substr($prod_attribs, 0, $end1);
			$pc2 = substr($prod_attribs, $start2);
			if (substr ( $pc2,0 ,5 ) == '<br/>') {
				$pc2 = substr ( $pc2, 5 );
			}
			return $pc1.$pc2;
		}
		return $prod_attribs;
	
	}
	function FormidfromAttrib ( $prod_attribs, $vm_attrib ) {
		$lang =& JFactory::getLanguage();
		$loadlang = $lang->load('mod_bix_vmchrono');
		$none = JText::_('NONE');
		$vm_attrib = $vm_attrib;
		if (stripos ( $prod_attribs , $vm_attrib ) === false) {
			return false;
		}
		//als enkel attribuut
		//test voor meer
		$multattribs = explode ( ";" , $prod_attribs ) ;
		$attrib1 = explode ( ":" ,$prod_attribs) ;
		if ( $attrib1[0] == $vm_attrib && count($multattribs) == 1 && strpos($attrib1[1],'<br/>') === false ) {
			return $attrib1[1];
		} 		
		//als meerdere attribs
		$prod_attribs_ns = str_replace(' ','', $prod_attribs);
		$prod_attribs1 = explode ( ";" , $prod_attribs_ns ) ;
		foreach ( $prod_attribs1 as $prod_attrib) {
			$attrib = explode ( ":" ,$prod_attrib) ;
			$attribs1[$attrib[0]] = $attrib[1];
		}
		if ($attribs1[$vm_attrib] && strpos($attribs1[$vm_attrib],'<br/>') === false) {
			return $attribs1[$vm_attrib];
		} 
		//zoeken in string
		$length = strlen ($vm_attrib) + 2;
		$search = $vm_attrib.":";
		if (stripos ( $prod_attribs , $search ) !== false) {
			$start = stripos ( $prod_attribs , $search ) + $length;
			$upload_id_str = substr ( $prod_attribs , $start );
			if (substr ( $upload_id_str,0 ,strlen($none) ) == $none) {
				$form_id = 0;
				return $form_id;
			}
			$upload_id_arr = explode ( "|", $upload_id_str );
			$part1 = $upload_id_arr[0];
			$part2 = intval(substr($upload_id_arr[1], 0, 5));
			return $part1."|".$part2;
		}
		//anders geen id
		$form_id = 0;
		return $form_id;
	} 
	function getAjax_formcode () {
			$ajax_formcode = '<?php
if (file_exists (JPATH_SITE.DS."modules".DS."mod_bix_vmchrono".DS."helper.php")) { 
	require_once (JPATH_SITE.DS."modules".DS."mod_bix_vmchrono".DS."helper.php");  
} 
$info 	= modBixvmChronoHelper::getFormInfo(); 
print json_encode(array(
	"rec_id"	=>	$info->rec_id,
	"mclass"	=>	$info->mclass,
	"formkey"	=>	$info->formkey
));?>';
		return $ajax_formcode;
	} 

	function CheckAjax_return () {
		$ajaxform = modBixvmChronoHelper::getChronoForm ('bix_ajax_return');
		if ($ajaxform->id < 1 ) {
			$check = 0;//geen form
		} else {
			$html = modBixvmChronoHelper::getAjax_formcode();
			$error = false;
			if ($ajaxform->html != $html ) {
				$error = true;
			}
			if ($ajaxform->published != 1 ) {
				$error = true;
			}
			if (!$error) {
				$check = 1;//form ok
			} else {
				$check = 2;//form verschilt
			}
		}
		return $check;
	} 
	function MakeAjaxForm ($reset) {
		$db	=& JFactory::getDBO();
		if ($reset) {
			$ajaxform = modBixvmChronoHelper::getChronoForm ('bix_ajax_return');
			$new_ajaxform = new stdClass;
			$new_ajaxform->id = $ajaxform->id;
			$new_ajaxform->html = modBixvmChronoHelper::getAjax_formcode();
			$new_ajaxform->published = 1;
			if (!$db->updateObject( '#__chrono_contact', $new_ajaxform, 'id' )) {
				return $db->stderr();
			}
			return JText::_('Ajax return form changed');
		} else {
			$query = "INSERT INTO #__chrono_contact
						(`name`, `html`, `published`)  
					 VALUES ( 'bix_ajax_return' , '".modBixvmChronoHelper::getAjax_formcode()."', 1) 
					"; 
			$db->setQuery ( $query );
			if (!$db->query()) {
				return $db->stderr();
			}
			return JText::_('Ajax return form added');
		}
	} 
	function CheckFormRedirect ($chronoformname) {
		$chronoform = modBixvmChronoHelper::getChronoForm ($chronoformname);
		if ($chronoform->redirecturl == '' ) {
			$check['redirect'] = 0;//geen redirect
		} else {
			if ($chronoform->redirecturl == 'index.php?option=com_chronocontact&chronoformname=bix_ajax_return&tmpl=component' ) {
				$check['redirect'] = 1;//redirect ok
			} else {
				$check['redirect'] = 2;//redirect verschilt
			}
		}
		if ( stripos ( $chronoform->attformtag , 'onsubmit=' ) === false ) {
			$check['submit'] = $chronoform->attformtag;//geen submit
		} else {
			if (stripos ( $chronoform->attformtag , 'onsubmit="BixFormUpdate()"' ) !== false) {
				$check['submit'] = 1;//submit ok
			} else {
				$check['submit'] = 2;//submit verschilt
			}
		}
		return $check;
	} 
	function MakeRedirect ($reset, $chronoformname) {
		$db	=& JFactory::getDBO();
		$new_form = new stdClass;
		$new_form->name = $chronoformname;
		$new_form->redirecturl = 'index.php?option=com_chronocontact&chronoformname=bix_ajax_return&tmpl=component';
		if (!$db->updateObject( '#__chrono_contact', $new_form, 'name' )) {
			return $db->stderr();
		}
		if ($reset) {
			return JText::_('Redirect changed');
		} else {
			return JText::_('Redirect added');
		}
	} 
	function MakeonSubmit ($reset, $chronoformname) {
		$db	=& JFactory::getDBO();
		$new_form = new stdClass;
		$new_form->name = $chronoformname;
		$new_form->attformtag = 'onsubmit="BixFormUpdate()"';
		if (!$db->updateObject( '#__chrono_contact', $new_form, 'name' )) {
			return $db->stderr();
		}
		if ($reset) {
			return JText::_('Redirect changed');
		} else {
			return JText::_('Redirect added');
		}
	} 
	function CheckFormDatabase ($chronoformname) {
		$db	=& JFactory::getDBO();
		$chronoform = modBixvmChronoHelper::getChronoForm ($chronoformname);
		$formparams = new JParameter($chronoform->paramsall);
		$tablename = $formparams->get('tablenames');
		$query = "SHOW COLUMNS FROM $tablename ;";
		$db->setQuery ($query);
		if ($db->query()) {
			$check['db'] = 1;//db ok
			$columns = $db->loadResultArray();
			if (in_array('formkey',$columns)) {
				$check['formkey'] = 1;//formkeyfield ok
			} else {
				$check['formkey'] = 0;//geen formkeyfield
			}

		} else {
			$check['db'] = 0;//geen db
		}
		return $check;
	}
	function getChronoForm ($chronoformname) {
		$db	=& JFactory::getDBO();
		$query = "SELECT * FROM #__chrono_contact WHERE name = '$chronoformname' LIMIT 0,1";
		$db->setQuery ($query);
		return $db->loadObject();
	}
	function getModParams ($position) {
		$db	=& JFactory::getDBO();
		$query = "SELECT params FROM #__modules WHERE position = '$position' LIMIT 0,1";
		$db->setQuery ($query);
		$mod_params = $db->loadResult();
		$mod_params = new JParameter($mod_params);
		return $mod_params;
	}
	function getModPositionSku ($product_sku) {
		$db	=& JFactory::getDBO();
		$position = false;
		$query = "SELECT product_desc FROM #__vm_product WHERE product_sku = '$product_sku' LIMIT 0,1";
		$db->setQuery ($query);
		$descr = $db->loadResult();
		$mod_position = modBixvmChronoHelper::PositionFromDescr ($descr);
		return $mod_position;
	}
	function getModPosition ($product_id) {
		$db	=& JFactory::getDBO();
		$position = false;
		$query = "SELECT product_desc FROM #__vm_product WHERE product_id = '$product_id' LIMIT 0,1";
		$db->setQuery ($query);
		$descr = $db->loadResult();
		$mod_position = modBixvmChronoHelper::PositionFromDescr ($descr);
		return $mod_position;
	}
	function PositionFromDescr ($descr) {
		$regex = '/{loadposition\s*.*?}/i';
		preg_match_all( $regex, $descr, $matches );
		$count = count( $matches[0] );
		if ( $count  ) {
			for ( $i=0; $i < $count; $i++ )
			{
				$match = str_replace( 'loadposition', '', $matches[0][$i] );
				$match = str_replace( '{', '', $match );
				$match = str_replace( '}', '', $match );
				$match = trim( $match );
				if (strpos($match,'vmchrono') !== false) {
					$position = $match;
				}
			}
		}
		if (!$position) 
			$position = 'vmchrono';
		return $position;
	}
	//VirtueMart helpers
	function getPriceInfo($description, $product_id) {
		$mod_position = modBixvmChronoHelper::getModPosition ( $product_id );
		$mod_params = modBixvmChronoHelper::getModParams ( $mod_position );
		$adjustments = new Stdclass;
		$adjustments->apply = false;
		$adjustments->adjustment = 0;
		$adjustments->setprice = 0;
		$adjustments->set_price = false;
		$vm_attrib = $mod_params->get('vm_attrib');
		if ($vm_attrib == '') {
			$vm_attrib = 'Form-id';
		}
		$formid = modBixvmChronoHelper::FormidfromAttrib ( $description, $vm_attrib );
		$showfields_arr = explode(',',str_replace(' ','', $mod_params->get('hidefields')));
		$formvalues = modBixvmChronoHelper::ValuesfromFormid ( $formid, $mod_params, 1, $showfields_arr );
		if ($formvalues) {
		foreach ($formvalues as $value) {
				$split = explode ("|", $value);
				if (is_numeric ($split[1])) {
					$adjustments->apply = true;
					$adjustments->adjustment += $split[1];
				} elseif (substr($split[1],0,1) == '=') {
					$adjustments->apply = true;
					$adjustments->setprice = substr($split[1], 1);
					$adjustments->set_price = true;
				}
			}
		}
		return $adjustments;
	}
}
?>






bix_ajax_return form in chronoforms
<?php
if (file_exists (JPATH_SITE.DS."modules".DS."mod_bix_vmchrono".DS."helper.php")) { 
	require_once (JPATH_SITE.DS."modules".DS."mod_bix_vmchrono".DS."helper.php");  
} 
$info 	= modBixvmChronoHelper::getFormInfo(); 
print json_encode(array(
	"rec_id"	=>	$info->rec_id,
	"mclass"	=>	$info->mclass,
	"formkey"	=>	$info->formkey
       )); ?>
creezi 30 Mar, 2011
I am a step further, sorry for changing the problem over and over.
I have tested with the cache plugin on and off. When the plugin is off, the order placing goes well, but in the next step in the cart, my added products are gone.

So I do need the caching to be on. I could've sworn it was off, during my last tests, but obviously it wasn't. My apologies. I have been testing for so long that it is confusing which steps I have taken.

Conclusion; it must be a combination of Bixie with Virtuemart issue and definitely not a chronoforms problem. I will ask on the virtuemart forum. But in case you have any suggestions, please say so. Thanks in advance.
Creezi
This topic is locked and no more replies can be posted.