Difference between revisions of "How to sell tickets in build in Helpdesk module"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "In order to implement such feature you will need one additional plugin - '''credits'''. This plugin is free for active customers. Then in product settings you can setup numb...")
 
Line 17: Line 17:
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>
<?php
 
 
Am_Di::getInstance()->hook->add(Bootstrap_Helpdesk::EVENT_TICKET_AFTER_INSERT, 'myTicketAfterInsert');
 
Am_Di::getInstance()->hook->add(Bootstrap_Helpdesk::EVENT_TICKET_AFTER_INSERT, 'myTicketAfterInsert');
  

Revision as of 03:03, 3 November 2015

In order to implement such feature you will need one additional plugin - credits. This plugin is free for active customers.

Then in product settings you can setup number of credits. In case customer buy this product then he received defined number of credits.

On Helpdesk tab user will have ability to submit new ticket only if he has credits. User still will be able to see ticket that he opened before. User can not reply to ticket if you close it from admin interface.

Each time user open new ticket code that you can see below use one credit from user balance. User can see history of credits use. In comment he will see ticket id and subject.

In this example I assume one ticket cost 1 credits. Number of credits by product you can configure within product settings.

Add this code to site.php file:

Am_Di::getInstance()->hook->add(Bootstrap_Helpdesk::EVENT_TICKET_AFTER_INSERT, 'myTicketAfterInsert');
 
function myTicketAfterInsert(Am_Event $e) {
    $ticket = $e->getTicket();
    $user = $ticket->getUser();
    $e->getDi()->plugins_misc->loadGet('credits')->debit(1, sprintf('#%s: %s', $ticket->ticket_mask, $ticket->subject), $user->pk()); }
 
Am_Di::getInstance()->hook->add('gridHelpdeskInitGrid', 'myTicketGrid');
 
function myTicketGrid(Am_Event_Grid $e)
{
    if (!defined('AM_ADMIN') || !AM_ADMIN) {
        if (!$e->getDi()->plugins_misc->loadGet('credits')->balance($e->getDi()->user->pk()))
            $e->getGrid()->actionDelete('ticket');
    }
}