This repository was archived by the owner on Feb 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathhooks.php
More file actions
44 lines (39 loc) · 1.28 KB
/
hooks.php
File metadata and controls
44 lines (39 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
// Copyright 1999-2016. Parallels IP Holdings GmbH.
/**
* Plesk Moodule Hooks
*/
use Illuminate\Database\Capsule\Manager as Capsule;
add_hook('ShoppingCartValidateCheckout', 1, function ($vars)
{
require_once 'lib/Plesk/Translate.php';
require_once 'lib/Plesk/Config.php';
require_once 'lib/Plesk/Utils.php';
$translator = new Plesk_Translate();
$accountLimit = (int)Plesk_Config::get()->account_limit;
if (0 >= $accountLimit) {
return array();
}
$accountCount = ('new' == $vars['custtype']) ? 0 : Plesk_Utils::getAccountsCount($vars['userid']);
$pleskAccountsInCart = 0;
foreach($_SESSION['cart']['products'] as $product) {
$currentProduct = Capsule::table('tblproducts')->where('id', $product['pid'])->first();
if ('plesk' == $currentProduct->servertype) {
$pleskAccountsInCart++;
}
}
if (!$pleskAccountsInCart) {
return array();
}
$summaryAccounts = $accountCount + $pleskAccountsInCart;
$errors = array();
if (0 < $accountLimit && $summaryAccounts > $accountLimit) {
$errors[] = $translator->translate(
'ERROR_RESTRICTIONS_ACCOUNT_COUNT',
array(
'ACCOUNT_LIMIT' => $accountLimit
)
);
}
return $errors;
});