1
|
|
|
<?php namespace App\Http\Controllers\Frontend; |
2
|
|
|
|
3
|
|
|
use App\Http\Controllers\Controller; |
4
|
|
|
use Illuminate\Http\Request; |
5
|
|
|
use Hideyo\Ecommerce\Framework\Services\SendingMethod\SendingMethodFacade as SendingMethodService; |
6
|
|
|
use Hideyo\Ecommerce\Framework\Services\PaymentMethod\PaymentMethodFacade as PaymentMethodService; |
7
|
|
|
use Hideyo\Ecommerce\Framework\Services\Shop\ShopFacade as ShopService; |
8
|
|
|
use Browser; |
|
|
|
|
9
|
|
|
use Cart; |
10
|
|
|
|
11
|
|
|
class CartController extends Controller |
12
|
|
|
{ |
13
|
|
|
public function getIndex() |
14
|
|
|
{ |
15
|
|
|
$sendingMethodsList = SendingMethodService::selectAllActiveByShopId(config()->get('app.shop_id')); |
16
|
|
|
$paymentMethodsList = $this->getPaymentMethodsList($sendingMethodsList); |
17
|
|
|
|
18
|
|
|
if (!Cart::getContent()->count()) { |
19
|
|
|
return redirect()->to('cart'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
if($sendingMethodsList->count() AND !Cart::getConditionsByType('sending_method')->count()) { |
23
|
|
|
self::updateSendingMethod($sendingMethodsList->first()->id); |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
if ($paymentMethodsList AND !Cart::getConditionsByType('payment_method')->count()) { |
27
|
|
|
Cart::updatePaymentMethod($paymentMethodsList->first()->id); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
$template = "frontend.cart.index"; |
31
|
|
|
|
32
|
|
|
if (Browser::isMobile()) { |
33
|
|
|
$template = "frontend.cart.index-mobile"; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
return view($template)->with(array( |
37
|
|
|
'user' => auth('web')->user(), |
38
|
|
|
'sendingMethodsList' => $sendingMethodsList |
39
|
|
|
)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getPaymentMethodsList($sendingMethodsList) |
43
|
|
|
{ |
44
|
|
|
if ($sendingMethodsList->first()) { |
45
|
|
|
return $paymentMethodsList = $sendingMethodsList->first()->relatedPaymentMethods; |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return $paymentMethodsList = PaymentMethodService::selectAllActiveByShopId(config()->get('app.shop_id')); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function postProduct(Request $request, $productId, $productCombinationId = false) |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
$result = Cart::postProduct( |
54
|
|
|
$request->get('product_id'), |
55
|
|
|
$productCombinationId, |
56
|
|
|
$request->get('leading_attribute_id'), |
57
|
|
|
$request->get('product_attribute_id'), |
58
|
|
|
$request->get('amount') |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
if($result){ |
62
|
|
|
return response()->json(array( |
63
|
|
|
'result' => true, |
64
|
|
|
'producttotal' => Cart::getContent()->count(), |
65
|
|
|
'total_inc_tax_number_format' => Cart::getTotalWithTax(), |
66
|
|
|
'total_ex_tax_number_format' => Cart::getTotalWithoutTax() |
67
|
|
|
)); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
return response()->json(false); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function deleteProduct($productId) |
74
|
|
|
{ |
75
|
|
|
$result = Cart::remove($productId); |
76
|
|
|
|
77
|
|
|
if (Cart::getContent()->count()) { |
78
|
|
|
return response()->json(array('result' => $result, 'totals' => true, 'producttotal' => Cart::getContent()->count())); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return response()->json(false); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function updateAmountProduct(Request $request, $productId, $amount) |
85
|
|
|
{ |
86
|
|
|
Cart::updateAmountProduct($productId, $amount, $request->get('leading_attribute_id'), $request->get('product_attribute_id')); |
87
|
|
|
|
88
|
|
|
if (Cart::getContent()->count() AND Cart::get($productId)) { |
89
|
|
|
$product = Cart::get($productId); |
90
|
|
|
$amountNa = false; |
91
|
|
|
|
92
|
|
|
if($product->quantity < $amount) { |
93
|
|
|
$amountNa = view('frontend.cart.amount-na')->with(array('product' => $product))->render(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
return response()->json( |
97
|
|
|
array( |
98
|
|
|
'amountNa' => $amountNa, |
99
|
|
|
'product_id' => $productId, |
100
|
|
|
'product' => $product, |
101
|
|
|
'total_price_inc_tax_number_format' => $product->getOriginalPriceWithTaxSum(), |
102
|
|
|
'total_price_ex_tax_number_format' => $product->getOriginalPriceWithoutTaxSum() |
103
|
|
|
) |
104
|
|
|
); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return response()->json(false); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getBasketDialog() |
111
|
|
|
{ |
112
|
|
|
return view('frontend.cart.basket-dialog'); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getTotalReload() |
116
|
|
|
{ |
117
|
|
|
$sendingMethodsList = SendingMethodService::selectAllActiveByShopId(config()->get('app.shop_id')); |
118
|
|
|
$paymentMethodsList = $this->getPaymentMethodsList($sendingMethodsList); |
|
|
|
|
119
|
|
|
|
120
|
|
|
$template = "frontend.cart._totals"; |
|
|
|
|
121
|
|
|
|
122
|
|
|
if (Browser::isMobile()) { |
123
|
|
|
$template = "frontend.cart._totals-mobile"; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
return view('frontend.cart._totals')->with(array('sendingMethodsList' => $sendingMethodsList)); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function updateSendingMethod($sendingMethodId) |
130
|
|
|
{ |
131
|
|
|
Cart::updateSendingMethod($sendingMethodId); |
132
|
|
|
return response()->json(array('sending_method' => Cart::getConditionsByType('sending_method'))); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function updatePaymentMethod($paymentMethodId) |
136
|
|
|
{ |
137
|
|
|
Cart::updatePaymentMethod($paymentMethodId); |
138
|
|
|
return response()->json(array('payment_method' => Cart::getConditionsByType('payment_method'))); |
139
|
|
|
} |
140
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths