File tree Expand file tree Collapse file tree 4 files changed +50
-23
lines changed
app/code/Magento/Checkout Expand file tree Collapse file tree 4 files changed +50
-23
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,6 @@ class Grid extends \Magento\Checkout\Block\Cart
22
22
*/
23
23
const XPATH_CONFIG_NUMBER_ITEMS_TO_DISPLAY_PAGER = 'checkout/cart/number_items_to_display_pager ' ;
24
24
25
- /**
26
- * Config settings path to enable clear shopping cart button
27
- */
28
- const XPATH_CONFIG_ENABLE_CLEAR_SHOPPING_CART = 'checkout/cart/enable_clear_shopping_cart ' ;
29
-
30
25
/**
31
26
* @var \Magento\Quote\Model\ResourceModel\Quote\Item\Collection
32
27
*/
@@ -107,7 +102,7 @@ protected function _construct()
107
102
}
108
103
109
104
/**
110
- * @inheritdoc
105
+ * { @inheritdoc}
111
106
*
112
107
* @since 100.2.0
113
108
*/
@@ -152,7 +147,7 @@ public function getItemsForGrid()
152
147
}
153
148
154
149
/**
155
- * @inheritdoc
150
+ * { @inheritdoc}
156
151
*
157
152
* @since 100.2.0
158
153
*/
@@ -166,8 +161,7 @@ public function getItems()
166
161
167
162
/**
168
163
* Verify if display pager on shopping cart
169
- *
170
- * Check if cart block has custom_items and items qty in the shopping cart<limit from stores configuration
164
+ * If cart block has custom_items and items qty in the shopping cart<limit from stores configuration
171
165
*
172
166
* @return bool
173
167
*/
@@ -182,17 +176,4 @@ private function isPagerDisplayedOnPage()
182
176
}
183
177
return $ this ->isPagerDisplayed ;
184
178
}
185
-
186
- /**
187
- * Check if clear shopping cart button is enabled
188
- *
189
- * @return bool
190
- */
191
- public function isClearShoppingCartEnabled ()
192
- {
193
- return (bool )$ this ->_scopeConfig ->getValue (
194
- self ::XPATH_CONFIG_ENABLE_CLEAR_SHOPPING_CART ,
195
- \Magento \Store \Model \ScopeInterface::SCOPE_STORE
196
- );
197
- }
198
179
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Magento \Checkout \ViewModel ;
3
+
4
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
5
+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
6
+ use Magento \Framework \View \Element \Context ;
7
+
8
+ class Cart implements ArgumentInterface
9
+ {
10
+ /**
11
+ * Config settings path to enable clear shopping cart button
12
+ */
13
+ private const XPATH_CONFIG_ENABLE_CLEAR_SHOPPING_CART = 'checkout/cart/enable_clear_shopping_cart ' ;
14
+
15
+ /**
16
+ * @var ScopeConfigInterface
17
+ */
18
+ private $ _scopeConfig ;
19
+
20
+ /**
21
+ * Constructor
22
+ *
23
+ * @param Context $context
24
+ */
25
+ public function __construct (
26
+ Context $ context
27
+ ) {
28
+ $ this ->_scopeConfig = $ context ->getScopeConfig ();
29
+ }
30
+
31
+ /**
32
+ * Check if clear shopping cart button is enabled
33
+ *
34
+ * @return bool
35
+ */
36
+ public function isClearShoppingCartEnabled ()
37
+ {
38
+ return (bool ) $ this ->_scopeConfig ->getValue (
39
+ self ::XPATH_CONFIG_ENABLE_CLEAR_SHOPPING_CART ,
40
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE
41
+ );
42
+ }
43
+ }
Original file line number Diff line number Diff line change 181
181
</block >
182
182
</container >
183
183
<block class =" Magento\Checkout\Block\Cart\Grid" name =" checkout.cart.form" as =" cart-items" template =" Magento_Checkout::cart/form.phtml" after =" cart.summary" >
184
+ <arguments >
185
+ <argument name =" view_model" xsi : type =" object" >Magento\Checkout\ViewModel\Cart</argument >
186
+ </arguments >
184
187
<block class =" Magento\Framework\View\Element\RendererList" name =" checkout.cart.item.renderers" as =" renderer.list" />
185
188
<block class =" Magento\Framework\View\Element\Text\ListText" name =" checkout.cart.order.actions" />
186
189
</block >
Original file line number Diff line number Diff line change 56
56
<span><?= $ block ->escapeHtml (__ ('Continue Shopping ' )) ?> </span>
57
57
</a>
58
58
<?php endif ; ?>
59
- <?php if ($ block ->isClearShoppingCartEnabled ()): ?>
59
+ <?php if ($ block ->getViewModel ()-> isClearShoppingCartEnabled ()): ?>
60
60
<button type="button"
61
61
name="update_cart_action"
62
62
data-cart-empty=""
You can’t perform that action at this time.
0 commit comments