Detect, that a joomla user bought an article

  • Posts: 45
  • Thank you received: 2
13 years 3 months ago #23034

Hello,

I want to create a webservice, that delivers specific values from my database, if a joomla user bought and paid a specific product in my shop.
I which table(s) do I find this information?

Or is there a prefabricated php function, which I could use?

Regards,

KB

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 3 months ago #23039

Hi,

The best is maybe to create a hikashop plugin an implement the event onAfterOrderUpdate(&$order,&$send_email) :
www.hikashop.com/en/support/documentatio...r-documentation.html
That function will be triggered when an order is modified. So you could check the order_status of the order and if it's confirmed, load it's products and do what you need to do for your integration.

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

  • Posts: 45
  • Thank you received: 2
13 years 3 months ago #23121

Thank you, nicolas, for your quick answer!

At the moment I am trying to make it more simple.

I need the information ("a certain joomla user payed a certain article") in an external script.

For better comprehension:
I have a Webservice (written in C#) contacting a PHP script to figure out, if a) an assigned user-password-combination exists in Joomla and b) the user has payed a certain article.

For a) I used this code:

define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', dirname(__FILE__) . DS . '..'); // assuming we need to go up 1 step to get to the Joomla root

require_once (JPATH_BASE .DS. 'includes' .DS. 'defines.php');
require_once (JPATH_BASE .DS. 'includes' .DS. 'framework.php');
require_once (JPATH_BASE .DS. 'libraries' .DS. 'joomla'. DS. 'user' .DS. 'authentication.php');

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

$credentials = array(
'username' => $this->username,
'password' => $this->password);

$options = array();

$authenticate = JAuthentication::getInstance();
$response = $authenticate->authenticate($credentials, $options);

if ($response->status === JAUTHENTICATE_STATUS_SUCCESS) {
return true;
}
else {
return false;
}


Is there a solution similarly short and easy solution for b)? Maybe I could call a hikashop script with assigned email address, username and article and the information returned is true, if the user (has bought the article and) has payed for it someday?

Last edit: 13 years 3 months ago by klimmbimm.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 3 months ago #23136

There is no such script in HikaShop.
You will have to make your own query it the database. The tables involved will be:
hikashop_order, hikashop_user and hikashop_order_product.
The query should be something like that:
SELECT * FROM #__hikashop_user AS a LEFT JOIN #__hikashop_order AS b ON a.user_id=b.order_user_id LEFT JOIN #__hikashop_order_product AS c ON b.order_id=c.order_id WHERE a.user_email='This email address is being protected from spambots. You need JavaScript enabled to view it.' AND b.order_status='confirmed' AND c.product_code='CODE_OF_MY_PRODUCT';

To make a query in joomla once joomla is initialized, you can do like that:
$db=&JFactory::getDBO();
$db->setQuery($query);
$result = $db->loadObjectList();

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

Time to create page: 0.038 seconds
Powered by Kunena Forum