VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: _oscar_ on February 07, 2011, 16:32:49 PM

Title: Documentation for plugin development
Post by: _oscar_ on February 07, 2011, 16:32:49 PM
Hey all,

There's a new page in our Wiki that describes the new plugin system for VirtueMart 2.
As you've probably seen before, it now uses the Joomla! plugin structure; there are some base classes for creating shipper- and payment plugins available.

If you wanna help VM by creating new plugins or converting VM1.1.x plugins to VM2; I'll buy you a beer (and even drink it for you :) )

For documentation, please have a look at http://dev.virtuemart.net/projects/virtuemart/wiki/Plugin_system
Any comments, just drop'm here!
Title: Re: Documentation for plugin development
Post by: stAn99 on March 06, 2011, 13:50:03 PM
Hello Everybody,
i analyzed VM2 (beta2, quick look at beta3) plugin system, and i would like to recommend to use own JInstall adapter for installing plugins with type="vm_ext". The advantage of own adapter is that we could use two sql inclusion files in manifest XML one for joomla 1.5 and the other for joomla 1.6. Also if the plugins would be saved as type adapter's type, they would not have to be in JPATH_PLUGINS directory where we don't really want to store them.

Also many VM extensions for VM 1.1.x are based on modifing ps_checkout->add( ps_checkout->process( functions of checkout processing. These are usually various coupon systems and payment systems. Will there be any possibility how can one particular function of VM2 can be overriden with 2 different plugins? 
Title: Re: Documentation for plugin development
Post by: Milbo on March 06, 2011, 20:03:11 PM
Quote from: stAn99 on March 06, 2011, 13:50:03 PM
they would not have to be in JPATH_PLUGINS directory where we don't really want to store them.
Why we do not really want to store them there? I am confident with using the general joomla plugin directory.

Quote from: stAn99 on March 06, 2011, 13:50:03 PM
Also many VM extensions for VM 1.1.x are based on modifing ps_checkout->add( ps_checkout->process( functions of checkout processing.
This function does not longer exist. All this extensions must be rewritten using joomla event hooks.
Title: Re: Documentation for plugin development
Post by: Minh BlackRed on March 21, 2011, 04:17:16 AM
@_oscar_:
http://dev.virtuemart.net/projects/virtuemart/wiki/Plugin_system
"Since VirtueMart v2, the Joomla! plugin system is used form payment and shipper plugins"
---
There has no plugin to control display of product on front-end?
Title: Re: Documentation for plugin development
Post by: _oscar_ on March 21, 2011, 09:51:11 AM
Quote from: ojb on March 21, 2011, 04:17:16 AM
There has no plugin to control display of product on front-end?

Not yet. There will be more events supporting more plugin types. There are a few undocumented ones already in the backend, but no plugins have been written for those events and therefore they can't be tested.
It's not planned to add more events for 2.0; after that release the plugin system will be expanded.
Title: Re: Documentation for plugin development
Post by: Dade on July 16, 2011, 17:10:18 PM
Oscar, you mean that if I try to create a plugin (for payment in my case) it won't be showed on the payment check on the front-end?

I'm asking because I'm trying to do a plugin for payments with AUP but since I activated it it gives me an error on the edit payment page (task=editpayment). It's because what you mentioned or simply because it's not written properly (I mean my plugin :P).

Thanks for your time!
Title: Re: Documentation for plugin development
Post by: _oscar_ on July 16, 2011, 19:22:01 PM
I answer this because you direct your question to me, but I left the VM project team about 3 months ago.
I'm not sure what happened with the plugin system since then, but from what I understand from your question.... it's not properly written ;)

Payment plugins should appear in the frontend on checkout, unless anything changed there over the last few months, but then there might be simply a bug that I'm sure someone in the team will pick up
Title: Re: Documentation for plugin development
Post by: Milbo on July 17, 2011, 00:02:59 AM
Haha oscar, what your writing?

You know very good, that this part was "done" as you left, and that you continued my work and was the last one who wrote on it before you left the team. On of the first things I added to the vmpayment plugin is the selfdisplaying on the frontend.

But to get the paypal plugin working we had to add some important stuff and rewrite some code, thats true. I suggest Dade should take a look on the wiki, the cash on del and the paypal plugin to understand how it is working.
Title: Re: Documentation for plugin development
Post by: alatak on July 19, 2011, 16:04:20 PM
Hi,

Quoteyou mean that if I try to create a plugin (for payment in my case) it won't be showed on the payment check on the front-end?

They do appear on the frontend. When you create a payment method, by default it is not published. Could this be the problem?
Title: Re: Documentation for plugin development
Post by: cmarkell on October 18, 2011, 09:18:17 AM
Is the wiki accurate still? In the current svn version the plgVmOnSelectPayment has become xxxplgVmOnSelectPayment and doesn't appear to be being used to output the select option during checkout... I'm trying to add credit card form fields, is this still the way?
Title: Re: Documentation for plugin development
Post by: alatak on October 18, 2011, 09:21:03 AM
Hi,

No, i am actually doing it.

The xxxplgVmOnSelectPayment is an obsolete function. I will remove it now .
Title: Re: Documentation for plugin development
Post by: f.janssen on November 30, 2011, 22:12:55 PM
If plgVmOnSelectPayment  is obsolete, how can I then add extra parameters which are needed for my payment plugin ?

Also, I do think these changes are kinda big if, VM2 is production ready.
I think I should wait some months for actually using this software or am I mistaken ?

Kind regards,
Fred
Title: Re: Documentation for plugin development
Post by: alatak on November 30, 2011, 22:54:13 PM
Hi,

The function plgVmOnSelectPayment() is not obsolete.
It is the one which i had in the code xxxplgVmOnSelectPayment() which should not have been on the code.
Title: Re: Documentation for plugin development
Post by: tlahtine on December 27, 2011, 15:29:40 PM
Quote from: _oscar_ on February 07, 2011, 16:32:49 PM

For documentation, please have a look at http://dev.virtuemart.net/projects/virtuemart/wiki/Plugin_system

Seems that the server is down?
Title: Re: Documentation for plugin development
Post by: alatak on December 27, 2011, 15:30:43 PM
Hi

Yes it is down.
We are trying to fix the problem.
Title: Re: Documentation for plugin development
Post by: Dokho on January 03, 2012, 15:29:12 PM
QuoteHi,

No, i am actually doing it.

The xxxplgVmOnSelectPayment is an obsolete function. I will remove it now .

Hi, that means, you are working on the credit card extra fields ?

I like VM but I'm new on that, I'm try to add extra fields for Credit Card payment but I don't know how.  My question it's : Are you guys working on the credit card extra fields ?
Title: Re: Documentation for plugin development
Post by: d0ublezer0 on February 27, 2012, 21:16:26 PM
Hi all!
I began to study the VM plugin system, to begin developing a payment plug-in .
I really do not have enough information to develop - the wiki describes only a few moments. That's not enough, unfortunately.
I could understand, how to install plug-in from the example of existing VM plugin package. But VM comes only with a component AIO, but does not have the installation file for the plugin (in pure form). I find it difficult to understand, from what I can get rid of the installer, and what is worth keeping.

Can you give me an example?
Thank you!
Title: Re: Documentation for plugin development
Post by: d0ublezer0 on February 28, 2012, 15:27:31 PM
Here's a question: saving plugin settings in the database - this is a mandatory requirement?
In my plugin i want only display printable order form (html)
Title: Re: Documentation for plugin development
Post by: juanma70 on February 29, 2012, 23:48:13 PM
In 'description' text field of vm 1.x payment methods where we did can insert the php code was a very practical way for personalized payment methods. ¿This way do not will be implemented in VM2 ? :-( i love VM but i do not very well in advance programation as to built a payment plugin from zero.

Now i am in a terrible dilemma: i want use J1.7 because its great multilanguage system, but if i can´t implemented the personalized payment plugin i´m in troubles. In my country (Colombia) paypal is not very popular and the only online accepted method is owned by a especific payment platform.

Any ideas?
Title: Re: Documentation for plugin development
Post by: IceMan-101 on March 28, 2012, 11:50:49 AM
I looked at the wiki provided and it does not supply enough information to write a custom payment plugin for my needs. I also look at the standard payment method and paypal method for guidance but I am having no luck.

Here is what I would like to do:

I want to create a payment method that reads the "User's" available credits from a web service (API) and if the user has the correct amount of credits available, it will deduct the credits via the API and process the order and if the user does not have the correct amount it will return an error to the user and decline the order.

If anybody could supply me with a guide, tutorial or documentation on how to create a payment method from scratch, it would be highly appreciated.
Title: Re: Documentation for plugin development
Post by: brendonhatcher on April 14, 2012, 16:24:26 PM
Hi

The wiki page does not explain how to redirect the user back from the payment gateway provider to the VirtueMart site in order to display a thank you page and update the order to "confirmed".

Can someone provide some guidance on this?

Thanks
Brendon
Title: Re: Documentation for plugin development
Post by: webcompass on May 08, 2012, 12:58:20 PM
Hi I read the informations here: http://dev.virtuemart.net/projects/virtuemart/wiki/Plugin_system

So I need to develope a Shipper plugin and I tried to do as was described in the wiki but I can not find vmShipperPlugin, and vmPaymentPlugin in the /components/com_virtuemart/helpers/.... dir! Can anyone say a few words about that why these abstract classes have been removed, and how to use the plugin system without these?

Thanks!
Title: Re: Documentation for plugin development
Post by: Alejandro Kurczyn on May 30, 2012, 05:07:09 AM
So how exactly should I code a plugin that runs when an order is confirmed as PAID?  I have tried several "events" but just can't get it right. I -know- how to code plugins, but I don't see how to call one on such event by looking at Virtuemart2 code or wiki docs. Perhaps I'm missing something?

It surely is a big miss if this is not possible without hacking VM2 PHP code, as many stores may need to trigger customized tasks when an order is paid like managing 3rd party stock reordering, 3rd party accounting records, not to mention online analytics information.

VM2 is quite the beast to tame if you want to develop for it.  My 2 cents.
Title: Re: Documentation for plugin development
Post by: lbear on June 14, 2012, 00:17:46 AM
Quote from: juanma70 on February 29, 2012, 23:48:13 PM
In 'description' text field of vm 1.x payment methods where we did can insert the php code was a very practical way for personalized payment methods. ¿This way do not will be implemented in VM2 ? :-( i love VM but i do not very well in advance programation as to built a payment plugin from zero.

Now i am in a terrible dilemma: i want use J1.7 because its great multilanguage system, but if i can´t implemented the personalized payment plugin i´m in troubles. In my country (Colombia) paypal is not very popular and the only online accepted method is owned by a especific payment platform.

Any ideas?

Check this post for Dineromail in Colombia http://forum.virtuemart.net/index.php?topic=103885.0 (http://forum.virtuemart.net/index.php?topic=103885.0)
Title: Re: Documentation for plugin development
Post by: BrownSystems on August 27, 2012, 23:49:08 PM
Would it be possible to have some additional events/hooks added?

I'd like to create some plugins that would allow the use of third party shopping carts in conjunction with virtue mart. To do this I would need an event/hook on the product details page.

Anyone have any suggestions for how I should proceed?
Title: Re: Documentation for plugin development
Post by: alatak on August 28, 2012, 09:25:00 AM
Hello,

there is already a hook for the product page. It has been implemented in the version 2.0.8.

The hook is
function plgVmOnProductDisplayPayment ($product, &$productDisplay)
$product: is the product object
$productDisplay: the display that should be added in the product page

You have an example of how to use it with the Klarna plugin payment.
Title: Re: Documentation for plugin development
Post by: themhz on October 12, 2012, 16:03:38 PM
I have managed to create a plugin with the following code


<?php

// no direct access
defined('_JEXEC') or die;

if (!
class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS DS 'vmcustomplugin.php');

class 
plgAftercheckout extends vmCustomPlugin
{
 public function __construct (&$subject$config=array()) {
  echo "ok";
         
parent::__construct($subject$config);
         
$this->_path JPATH_PLUGINS.DS.$this->getName();
         
JPlugin::loadLanguage('plg_vmextended_'.$this->getName());
     }
 
   public function 
plgVmOnDisplayProductFE$field$param$product$idx){
   
echo "plgVmOnDisplayProductFE fired";
die();
   } 
 
   public function 
plgVmOnAddToCart(&$product)
{
    echo "plgVmOnAddToCart fired";
die();

}

public function plgVmConfirmedOrder($cart$order)
{
echo "plgVmConfirmedOrder fired";
die();
}

}

?>


I also created the xml file like this


<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="vmcustom">
        <name>plg_aftercheckout</name>
        <author>themhz</author>
        <creationDate>June 18th, 2012</creationDate>
        <copyright>CodeCraft.gr</copyright>
        <license>GNU General Public License</license>
        <authorEmail>themhz@codecraft.gr</authorEmail>
        <authorUrl>http://www.codecraft.gr</authorUrl>
        <version>1.0</version>
        <description>Some description.</description>
        <files>
                <filename plugin="aftercheckout">aftercheckout.php</filename>
                <filename>index.html</filename>
        </files>
</extension>


I packed them up into a zipfile named aftercheckout.zip and I installed the plugin succesffully.
However the methods do not seem to trigger when I add something to the cart or when i confirm the order. Is it something that I am missing here?
Thank you
Title: Re: Documentation for plugin development
Post by: themhz on October 12, 2012, 18:12:22 PM
Quote from: themhz on October 12, 2012, 16:03:38 PM
I have managed to create a plugin with the following code


<?php

// no direct access
defined('_JEXEC') or die;

if (!
class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS DS 'vmcustomplugin.php');

class 
plgAftercheckout extends vmCustomPlugin
{
 public function __construct (&$subject$config=array()) {
  echo "ok";
         
parent::__construct($subject$config);
         
$this->_path JPATH_PLUGINS.DS.$this->getName();
         
JPlugin::loadLanguage('plg_vmextended_'.$this->getName());
     }
 
   public function 
plgVmOnDisplayProductFE$field$param$product$idx){
   
echo "plgVmOnDisplayProductFE fired";
die();
   } 
 
   public function 
plgVmOnAddToCart(&$product)
{
    echo "plgVmOnAddToCart fired";
die();

}

public function plgVmConfirmedOrder($cart$order)
{
echo "plgVmConfirmedOrder fired";
die();
}

}

?>


I also created the xml file like this


<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="vmcustom">
        <name>plg_aftercheckout</name>
        <author>themhz</author>
        <creationDate>June 18th, 2012</creationDate>
        <copyright>CodeCraft.gr</copyright>
        <license>GNU General Public License</license>
        <authorEmail>themhz@codecraft.gr</authorEmail>
        <authorUrl>http://www.codecraft.gr</authorUrl>
        <version>1.0</version>
        <description>Some description.</description>
        <files>
                <filename plugin="aftercheckout">aftercheckout.php</filename>
                <filename>index.html</filename>
        </files>
</extension>


I packed them up into a zipfile named aftercheckout.zip and I installed the plugin succesffully.
However the methods do not seem to trigger when I add something to the cart or when i confirm the order. Is it something that I am missing here?
Thank you

I also found this plugin that already works, in the vmcustom stockable and I found this method "public function plgVmOnAddToCart(&$product){" than fires when ever I add something into the cart. I copied that method to my class plugin but its does not fire from my class :(.
Title: Re: Documentation for plugin development
Post by: themhz on October 12, 2012, 20:35:53 PM
Quote from: themhz on October 12, 2012, 18:12:22 PM
Quote from: themhz on October 12, 2012, 16:03:38 PM
I have managed to create a plugin with the following code


<?php

// no direct access
defined('_JEXEC') or die;

if (!
class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS DS 'vmcustomplugin.php');

class 
plgAftercheckout extends vmCustomPlugin
{
 public function __construct (&$subject$config=array()) {
  echo "ok";
         
parent::__construct($subject$config);
         
$this->_path JPATH_PLUGINS.DS.$this->getName();
         
JPlugin::loadLanguage('plg_vmextended_'.$this->getName());
     }
 
   public function 
plgVmOnDisplayProductFE$field$param$product$idx){
   
echo "plgVmOnDisplayProductFE fired";
die();
   } 
 
   public function 
plgVmOnAddToCart(&$product)
{
    echo "plgVmOnAddToCart fired";
die();

}

public function plgVmConfirmedOrder($cart$order)
{
echo "plgVmConfirmedOrder fired";
die();
}

}

?>


I also created the xml file like this


<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="vmcustom">
        <name>plg_aftercheckout</name>
        <author>themhz</author>
        <creationDate>June 18th, 2012</creationDate>
        <copyright>CodeCraft.gr</copyright>
        <license>GNU General Public License</license>
        <authorEmail>themhz@codecraft.gr</authorEmail>
        <authorUrl>http://www.codecraft.gr</authorUrl>
        <version>1.0</version>
        <description>Some description.</description>
        <files>
                <filename plugin="aftercheckout">aftercheckout.php</filename>
                <filename>index.html</filename>
        </files>
</extension>


I packed them up into a zipfile named aftercheckout.zip and I installed the plugin succesffully.
However the methods do not seem to trigger when I add something to the cart or when i confirm the order. Is it something that I am missing here?
Thank you

I also found this plugin that already works, in the vmcustom stockable and I found this method "public function plgVmOnAddToCart(&$product){" than fires when ever I add something into the cart. I copied that method to my class plugin but its does not fire from my class :(.

Ok I found the solution. The problem was the class name. In the joomla 1.5 documentation http://docs.joomla.org/Creating_a_Plugin_for_Joomla_1.5 it mentions that the class name must follow this rule: class plg extends JPlugin But this is not mentiond in any joomla 2.5 documentation, since it is probably considered " an already known rule ". So my solution was to change the class name from

class plgVmAftercheckout extends vmCustomPlugin {

to

class plgVmCustomAftercheckout extends vmCustomPlugin {

"Custom" because the plugin belongs to a specific group called Custom. So we need to mention the group name in order to make those hook methods observe the events.
Title: Re: Documentation for plugin development
Post by: theodore88 on November 29, 2012, 06:13:34 AM
Is it possible to add some custom parameters in the admin view without hacking the core?
My goal is to call an SQL query for active payment methods

Something like this http://docs.joomla.org/SQLMultiSelectX (http://docs.joomla.org/SQLMultiSelectX)
Title: Re: Documentation for plugin development
Post by: veeco on November 29, 2012, 13:23:14 PM
I compare between the plugin events/method in wiki and in bundled package and found that there several undocumented trigger... does the wiki content is the latest one ?
Title: Re: Documentation for plugin development
Post by: jenkinhill on May 22, 2013, 23:15:16 PM
That is an old link. Try http://docs.virtuemart.net/component/flexicontent/34-development/84-extension-plugins.html
Title: Re: Documentation for plugin development
Post by: sotoz on October 17, 2013, 13:30:19 PM
Where can I find the list for all the Events supported by vm?
I need to make a plugin for virtuemart but the documentation at https://dev.virtuemart.net/projects/virtuemart/wiki/Developing_a_module_or_plugin_for_VirtueMart_2 is not helpful at all.
I managed to make a vmcustom plugin and the constructor gets called correctly in the main component but I would like to know how can I trigger events that show the vm cart.

thank you in advance.
Title: Re: Documentation for plugin development
Post by: whisky on November 08, 2013, 16:28:37 PM
I do not understand, if the last answer is a response or a not yet filtered spam.

But I'am on the same side of trying to find proper developer documentation and the least I can say is that, the 'new' site as very insufficient documentation content compared to what is qualified here as 'old' documentation.

So from other developers could we list best documentation links ??

1) I found that reading the code from the aio is the best documentation by deciphering code commonalities and onXXX callbacks function from vm engine
2) the http://dev.virtuemart.net/projects/virtuemart/wiki is still the best source of technical information

found the best explanation for custom fields here : http://www.spiralscripts.co.uk/Table/How-To/Joomla-Tips/

Does anyone have some advice to feed this thread ?

Thanks in advance.
Title: Re: Documentation for plugin development
Post by: jaycee201827 on November 09, 2013, 02:23:46 AM
I am new to this payment gateway specially in VirtueMart. and I am planning to integrate it to our website and make own payment plugin, I am searching for VirtueMart 2.0 documentation or tutorials on how can i do it. I was reading this link: http://dev.virtuemart.net/projects/1/wiki/plugin_system
but it seems that samples are for Joomla 1.5-1.7.


VirtueMart: 2.0.24
Joomla: 2.5.16
PHP: 5.3

Sorry for a newbie question  ;D
Title: Re: Documentation for plugin development
Post by: jenkinhill on November 09, 2013, 13:04:23 PM
http://docs.virtuemart.net/component/flexicontent/34-development/84-extension-plugins.html
Title: Re: Documentation for plugin development
Post by: prince831 on December 03, 2013, 09:04:03 AM
Hello Everybody,
I am new to Joomla virtuemart, i need to develop a plugin for a credit card payment gateway.
Can anybody help me to find step by step plugin development tutorials for virtuemart. I searched a-lot but didn't find any thing helpful yet.
Thanks in advance.
Title: Re: Documentation for plugin development
Post by: Il_maca on June 22, 2016, 19:07:02 PM
WHY?
http://dev.virtuemart.net/projects/virtuemart/wiki/Calculation_Plugins

I 'smadonnato' for several hours to find, in a thirdy part plugin, the calculation hook that i was looking for....
  :D :D :D
Title: Re: Documentation for plugin development
Post by: alatak on June 23, 2016, 09:30:23 AM
Hello

The best is to look at the different examples provided in the VirtueMart core.
Title: Re: Documentation for plugin development
Post by: Adwans on August 31, 2016, 13:01:38 PM
Hello!
Are there any changes in XML file - regarding plugin installation - recently?
I cannot install my plugin after upgrading to Joomla 3.6 and VM 3.0.16.
<?xml version="1.0" encoding="UTF-8" ?>
<extension version="3.0"  type="plugin" group="vmpayment" method="upgrade">

I got:
QuoteWarning
JInstaller: :Install: Can't find Joomla XML setup file.
Error
Unable to find install package
Title: Re: Documentation for plugin development
Post by: GJC Web Design on August 31, 2016, 13:04:07 PM
just check a current bundled payment plugin xml for any change
Title: Re: Documentation for plugin development
Post by: Adwans on August 31, 2016, 23:11:52 PM
oki doki, I found my little mistake - thanks, GJC. 
You had inspired me with that  "dummy-payment" plugin, which could allow to change order status form a URL.  from here:
https://forum.virtuemart.net/index.php?topic=129413.0 (https://forum.virtuemart.net/index.php?topic=129413.0)
Regards.