Skip to content

Commit

Permalink
Amend & merge PR #18 << bakkbone/master (GUI display) v3.0.2
Browse files Browse the repository at this point in the history
Add merge field to list
  • Loading branch information
lsthompson authored May 15, 2024
2 parents 398c166 + fa0513c commit 11aad99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion includes/hooks/bpay_getCRN_byCUST.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// BPAY for WHMCS - (v3.0.1) - Reliable CRN Generation & Handling (this file: GENERATION BY CUSTOMER ID)
// BPAY for WHMCS - (v3.0.2) - Reliable CRN Generation & Handling (this file: GENERATION BY CUSTOMER ID)
//
// Adds a BPAY CRN with a MOD10 version 5 check digit for client-related emails and returns it as a merge field.
// You can then use the {$bpay_reference} merge field in WHMCS Admin > Email Templates, to render the CRN.
Expand Down Expand Up @@ -30,6 +30,7 @@
die('This file cannot be accessed directly');
}

// Customer ID generation method requires DB to cross-reference unique (rel) ID
use WHMCS\Database\Capsule;

/**
Expand Down Expand Up @@ -62,6 +63,7 @@ function addMod10v5CheckDigit($number) {
return $number . $checkdigit;
}

// Suffix the check digit through the above function; then return the Merge Field
add_hook('EmailPreSend', 1, function($vars) {
// Initialise merge fields array
$merge_fields = [];
Expand Down Expand Up @@ -89,3 +91,10 @@ function addMod10v5CheckDigit($number) {
// Whether empty or filled, return to-spec
return $merge_fields;
});

// Present the Merge Field in the GUI, when editing Email Templates
add_hook('EmailTplMergeFields', 1, function($vars) {
$merge_fields = [];
$merge_fields['bpay_reference'] = "BPAY Reference (CRN)";
return $merge_fields;
});
10 changes: 9 additions & 1 deletion includes/hooks/bpay_getCRN_byINV.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// BPAY for WHMCS - (v3.0.1) - Reliable CRN Generation & Handling (this file: GENERATION BY INVOICE ID)
// BPAY for WHMCS - (v3.0.2) - Reliable CRN Generation & Handling (this file: GENERATION BY INVOICE ID)
//
// Adds a BPAY CRN with a MOD10 version 5 check digit for client-related emails and returns it as a merge field.
// You can then use the {$bpay_reference} merge field in WHMCS Admin > Email Templates, to render the CRN.
Expand Down Expand Up @@ -60,6 +60,7 @@ function addMod10v5CheckDigit($number) {
return $number . $checkdigit;
}

// Suffix the check digit through the above function; then return the Merge Field
add_hook('EmailPreSend', 1, function($vars) {
// Initialise merge fields array
$merge_fields = [];
Expand All @@ -82,3 +83,10 @@ function addMod10v5CheckDigit($number) {
// Whether empty or filled, return to-spec
return $merge_fields;
});

// Present the Merge Field in the GUI, when editing Email Templates
add_hook('EmailTplMergeFields', 1, function($vars) {
$merge_fields = [];
$merge_fields['bpay_reference'] = "BPAY Reference (CRN)";
return $merge_fields;
});

0 comments on commit 11aad99

Please sign in to comment.