Hi,
I'm trying to figure out how to create custom virtuemart/joomla plugin that calls out custom functions.
It should call out function:
after user makes order
after user cancels order
after order payment fails
after payment is successful
and maybe others if possible, i would not like to hardcode cause then updating would be harder.
My code is like this and only first section works.
public function plgVmConfirmedOrder($cart, $order)
{
echo '<h1>plgVmConfirmedOrder</h1>';
echo '<script type="text/javascript">alert("plgVmConfirmedOrder")</script>';
// This one works
}
public function plgVmOnUserPaymentCancel()
{
echo '<h1>plgVmOnUserPaymentCancel</h1>';
echo '<script type="text/javascript">alert("plgVmOnUserPaymentCancel")</script>';
}
public function plgVmOnPaymentResponseReceived()
{
echo '<h1>plgVmOnPaymentResponseReceived</h1>';
echo '<script type="text/javascript">alert("plgVmOnPaymentResponseReceived")</script>';
}
public function plgVmOnPaymentNotification()
{
echo '<h1>plgVmOnPaymentNotification</h1>';
echo '<script type="text/javascript">alert("plgVmOnPaymentNotification")</script>';
}
public function plgVmOnConfirmedOrderStorePaymentData()
{
echo '<h1>plgVmOnConfirmedOrderStorePaymentData</h1>';
echo '<script type="text/javascript">alert("plgVmOnConfirmedOrderStorePaymentData")</script>';
}
public function plgVmOnDisplayProductFE()
{
echo "<h1>plgVmOnDisplayProductFE</h1>";
echo '<script type="text/javascript">alert("plgVmOnDisplayProductFE")</script>';
}
public function plgVmOnAddToCart()
{
echo "<h1>plgVmOnAddToCart</h1>";
echo '<script type="text/javascript">alert("plgVmOnAddToCart");</script>';
}
public function plgVmOnPaymentSelectCheck()
{
echo "<h1>plgVmOnPaymentSelectCheck</h1>";
echo '<script type="text/javascript">alert("plgVmOnPaymentSelectCheck");</script>';
}
First time virtuemart user, thanks
Add a new paiement (or shipment in some case)plugin and don't check if it is right payment so it's always called.
Quote from: Studio 42 on August 17, 2016, 13:39:08 PM
Add a new paiement (or shipment in some case)plugin and don't check if it is right payment so it's always called.
Thanks, for the reply. Could you tell me whan is the right star for payment plugin cause i tried it but it didn't work.
if (!class_exists('vmCustomPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
}
class plgVmCustomKauppakanava extends vmCustomPlugin
{
EDIT: Got it working as payment plugin. Now these two functions work. But i need more. I need ATLEAST one that calls a function when payment is complete.
public function plgVmConfirmedOrder($cart, $order)
{
echo '<h1>plgVmConfirmedOrder</h1>';
echo '<script type="text/javascript">alert("plgVmConfirmedOrder")</script>';
// Vahvista tilaus
}
public function plgVmOnUserPaymentCancel()
{
echo '<h1>plgVmOnUserPaymentCancel</h1>';
echo '<script type="text/javascript">alert("plgVmOnUserPaymentCancel")</script>';
// Peruuta tilaus
}
If i remember good it's plgVmOnPaymentResponseReceived
Check plugin/vmpaiment/standard folder for the most used trigger, all triggered function begin with "plgVm"
This is the right trigger, when the payment providers sends something.
I think he needs plgVmOnUpdateOrderPayment
Hi All,
I developed an plugin in order to catch "plgVmOnUpdateOrderPayment", but will never invoked.
Herewith the code:
jimport ('joomla.plugin.plugin');
if (!class_exists('vmCustomPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
}
class plgVmcustomAfterOrderConfirmedHook extends vmCustomPlugin {
function plgVmConfirmedOrder($cart, $order){
DO ACTIONS
}
function plgVmOnUpdateOrderPayment($cart, $order){
DO ACTIONS
}
}
What I miss?
thanks a lot
Stupid question, have you published the plugin in Joomla ?
Yes, of course 8)
The problem is perhaps here :
class plgVmcustomAfterOrderConfirmedHook extends vmCustomPlugin {
I'm not sure that vmCustom Plugins are always loaded here.
If you only call it for this 2 triggers, perhaps try to convert it to a shipment or payment plugin
I tried also as vmPayment and as System plugins... but doesn't been invoked.
Here below the vmPayment statement:
<?php
defined ('_JEXEC') or die('Direct Access to ' . basename (__FILE__) . ' is not allowed.');
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
jimport ('joomla.plugin.plugin');
if (!class_exists ('vmPSPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php');
}
class plgVmcustomAfterOrderConfirmedHook extends vmPSPlugin {
function __construct (& $subject, $config) {
parent::__construct ($subject, $config);
}
function plgVmConfirmedOrder($cart, $order){
DO SOMETHING
}
function plgVmOnUpdateOrderPayment($cart, $order){
DO SOMETHING
}
}
?>
I use VirtueMart 3.0.19.3 Blue Corvus 9439 & Joomla! 3.6 and the plugin is enable on "Extensions-Plugins" section.
Many thanks for your support
You have to install it in the right folder and use right class name.
Main file
JOOMLAROOT\plugins\vmpayment\confirmedhook\confirmedhook.php
basic code for the file confirmedhook.php
<?php
defined ('_JEXEC') or die();
if (!class_exists ('vmPSPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php');
}
class plgVmPaymentConfirmedHook extends vmPSPlugin {
function plgVmConfirmedOrder($cart, $order){
//DO ACTIONS
}
function plgVmOnUpdateOrderPayment($cart, $order){
// DO ACTIONS
}
}
THAAAAANKS, with the right classname it works.... finally :) :D
best regards