VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Zilvermeeuw on May 29, 2021, 18:08:52 PM

Title: Starting with API
Post by: Zilvermeeuw on May 29, 2021, 18:08:52 PM
I would like to start learning the API of Virtuemart.

I am reading https://api.virtuemart.net, but nothing what I do works.

Does anybody have an example how to start with the API?
Title: Re: Starting with API
Post by: Zilvermeeuw on May 31, 2021, 06:26:44 AM
I added "include "testapi.php";" at the beginning of "administrator/components/com_virtuemart/views/orders/tmpl/orders.php". So when I open de Virtuemart orders list, the script "testapi.php" is called.

the array $this->orderslist contains all orders
the member 0 contains information about the last order ($this->orderslist[0])
The following vmJsApi works (it is a copy from orders.php)
$order = $this->orderslist[0];
echo vmJsApi::date ($order->created_on, 'LC2', TRUE) ."<br>";


In https://api.virtuemart.net several classes are given. For example the following. But this is not working (I tried several classes).
$q = VirtuemartViewOrders::display ($order);
echo "q = ". $q  .".<br>";


Also the first vmJsApi parameters, I cannot find in the api.virtuemart.net website.

I think I am on the wrong track. But where?
Title: Re: Starting with API
Post by: pinochico on May 31, 2021, 10:16:16 AM
why do you need API?
Title: Re: Starting with API
Post by: Zilvermeeuw on May 31, 2021, 10:32:10 AM
I would like to:
Title: Re: Starting with API
Post by: Studio 42 on May 31, 2021, 23:24:10 PM
The APi is to use in Joomla. If you want connect an ERP, you have to use (joomla) plugins, you have no external APi for Virtuemart.
You have some extensions that can render a list of product with some filters, but what you want to do is a big task(hundreds Hours of dev)
I see that you do not a PHP expert, so first you have to understand MVC, Joomla and after VIrtuemart before trying to create your own API
Title: Re: Starting with API
Post by: Zilvermeeuw on June 01, 2021, 07:29:02 AM
I know I have to write a plugin. I already created two MVC's in Joomla. With PHP, SQL and calls to the ERP with its API. (So I am an expert wanebee, see my signature)

I like the way, an API works. Just ask some information and get an answer. Without need for knowledge of the SQL database or array structures.
To get rid of the SQL queries I would like to use API's. Therefor I made the above (very simple, without plugin) example and tried several formats of the line. But none are working.
Clearly I miss something.

Edit: If found the class vmJsApi and played around with it. This works.
I would like to use the class, mentioned in https://api.virtuemart.net/annotated.html.

How can I call these classes?
Title: Re: Starting with API
Post by: pinochico on June 01, 2021, 08:53:37 AM
if you want connect ERP you have to write your custom class in your plugin.
(we connected SAP, KTK, online app on mobile with VirtueMart).

Or you can use existing solutions
- with Xml/CSV files (+ cron) - we connected Cesar, Helios
- with DB - we connected Pohoda, MoneyS4

We don't use API VM.

Title: Re: Starting with API
Post by: Studio 42 on June 01, 2021, 10:52:27 AM
If you click on the function details, you see that this list is only a function list of other plugins .

For eg BatchDelete :
The documentation for this class was generated from the following file:
plugins/vmcalculation/avalara/classes/BatchSvc/BatchDelete.class.php

You have no way to communicate with Vm directly using an API
Title: Re: Starting with API
Post by: Zilvermeeuw on June 02, 2021, 06:15:24 AM
OK, thanks.

No API, just function calls.
Title: Re: Starting with API
Post by: pinochico on June 02, 2021, 10:17:39 AM
That is right