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

From aMember Pro Documentation
Jump to: navigation, search
Line 5: Line 5:
 
In case customer buy this product then he received defined number of credits.
 
In case customer buy this product then he received defined number of credits.
  
[[File:helpdesk-ticket-sell-product.png|200px]]
+
[[File:helpdesk-ticket-sell-product.png|300px]]
  
 
On Helpdesk tab user will have ability to submit new ticket only if he has credits.
 
On Helpdesk tab user will have ability to submit new ticket only if he has credits.
Line 11: Line 11:
 
User can not reply to ticket if you close it from admin interface.
 
User can not reply to ticket if you close it from admin interface.
  
[[File:helpdesk-ticket-sell-submit.png|200px]]
+
[[File:helpdesk-ticket-sell-submit.png|300px]]
  
 
Each time user open new ticket it reduce his balance by 1 credit.
 
Each time user open new ticket it reduce his balance by 1 credit.
 
User can see history of credits use. In comment he will see ticket id.
 
User can see history of credits use. In comment he will see ticket id.
  
[[File:helpdesk-ticket-sell-history.png|200px]]
+
[[File:helpdesk-ticket-sell-history.png|300px]]
  
 
In this example I assume one ticket cost 1 credits.
 
In this example I assume one ticket cost 1 credits.
Line 45: Line 45:
 
''aMember Cp -> Users -> Browse Users -> (edit) -> Credits''
 
''aMember Cp -> Users -> Browse Users -> (edit) -> Credits''
  
[[File:helpdesk-ticket-sell-admin.png|200px]]
+
[[File:helpdesk-ticket-sell-admin.png|300px]]

Revision as of 06:55, 16 December 2016

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

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

Helpdesk-ticket-sell-product.png

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.

Helpdesk-ticket-sell-submit.png

Each time user open new ticket it reduce his balance by 1 credit. User can see history of credits use. In comment he will see ticket id.

Helpdesk-ticket-sell-history.png

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:

$credit_plugin = Am_Di::getInstance()->plugins_misc->loadGet('credits');
 
Am_Di::getInstance()->hook->add('gridHelpdeskInitGrid', function(Am_Event_Grid $e) use ($credit_plugin) {
    if (!defined('AM_ADMIN')) {
        if ($credit_plugin->balance() <= 0) {
            $e->getGrid()->actionDelete('ticket');
        }
    }
});
 
Am_Di::getInstance()->hook->add(Bootstrap_Helpdesk::EVENT_TICKET_AFTER_INSERT, function(Am_Event $e) use ($credit_plugin) {
    if (!defined('AM_ADMIN')) {
        $ticket = $e->getTicket();
        $credit_plugin->debit(1, "Ticket #{$ticket->ticket_mask}", $ticket->user_id, $ticket->pk());
    }
});

You can see user credits history and debit/credit manually from admin interface as well. aMember Cp -> Users -> Browse Users -> (edit) -> Credits

Helpdesk-ticket-sell-admin.png