<?php
/**
*@author Jakub Stejskal <Cajme1273@gmail.com>
*@copyright Copyright (c) 2014, Jakub Stejskal
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.plugin.plugin');
if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
class plgHikashopFapi extends JPlugin {
function plgHikashopFapi(&$subject, $config){
parent::__construct($subject, $config);
}
/*
function onAfterOrderCreate(&$order) {
}*/
function onAfterUserCreate(&$element) {
/**
* Login informace do FAPI
* @todo Udělat napojení na administraci a udělat úpravu v ní
*/
$username = 'login';
$password = 'pass';
$data = array(
'email' => $element->email,
'first_name'=> $element->first_name,
'last_name'=> $element->last_name,
'phone'=> $element->telephone,
'address'=> array(
'street'=> $element->street,
'city'=> $element->city,
'zip'=> $element->post_code,
'country'=> $element->country,
),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.fapi.cz/clients");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode("$username:$password"),
'Accept: application/json',
'Content-Type: application/json'
));
$response = curl_exec($ch);
curl_close($ch);
echo var_dump($element); // For check data
}
}
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="hikashop">
<name>Hikashop Fapi connector</name>
<author>Jakub Stejskal</author>
<creationDate>24/05/2014</creationDate>
<copyright>Copyright (C) 2014 Jakub Stejskal. All rights reserved.</copyright>
<license>GNU General Public License</license>
<authorEmail>Cajme1273@gmail.com</authorEmail>
<authorUrl>www.stejk.eu</authorUrl>
<version>1.0</version>
<description>Connect HikaShop and Fapi API</description>
<files>
<filename plugin="Fapi">Fapi.php</filename>
<filename>index.html</filename>
</files>
</extension>
But if i complete registration nothing.
If i make this ready, next task is send order details (address and items) to invoice application (FAPI.CZ).