forked from concretecms-community-store/community_store
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.php
More file actions
executable file
·155 lines (134 loc) · 6.87 KB
/
controller.php
File metadata and controls
executable file
·155 lines (134 loc) · 6.87 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
namespace Concrete\Package\CommunityStore;
use Package;
use Concrete\Package\CommunityStore\Src\CommunityStore\Payment\Method as PaymentMethod;
use Concrete\Package\CommunityStore\Src\CommunityStore\Shipping\Method\ShippingMethodType as ShippingMethodType;
use Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Installer;
use Whoops\Exception\ErrorException;
use Route;
use Asset;
use AssetList;
use URL;
use Core;
class Controller extends Package
{
protected $pkgHandle = 'community_store';
protected $appVersionRequired = '5.7.5';
protected $pkgVersion = '1.3.2';
public function getPackageDescription()
{
return t("Add a store to your site");
}
public function getPackageName()
{
return t("Community Store");
}
public function installStore()
{
$pkg = Package::getByHandle('community_store');
Installer::installSinglePages($pkg);
Installer::installProductParentPage($pkg);
Installer::installStoreProductPageType($pkg);
Installer::setDefaultConfigValues($pkg);
Installer::installPaymentMethods($pkg);
Installer::installShippingMethods($pkg);
Installer::installBlocks($pkg);
Installer::setPageTypeDefaults($pkg);
Installer::installCustomerGroups($pkg);
Installer::installUserAttributes($pkg);
Installer::installOrderAttributes($pkg);
Installer::installProductAttributes($pkg);
Installer::createDDFileset($pkg);
Installer::installOrderStatuses($pkg);
Installer::installDefaultTaxClass($pkg);
}
public function install()
{
parent::install();
$this->installStore();
}
public function upgrade()
{
$pkg = Package::getByHandle('community_store');
Installer::upgrade($pkg);
parent::upgrade();
}
public function registerRoutes()
{
Route::register('/cart/getCartSummary', '\Concrete\Package\CommunityStore\Src\CommunityStore\Cart\CartTotal::getCartSummary');
Route::register('/cart/getmodal', '\Concrete\Package\CommunityStore\Src\CommunityStore\Cart\CartModal::getCartModal');
Route::register('/productmodal', '\Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductModal::getProductModal');
Route::register('/checkout/getstates', '\Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\States::getStateList');
Route::register('/checkout/getShippingMethods', '\Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Checkout::getShippingMethods');
Route::register('/checkout/updater', '\Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Checkout::updater');
Route::register('/checkout/setVatNumber', '\Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Checkout::setVatNumber');
Route::register('/checkout/selectShipping', '\Concrete\Package\CommunityStore\Src\CommunityStore\Cart\CartTotal::getShippingTotal');
Route::register('/productfinder', '\Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\ProductFinder::getProductMatch');
Route::register('/dashboard/store/orders/details/slip', '\Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\OrderSlip::renderOrderPrintSlip');
}
public function on_start()
{
$this->registerRoutes();
$al = AssetList::getInstance();
$al->register('css', 'community-store', 'css/community-store.css', array('version' => '1', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => false, 'combine' => false), $this);
$al->register('css', 'communityStoreDashboard', 'css/communityStoreDashboard.css', array('version' => '1', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => false, 'combine' => false), $this);
$al->register('javascript', 'community-store', 'js/communityStore.js', array('version' => '1', 'position' => Asset::ASSET_POSITION_FOOTER, 'minify' => false, 'combine' => false), $this);
$al->register('javascript', 'communityStoreFunctions', 'js/communityStoreFunctions.js', array('version' => '1', 'position' => Asset::ASSET_POSITION_FOOTER, 'minify' => false, 'combine' => false), $this);
$al->register('javascript', 'chartist', 'js/chartist.min.js', array('version' => '0.9.7', 'position' => Asset::ASSET_POSITION_FOOTER, 'minify' => false, 'combine' => false), $this);
$al->register('css', 'chartist', 'css/chartist.min.css', array('version' => '0.9.7', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => false, 'combine' => false), $this);
$al->register('javascript', 'chartist-tooltip', 'js/chartist-plugin-tooltip.min.js', array('version' => '0.0.12', 'position' => Asset::ASSET_POSITION_FOOTER, 'minify' => false, 'combine' => false), $this);
$al->register('css', 'chartist-tooltip', 'css/chartist-plugin-tooltip.css', array('version' => '0.0.12', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => false, 'combine' => false), $this);
$al->registerGroup('chartist',
array(
array('javascript', 'chartist'),
array('javascript', 'chartist-tooltip'),
array('css', 'chartist'),
array('css', 'chartist-tooltip'),
)
);
if (Core::make('app')->isRunThroughCommandLineInterface()) {
try {
$app = Core::make('console');
$app->add(new Src\CommunityStore\Console\Command\ResetCommand());
} catch (Exception $e) {}
}
}
public function uninstall()
{
$invoicepm = PaymentMethod::getByHandle('invoice');
if (is_object($invoicepm)) {
$invoicepm->delete();
}
$shippingMethodType = ShippingMethodType::getByHandle('flat_rate');
if (is_object($shippingMethodType)) {
$shippingMethodType->delete();
}
$shippingMethodType = ShippingMethodType::getByHandle('free_shipping');
if (is_object($shippingMethodType)) {
$shippingMethodType->delete();
}
// change existing product pages back to standard page type to prevent broken pages
$list = new \Concrete\Core\Page\PageList();
$list->filterByPageTypeHandle('store_product');
$pages = $list->getResults();
$pageType = \PageType::getByHandle('page');
if ($pageType) {
foreach ($pages as $page) {
$page->setPageType($pageType);
}
}
parent::uninstall();
}
public static function returnHeaderJS()
{
return "
<script type=\"text/javascript\">
var PRODUCTMODAL = '" . URL::to('/productmodal') . "';
var CARTURL = '" . URL::to('/cart') . "';
var CHECKOUTURL = '" . URL::to('/checkout') . "';
var QTYMESSAGE = '" . t('Quantity must be greater than zero') . "';
</script>
";
}
}
//require_once __DIR__ . '/vendor/autoload.php';