I want to show the Cart Items
section below the Order Summary
on the checkout page
.
See my code but it’s not working —
create a di.xml
file at the location,
app/code/Vishal/CartItemsAfterSummary/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Billing address above the payment method plugin -->
<type name="MagentoCheckoutBlockCheckoutLayoutProcessor">
<plugin name="move_billing_address_above_payment_method"
type="Vishal/CartItemsAfterSummaryPluginBlockCheckoutLayoutProcessor"/>
</type>
</config>
Based on the XML file, Create a Plugin Class, app/code/Vishal/CartItemsAfterSummary/Plugin/Block/Checkout/LayoutProcessor.php
<?php declare(strict_types=1);
namespace VishalCartItemsAfterSummaryPluginBlockCheckout;
use MagentoCheckoutBlockCheckoutLayoutProcessor as CheckoutLayoutProcessor;
/**
* Move Billing address to top
*/
class LayoutProcessor
{
/**
* @param CheckoutLayoutProcessor $subject
* @param array $jsLayout
* @return array
*/
public function afterProcess(
CheckoutLayoutProcessor $subject,
array $jsLayout
): array {
$sidebarLayout = $jsLayout['components']['checkout']['children']['sidebar'];
if (isset($sidebarLayout['children']['summary']['children']['cart_items'])) {
$jsLayout['components']['checkout']['children']['sidebar']['children']['cart_items'] = $sidebarLayout['children']['summary']['children']['cart_items'];
unset($jsLayout['components']['checkout']['children']['sidebar']['children']['summary']['children']['cart_items']);
}
return $jsLayout;
}
}