Newer
Older
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* This file contains QUI\ERP\Utils\Shop
*/
namespace QUI\ERP\Utils;
use QUI;
/**
* Class Shop
*
* @package QUI\ERP\Utils
*/
class Shop
{
/**
* @var string
*/
protected static $type = null;
/**
* Return the shop business type
*
* @return array|string
*/
public static function getBusinessType()
{
if (self::$type !== null) {
return self::$type;
}
try {
$Config = QUI::getPackage('quiqqer/erp')->getConfig();
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
// default
self::$type = 'B2C';
return self::$type;
}
self::$type = $Config->get('general', 'businessType');
switch (self::$type) {
case 'B2C':
case 'B2B':
case 'B2C-B2B':
case 'B2B-B2C':
return self::$type;
}
self::$type = 'B2C';
return self::$type;
}
/**
* Is the shop a b2b shop?
* To know if the shop is only a b2b shop, please use isOnlyB2B()
*
* @return bool
*/
public static function isB2B()
{
return \strpos(self::getBusinessType(), 'B2B') !== false;
}
/**
* Is the shop an b2c shop?
* To know if the shop is only a b2c shop, please use isOnlyB2C()
*
* @return bool
*/
public static function isB2C()
{
return \strpos(self::getBusinessType(), 'B2C') !== false;
/**
* Is the shop an b2c and b2b shop, but b2c is more important
*
* @return bool
*/
public static function isB2BPrioritized()
{
if (self::isB2B() === false) {
return false;
}
return \strpos(self::getBusinessType(), 'B2B') === 0;
}
/**
* Is the shop an b2c and b2b shop, but b2c is more important
*
* @return bool
*/
public static function isB2CPrioritized()
{
if (self::isB2C() === false) {
return false;
}
return \strpos(self::getBusinessType(), 'B2C') === 0;
}
/**
* Is the shop only b2b?
*
* @return bool
*/
public static function isOnlyB2B()
{
return self::getBusinessType() === 'B2B';
}
/**
* Is the shop only b2c?
*
* @return bool
*/
public static function isOnlyB2C()
{
return self::getBusinessType() === 'B2C';
}
/**
* Is the shipping module installed?
*
* @return bool
*/
public static function isShippingInstalled()
{
try {
QUI::getPackageManager()->getPackage('quiqqer/shipping');
} catch (\Exception $Exception) {
return false;
}
return true;
}