Files
interblue.pl/modules/przelewy24/classes/Przelewy24Tools.php
2024-10-25 14:16:28 +02:00

36 lines
907 B
PHP

<?php
/**
* @author Przelewy24
* @copyright Przelewy24
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class Przelewy24Tools
{
/**
* Check if cart is valid for customer.
*
* @param Customer $customer
* @param Cart $cart
*
* @return bool
*/
public static function checkCartForCustomer($customer, $cart)
{
$cartCustomer = new Customer($cart->id_customer);
$isGuest = $cartCustomer->isGuest();
if ($isGuest) {
/* The test below do now work for guests and is useless. */
return true;
}
return $customer
&& $customer->id === (int) $cart->id_customer
&& $customer->id_shop === $cart->id_shop
&& (0 === (int) $cart->id_shop_group || (int) $customer->id_shop_group === (int) $cart->id_shop_group);
}
}