-- HikaShop version -- : 2.2.0
-- Joomla version -- : 3.1.4
-- PHP version -- : 5.3.27
Hi guys
I am beginning an exciting journey in Hikashop custom plugin development! Yay!
I have a basic function like this:
class plgHikashopkf_insert extends JPlugin
{
function plgHikashopKashflow(&$subject, $config){
parent::__construct($subject, $config);
if(!isset($this->params)){
$plugin =& JPluginHelper::getPlugin('hikashop', 'kf_insert');
jimport('joomla.html.parameter');
$this->params = new JParameter( $plugin->params );
}
}
function onAfterOrderCreate(&$order,&$send_email){
if(!empty($order->order_id)){
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$from = "no_replies_please@********.co.uk";
$headers .= "From:".$from;
$email_add = '*******.net';
$subject = 'Test';
mysql_connect("localhost", "**********", "************") or die(mysql_error());
mysql_select_db("****************") or die(mysql_error());
$order_id = $order->order_id;
$order_user_id = mysql_result(mysql_query("SELECT order_user_id FROM nl7xh_hikashop_order WHERE '".$order_id."' = order_id ;"), 0);
$user_email_add = mysql_result(mysql_query("SELECT user_email FROM nl7xh_hikashop_user WHERE '".$order_user_id."' = user_id ;"), 0);
$order_shipping_address_id = mysql_result(mysql_query("SELECT user_email FROM nl7xh_hikashop_user WHERE '".$order_user_id."' = user_id ;"), 0);
$message = "User ID: $order_user_id Email: $user_email_add;"; //etc
mail($email_add, $subject, $message, $headers);
}
return true;
}
}
Is using queries a good or bad way to get the field data from multiple tables into my script? Is there an easier way? I guess my main problem is I don't understand how to make use of the $order object properly?
Any help would be marvellous
All the best
Eleventy