Skip to main content

Plugin onAfterUserCreate, Extrenal Invoice API

More
12 years 3 months ago #157720 by Stejk
-- HikaShop version -- : 2.3.1 Business
-- Joomla version -- : 3.2.1

Hello,

I have a problem with plugin developing.
I want this:
  1. User fill registration
  2. Data from form will be send to some server
My code: Fapi.php
Code:
<?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 } }
Fapi.xml
Code:
<?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).

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #157723 by Mohamed Thelji
Hello,
1. Can you test it by registering through the Hikashop registration form ?

2. Can you check if your plugin is called or not after a registration by adding some "debug" code ?

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #158205 by Stejk
Hello,
I think this code is debug
Code:
echo var_dump($element);
If i send some product and process to checkout, i register but nothing happend.

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #158246 by Jerome
Hi,

Because it's an HikaShop plugin, HikaShop will be loaded.
You don't have to put the inclusion of HikaShop in the beginning of your file.

Please be careful with filenames while developing plugins, use filenames in lowercase will be better for Linux.

You can put a " die('fapi plugin'); " just before your class to be sure that your plugin is right loaded (maybe unpublished, file not found depending the case (check the database too or re-install the plugin)).

The trigger "onAfterUserCreate" is called when HikaShop create a new user. You can put a trace in the HikaShop core itself to be sure that the trigger is right called (class user in HikaShop).

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.197 seconds
Powered by Kunena Forum