News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Create a customer from external from aplication

Started by Angel Julian Mena, October 27, 2016, 10:03:59 AM

Previous topic - Next topic

Angel Julian Mena

Hi,
I'm creating an external application users and need to create users in virtuemart, I added data to the following tables:
$query = "INSERT INTO xxx_users (name, username, email, password,  block, sendEmail, registerDate )  VALUES  ('{$name}', '{$email}', '{$email}', '{$password}',  '{$block}', '{$sendEmail}',  NOW())";
$query = "INSERT INTO xxx_user_usergroup_map (user_id, group_id)  VALUES  ('{$value}',  '2')";

From create joomla user and tables:
$query = "INSERT INTOxxx_virtuemart_vmusers (virtuemart_vendor_id, user_is_vendor, customer_number, virtuemart_paymentmethod_id, virtuemart_shipmentmethod_id, agreed)  VALUES  ('{$virtuemart_vendor_id}', '{$user_is_vendor}', '{$customer_number}', '{$virtuemart_paymentmethod_id}', '{$virtuemart_shipmentmethod_id}', '{$agreed}')";
$query = "INSERT INTO  xxx_virtuemart_vmuser_shoppergroups (virtuemart_user_id, virtuemart_shoppergroup_id)   VALUES  ('$virtuemart_user_id', '2')";
$query = "INSERT INTO xxx_virtuemart_userinfos (virtuemart_user_id, address_type, name, last_name, first_name, username, email, phone_1, address_1, city, virtuemart_state_id, virtuemart_country_id, zip, agreed) VALUES   ('{$virtuemart_user_id}', '{$address_type}', '{$name}', '{$lastname}', '{$firstname}', '{$email}', '{$email}', '{$phone}', '{$address}', '{$city}', '{$virtuemart_state_id}', '{$virtuemart_country_id}', '{$zip}', '{$agree}')";

The user is created and the table virtuemart_userinfos see the information and the address, but both the administration and when the user loegea and this in the checkout process information from the billing address is not shown.

Someone can tell me if there is an error in these tables or should I create a record in another table so that the billing address is accessible?

Thanks

Studio 42

Why not using a plugin and get fields from VM form (or adding the framework using includes in a PHP file)?
In all case you need to call the serveur and secure your exchange with the server.
On doing this, you can use the original way to get all needed datas and reuse the VM/joomla code to save all with some security checks.

Angel Julian Mena

Thanks for your answer.
But the form where the data is filled is more extensive and is out of joomla. I need to know if I need to add data to a table or I need to fill some field.

Studio 42

It's not a problem to fill it from external application in a php file.
you have for eg, this generic code:
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));

require_once ( JPATH_BASE. '/includes/defines.php' );
require_once ( JPATH_BASE. '/includes/framework.php' );
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();

JPATH_BASE have to be changed for your need.
After this, you can use standard things.
But you can add an entry to a plugin using com_ajax and send get your datas, for VM you need to declare Virtuemart config.
And in your query you have an error : INSERT INTOxxx_virtuemart_vmusers > INSERT INTO xxx_virtuemart_vmusers , the $address_type need to be "BT", $user_is_vendor, always set to 0, $virtuemart_vendor_id always set to 1 ....