Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(oneoff): resolved for 8.8 #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions hooks/OneOffProductsDomainRequireProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@

use WHMCS\Database\Capsule;

define('kt_onetimeProducts', array()); // Array of product IDs to treat as "one-off" (customer is not allowed to order the same product multiple times
define('kt_onetimeProductGroups', array()); // Same as above but for product group IDs. All producs inside such groups are treated as one-off
define('kt_onetimeProducts', array()); // Written as array('##','##') Array of product IDs to treat as "one-off" (customer is not allowed to order the same product multiple times
define('kt_onetimeProductGroups', array()); // Written as array('##','##') Same as above but for product group IDs. All producs inside such groups are treated as one-off
define('kt_firstTimerTollerance', true); // Product-based restrictions are disabled for new customers placing their first order with you
define('kt_notRepeatable', true); // If a customer already has a one-off product, he can't purchase further one-offs ($firstTimerTollerance is ignored)
define('kt_domainRequiresProduct', false); // Domain purchase is allowed only if any of the following conditions is met: a) Customer has an existing product/service (`Pending` and `Terminated` don't count) b) Customer is purchasing a domain and a product/service
define('kt_domainRequiresProduct', true); // Domain purchase is allowed only if any of the following conditions is met: a) Customer has an existing product/service (`Pending` and `Terminated` don't count) b) Customer is purchasing a domain and a product/service
define('kt_onClientRegister', false); // Ordering one-off products is possible only for clients who registered within the last X number of days. Leave false to disable
define('kt_promptRemoval', 'modal'); // Choose one of the following options: "bootstrap-alert", "modal", "js-alert" (works on Six template. Change jQuery selectors accordingly for custom templates)
define('kt_promptRemoval', 'bootstrap-alert'); // Only 'bootstrap-alert' works with redirects. Choose one of the following options: "bootstrap-alert", "modal", "js-alert" (works on Six template. Change jQuery selectors accordingly for custom templates)
define('kt_textDisallowed', 'The Product/Service can be purchased only once.'); // Don't forget to "\" escape
define('kt_textRequireProduct', 'Domain purchase require an active Product/Service.'); // Don't forget to "\" escape


add_hook('ClientAreaHeadOutput', 1, function($vars)
{
if ($_SESSION['cart']['products'] AND (kt_onetimeProductGroups OR kt_onetimeProducts))
Expand Down Expand Up @@ -58,7 +59,7 @@

foreach ($_SESSION['cart']['products'] as $k => $v)
{
if (in_array($v['pid'], $groupByProductsKeys) AND in_array($v['pid'], $disallowedPids))
if (isset($v['pid'], $groupByProductsKeys) AND isset($v['pid'], $disallowedPids))
{
if ($i > 1)
{
Expand All @@ -84,7 +85,7 @@

foreach ($_SESSION['cart']['products'] as $k => $v)
{
if (in_array($v['pid'], $userProducts))
if ($v['pid'] == $userProducts)
{
$removedFromCart = true;
unset($_SESSION['cart']['products'][$k]);
Expand Down