Forums

VIrtuemart and shopper group update?

jkosick 14 May, 2010
I was wondering if it would be possible to use chrono forms as a way to update the shopper group? I currently have it set up as a coupon code that updates that database so that default users can input this code and change to a discount gold group so I don't have to manually do it each time.

I would like do this in a form that you just use a text box and hit submit to change your shopper group.

<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

class ps_coupon extends vm_ps_coupon {
	function process_coupon_code( $d ) {
		$retval=vm_ps_coupon::process_coupon_code($d);
		$user =& JFactory::getUser();
		if($d['coupon_code']=="password here" && $user->id > 0 )  {
			$d['shopper_group_id']="6"; 
			$user =& JFactory::getUser();
			$db =& JFactory::getDBO();
			$q = "UPDATE #__vm_shopper_vendor_xref SET `shopper_group_id` = '6' WHERE `user_id` =".$user->id." LIMIT 1";
			$db->setQuery($q);
			$db->query();
		}
	}
}
?>


Thank you for any info you might have!
GreyHead 15 May, 2010
Hi jkosick,

I think that would probably work - try it and see.

Bob
jkosick 15 May, 2010
I only know enough to edit php code, how would I go about making this happen in the form? Do i need to connect it the database or just put this code somewhere in the form?
GreyHead 20 May, 2010
Hi jkosick,

I'm afraid that it isn't just a quick cut and paste job. This class depends on another VirtueMart class that probably also has to be loaded.

It's going to take a few hours for someone familiar with PHP.

Bob
This topic is locked and no more replies can be posted.