1<?php
2use WHMCS\Database\Capsule;
3
4// Hide the Checkout Stripe gateway in the cart for users in group 1
5function cart_gateway_removal_for_group1($vars) {
6 if ($vars['templatefile'] == 'viewcart') {
7 $gateways = $vars['gateways'];
8
9 $client = Capsule::table('tblclients')->where('id', $_SESSION["uid"])->first();
10 $groupid = $client->groupid;
11
12 // If the client is in group 1, remove Checkout Stripe gateway
13 if ($groupid === 1) {
14 unset($gateways['stripeGateway']);
15 }
16
17 return array("gateways" => $gateways);
18 }
19}
20add_hook("ClientAreaPageCart", 1, "cart_gateway_removal_for_group1");
21
22// Hide the Checkout Stripe gateway in the invoice view for users in group 1
23add_hook('ClientAreaPageViewInvoice', 1, function($vars) {
24 $gatewaydropdown = $vars['gatewaydropdown'];
25
26 $client = Capsule::table('tblclients')->where('id', $_SESSION["uid"])->first();
27 $groupid = $client->groupid;
28
29 // If the client is in group 1, remove Checkout Stripe gateway
30 if ($groupid === 1) {
31 $cashapp = '<option value="stripeGateway">Credit Card</option>';
32 $gatewaydropdown = str_replace($cashapp, '', $gatewaydropdown);
33 }
34
35 return array("gatewaydropdown" => $gatewaydropdown);
36});
37
38// Hide the Checkout Stripe gateway in the payment methods on profile page for users in group 1
39add_hook('ClientAreaPageProfile', 1, function($vars) {
40 $paymentmethods = $vars['paymentmethods'];
41
42 $client = Capsule::table('tblclients')->where('id', $_SESSION["uid"])->first();
43 $groupid = $client->groupid;
44
45 // If the client is in group 1, remove Checkout Stripe gateway
46 if ($groupid === 1) {
47 unset($paymentmethods['stripeGateway']);
48 }
49
50 return array("paymentmethods" => $paymentmethods);
51});
52?>