Pixelly
Client Panel
  • Home
  • Products
  • Services
  • Portfolio
  • Company
    • About
    • Contact
    • Terms of Service
    • Product Documents
Pixelly
  • Home
  • Products
  • Services
  • Portfolio
  • Company
    • About
    • Contact
    • Terms of Service
    • Product Documents

WordPress WHMCS Kit (WWK)

  • Getting Started
  • Usage Guide
  • Advanced Usage
  • Elementor Pricing Table Integration
  • Release Note

Ticket Campaigns for WHMCS

  • Getting Started
  • Usage Guide
  • Release Note

Ticket as Provisioner for WHMCS

  • Getting Started
  • Usage Guide
  • Release Note

MailerSend Mail Provider for WHMCS

  • Getting Started
  • Release Note

Quota Manager for WHMCS

  • Getting Started
  • Usage Guide
  • Release Note

Cashback Promotions for WHMCS

  • Getting Started
  • Usage Guide
  • Advanced Usage
  • Release Note

Advanced Usage

1 min read

In this section, you will learn about advanced topics.

Automatic Cancellation of Pending Cashback #

Since in the WHMCS invoice refunding mechanism, it is not possible to accurately specify the service that the operator intends to return, it is not possible to automatically cancel the cashback at the time of the invoice refunding in a technically precise manner. But if you would like to cancel the pending cashback when the invoice is refunded fully or partially, you can use the following method. 

Since in the WHMCS invoice refunding mechanism, it is not possible to accurately specify the service that the operator intends to return, it is not possible to automatically cancel the cashback at the time of the invoice refunding in a technically precise manner. But if you would like to cancel the pending cashback when the invoice is refunded fully or partially, you can use the following hook. 

Create a WHMCS hook file in the following path:

/includes/hooks/auto-cancel-pending-cashback.php

Then paste the following snippet inside it:

<?php
function cancelPendingCashback($invoice_id){
	Capsule::table("mod_cashback_logs")
	->join("tblinvoiceitems", 'invoice_item_id', '=', 'tblinvoiceitems.id')
	->join("tblinvoices", 'tblinvoices.id', '=', 'tblinvoiceitems.invoiceid')
	->where("tblinvoices.id", $invoice_id)
	->where("mod_cashback_logs.status", 'pending')
	->update([
		'mod_cashback_logs.status'=> 'cancelled'
	]);
}

// Handle refund by credit
add_hook('UpdateInvoiceTotal', 1, function ($vars) {
	$invoice = localAPI('GetInvoice', array(
		'invoiceid' => $vars['invoiceid'],
	));

	if ($invoice['Refunded'] != false || $invoice['credit'] != 0 || $invoice['balance'] != $invoice['total'])
		return;
	
	cancelPendingCashback($vars['invoiceid']);
});

// Handle manual refund and refund through Gateway  
add_hook('InvoiceRefunded', 1, function ($vars) {
	cancelPendingCashback($vars['invoiceid']);	
});

?>


Table of Contents
  • Automatic Cancellation of Pending Cashback
Logo
  • Home
  • Services
  • Portfolio
  • Documentation
  • About
  • Contact
© Copyright 2025 Pixlley
We use cookies from third party services for marketing activities to offer you a better experience.Accept and close