Skip to content

Commit 943afc6

Browse files
authored
ENGCOM-4126: Enabled 'Shopping Cart' tab for customer edit interface in admin #20918
2 parents 4f964f6 + af93daf commit 943afc6

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Model;
9+
10+
use Magento\Framework\App\RequestInterface;
11+
12+
/**
13+
* Provides customer id from request.
14+
*/
15+
class CustomerIdProvider
16+
{
17+
/**
18+
* @var RequestInterface
19+
*/
20+
private $request;
21+
22+
/**
23+
* @param RequestInterface $request
24+
*/
25+
public function __construct(
26+
RequestInterface $request
27+
) {
28+
$this->request = $request;
29+
}
30+
31+
/**
32+
* Get customer id from request.
33+
*
34+
* @return int
35+
*/
36+
public function getCustomerId(): int
37+
{
38+
return (int)$this->request->getParam('id');
39+
}
40+
}

app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
<referenceContainer name="content">
1616
<uiComponent name="customer_form"/>
1717
</referenceContainer>
18+
<referenceContainer name="after.body.start">
19+
<block class="Magento\Catalog\Block\Adminhtml\Product\Composite\Configure" name="after.body.start.product_composite_configure" template="Magento_Catalog::catalog/product/composite/configure.phtml"/>
20+
</referenceContainer>
1821
</body>
1922
</page>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Block\Adminhtml;
7+
8+
use Magento\Backend\Block\Template\Context;
9+
use Magento\Customer\Model\CustomerIdProvider;
10+
use Magento\Ui\Component\Layout\Tabs\TabWrapper;
11+
12+
/**
13+
* Class ShoppingCarts
14+
*
15+
* @package Magento\Sales\Block\Adminhtml
16+
*/
17+
class ShoppingCartsTab extends TabWrapper
18+
{
19+
/**
20+
* @var bool
21+
*/
22+
protected $isAjaxLoaded = true;
23+
24+
/**
25+
* @var CustomerIdProvider
26+
*/
27+
private $customerIdProvider;
28+
29+
/**
30+
* @param Context $context
31+
* @param CustomerIdProvider $customerIdProvider
32+
* @param array $data
33+
*/
34+
public function __construct(Context $context, CustomerIdProvider $customerIdProvider, array $data = [])
35+
{
36+
parent::__construct($context, $data);
37+
$this->customerIdProvider = $customerIdProvider;
38+
}
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
public function canShowTab()
44+
{
45+
return $this->customerIdProvider->getCustomerId();
46+
}
47+
48+
/**
49+
* Return Tab label
50+
*
51+
* @codeCoverageIgnore
52+
*
53+
* @return \Magento\Framework\Phrase
54+
*/
55+
public function getTabLabel()
56+
{
57+
return __('Shopping cart');
58+
}
59+
60+
/**
61+
* Return URL link to Tab content
62+
*
63+
* @return string
64+
*/
65+
public function getTabUrl()
66+
{
67+
return $this->getUrl('customer/*/cart', ['_current' => true]);
68+
}
69+
}

app/code/Magento/Sales/view/base/ui_component/customer_form.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
<htmlContent name="orders_content">
1010
<block acl="Magento_Sales::actions_view" class="Magento\Sales\Block\Adminhtml\CustomerOrdersTab" name="orders" />
1111
</htmlContent>
12+
<htmlContent name="cart_content">
13+
<block acl="Magento_Cart::manage" class="Magento\Sales\Block\Adminhtml\ShoppingCartsTab" name="cart"/>
14+
</htmlContent>
1215
</form>

0 commit comments

Comments
 (0)