Skip to content

Instantly share code, notes, and snippets.

@Pierowheelz
Pierowheelz / page_expiry.js
Last active March 24, 2023 02:49
Display a popup (with id="popup_expiredpage") when a page has expired
const wb_expiry = new function(){
self.load_time = 99999999999999; //set automatically
self.page_expiry = 60; //minutes
self.reload_timer = {};
this.hidden = 'hidden';
this.vis_change = 'visibilitychange';
this.hidden_state = 'visibilityState';
this.currently_visible = true;
@Pierowheelz
Pierowheelz / smoothscroll.js
Last active November 4, 2018 22:01 — forked from ichadhr/smoothscroll.js
Simple smooth scroll Javascript
// Smoothscroll
function ssc_init() {
if (!document.body) return;
var e = document.body;
var t = document.documentElement;
var n = window.innerHeight;
var r = e.scrollHeight;
ssc_root = document.compatMode.indexOf("CSS") >= 0 ? t : e;
ssc_activeElement = e;
ssc_initdone = true;
@Pierowheelz
Pierowheelz / set_sub_account_info.php
Created June 14, 2018 22:43
A WHMCS hook to copy Company Name and Address from Clients to Contacts (sub-accounts) upon creation of a new Contact. This ensures that invoices always show the correct Company Name and Address.
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
/*
* Copies account details from parent accounts to sub-accounts
*/
add_hook('ContactAdd', 1, "wb_setup_sub_accounts");
@Pierowheelz
Pierowheelz / mark_zero_invoices_paid.php
Created June 14, 2018 22:39
A hook for WHMCS which marks invoices which have received payment as paid, where the WHMCS system doesn't automatically mark them paid. I found that if manually associating a transaction with an invoice number in WHMCS, the invoice is not marked as paid even when there is zero total remaining. This fixes that.
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
function wb_mark_zero_invoices_paid(){
//get all unpaid invoices
$unpaid_invoices = Capsule::table('tblinvoices')->where('status', 'Unpaid')->get();
foreach( $unpaid_invoices as $inv ){
@Pierowheelz
Pierowheelz / disable_zero_invoices.php
Created June 14, 2018 22:36
A hook for WHMCS which disables email notifications for invoices with a zero total. Modified from existing code to use the new Capsule database handler ( http://www.whmcsjet.com/how-to-disable-invoice-generation-for-0-00-invoices/ ).
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
function disable_00_invoices($vars) {
$merge_fields = array();
$email_template_name = $vars['messagename']; # Email template name being sent
@Pierowheelz
Pierowheelz / update_billing_emails.php
Last active May 12, 2021 06:40
Forces WHMCS to only send invoice related emails to the billing contact. This is done by temporarily updating the primary account's email address and contact info to that of the billing contact (ie. it's a hack). Add this to your .../includes/hooks/ folder.
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
/*
* Temporarily updates the primary account's email address to that of the
* company's Billing contact upon creation of a new invoice so that invoices
* are not sent to the primary account holder.