Magento2 - Reposition billing address form to customer-email region
I'm trying to reposition the billing-address-form
below the authentication
form. But I can't figure it out.
Preferred result:
What I have done so far
I have found this question, and made a module for it.
<vendor>/<module>/Block/Checkout/LayoutProcessor.php
namespace <vendor><module>CheckoutBlockCheckout; //<-- I think the first Checkout needs to be removed.
use MagentoCheckoutBlockCheckoutLayoutProcessor as LayoutProcessor;
class LayoutProcessorPlugin
{
public function afterProcess(LayoutProcessor $layoutProcessor, callable $proceed): float
{
$jsLayout = $proceed();
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to shipping step
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
return $jsLayout;
}
}
<vendor>/<module>/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">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="<vendor><module>BlockCheckoutLayoutProcessor" />
</config>
But after the compilation I get the following error on the checkout page:
Cannot declare class <vendor><module>BlockCheckoutLayoutProcessorPlugin, because the name is already in use in /app/code/<vendor>/<module>/Block/Checkout/LayoutProcessor.php on line 6
magento-2.1 checkout jslayout
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm trying to reposition the billing-address-form
below the authentication
form. But I can't figure it out.
Preferred result:
What I have done so far
I have found this question, and made a module for it.
<vendor>/<module>/Block/Checkout/LayoutProcessor.php
namespace <vendor><module>CheckoutBlockCheckout; //<-- I think the first Checkout needs to be removed.
use MagentoCheckoutBlockCheckoutLayoutProcessor as LayoutProcessor;
class LayoutProcessorPlugin
{
public function afterProcess(LayoutProcessor $layoutProcessor, callable $proceed): float
{
$jsLayout = $proceed();
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to shipping step
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
return $jsLayout;
}
}
<vendor>/<module>/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">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="<vendor><module>BlockCheckoutLayoutProcessor" />
</config>
But after the compilation I get the following error on the checkout page:
Cannot declare class <vendor><module>BlockCheckoutLayoutProcessorPlugin, because the name is already in use in /app/code/<vendor>/<module>/Block/Checkout/LayoutProcessor.php on line 6
magento-2.1 checkout jslayout
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm trying to reposition the billing-address-form
below the authentication
form. But I can't figure it out.
Preferred result:
What I have done so far
I have found this question, and made a module for it.
<vendor>/<module>/Block/Checkout/LayoutProcessor.php
namespace <vendor><module>CheckoutBlockCheckout; //<-- I think the first Checkout needs to be removed.
use MagentoCheckoutBlockCheckoutLayoutProcessor as LayoutProcessor;
class LayoutProcessorPlugin
{
public function afterProcess(LayoutProcessor $layoutProcessor, callable $proceed): float
{
$jsLayout = $proceed();
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to shipping step
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
return $jsLayout;
}
}
<vendor>/<module>/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">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="<vendor><module>BlockCheckoutLayoutProcessor" />
</config>
But after the compilation I get the following error on the checkout page:
Cannot declare class <vendor><module>BlockCheckoutLayoutProcessorPlugin, because the name is already in use in /app/code/<vendor>/<module>/Block/Checkout/LayoutProcessor.php on line 6
magento-2.1 checkout jslayout
I'm trying to reposition the billing-address-form
below the authentication
form. But I can't figure it out.
Preferred result:
What I have done so far
I have found this question, and made a module for it.
<vendor>/<module>/Block/Checkout/LayoutProcessor.php
namespace <vendor><module>CheckoutBlockCheckout; //<-- I think the first Checkout needs to be removed.
use MagentoCheckoutBlockCheckoutLayoutProcessor as LayoutProcessor;
class LayoutProcessorPlugin
{
public function afterProcess(LayoutProcessor $layoutProcessor, callable $proceed): float
{
$jsLayout = $proceed();
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to shipping step
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
return $jsLayout;
}
}
<vendor>/<module>/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">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="<vendor><module>BlockCheckoutLayoutProcessor" />
</config>
But after the compilation I get the following error on the checkout page:
Cannot declare class <vendor><module>BlockCheckoutLayoutProcessorPlugin, because the name is already in use in /app/code/<vendor>/<module>/Block/Checkout/LayoutProcessor.php on line 6
magento-2.1 checkout jslayout
magento-2.1 checkout jslayout
edited Jun 1 '17 at 13:00
Frank Groot
asked May 31 '17 at 8:58
Frank GrootFrank Groot
381426
381426
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
First, it looks like you've literally used "<vendor>
" and "<module>
" in your namespace and as directory names. These are meant as parameters, placeholders to be filled with your own values. For example "FrankCheckout
" instead of "<vendor><module>
". The same applies for the directory names.
Second, there is a configuration setting that's used to point where the billing address form is rendered at the path checkout/options/display_billing_address_on
. It can be found in the admin Stores > Configuration > Sales > Checkout > Checkout Options:
Set Display Billing Address On Display Billing Address On
to Payment Page
.
This will normally render billing address below the payment-method selection, but the Plugin you've made for the LayoutProcessor will removed it from below the payment-method selection and add it on the shipping step.
Note: I don't think you'd want it to be moved to the shipping step, because you're selling virtual products - they don't get shipped so the shipping step is not shown on the checkout. You may way to move it somewhere else by changing the afterProcess
method in the plugin to:
public function afterProcess(LayoutProcessor $subject, $jsLayout)
{
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to before the payment methods
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['beforeMethods']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
}
return $jsLayout;
}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f176768%2fmagento2-reposition-billing-address-form-to-customer-email-region%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First, it looks like you've literally used "<vendor>
" and "<module>
" in your namespace and as directory names. These are meant as parameters, placeholders to be filled with your own values. For example "FrankCheckout
" instead of "<vendor><module>
". The same applies for the directory names.
Second, there is a configuration setting that's used to point where the billing address form is rendered at the path checkout/options/display_billing_address_on
. It can be found in the admin Stores > Configuration > Sales > Checkout > Checkout Options:
Set Display Billing Address On Display Billing Address On
to Payment Page
.
This will normally render billing address below the payment-method selection, but the Plugin you've made for the LayoutProcessor will removed it from below the payment-method selection and add it on the shipping step.
Note: I don't think you'd want it to be moved to the shipping step, because you're selling virtual products - they don't get shipped so the shipping step is not shown on the checkout. You may way to move it somewhere else by changing the afterProcess
method in the plugin to:
public function afterProcess(LayoutProcessor $subject, $jsLayout)
{
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to before the payment methods
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['beforeMethods']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
}
return $jsLayout;
}
add a comment |
First, it looks like you've literally used "<vendor>
" and "<module>
" in your namespace and as directory names. These are meant as parameters, placeholders to be filled with your own values. For example "FrankCheckout
" instead of "<vendor><module>
". The same applies for the directory names.
Second, there is a configuration setting that's used to point where the billing address form is rendered at the path checkout/options/display_billing_address_on
. It can be found in the admin Stores > Configuration > Sales > Checkout > Checkout Options:
Set Display Billing Address On Display Billing Address On
to Payment Page
.
This will normally render billing address below the payment-method selection, but the Plugin you've made for the LayoutProcessor will removed it from below the payment-method selection and add it on the shipping step.
Note: I don't think you'd want it to be moved to the shipping step, because you're selling virtual products - they don't get shipped so the shipping step is not shown on the checkout. You may way to move it somewhere else by changing the afterProcess
method in the plugin to:
public function afterProcess(LayoutProcessor $subject, $jsLayout)
{
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to before the payment methods
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['beforeMethods']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
}
return $jsLayout;
}
add a comment |
First, it looks like you've literally used "<vendor>
" and "<module>
" in your namespace and as directory names. These are meant as parameters, placeholders to be filled with your own values. For example "FrankCheckout
" instead of "<vendor><module>
". The same applies for the directory names.
Second, there is a configuration setting that's used to point where the billing address form is rendered at the path checkout/options/display_billing_address_on
. It can be found in the admin Stores > Configuration > Sales > Checkout > Checkout Options:
Set Display Billing Address On Display Billing Address On
to Payment Page
.
This will normally render billing address below the payment-method selection, but the Plugin you've made for the LayoutProcessor will removed it from below the payment-method selection and add it on the shipping step.
Note: I don't think you'd want it to be moved to the shipping step, because you're selling virtual products - they don't get shipped so the shipping step is not shown on the checkout. You may way to move it somewhere else by changing the afterProcess
method in the plugin to:
public function afterProcess(LayoutProcessor $subject, $jsLayout)
{
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to before the payment methods
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['beforeMethods']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
}
return $jsLayout;
}
First, it looks like you've literally used "<vendor>
" and "<module>
" in your namespace and as directory names. These are meant as parameters, placeholders to be filled with your own values. For example "FrankCheckout
" instead of "<vendor><module>
". The same applies for the directory names.
Second, there is a configuration setting that's used to point where the billing address form is rendered at the path checkout/options/display_billing_address_on
. It can be found in the admin Stores > Configuration > Sales > Checkout > Checkout Options:
Set Display Billing Address On Display Billing Address On
to Payment Page
.
This will normally render billing address below the payment-method selection, but the Plugin you've made for the LayoutProcessor will removed it from below the payment-method selection and add it on the shipping step.
Note: I don't think you'd want it to be moved to the shipping step, because you're selling virtual products - they don't get shipped so the shipping step is not shown on the checkout. You may way to move it somewhere else by changing the afterProcess
method in the plugin to:
public function afterProcess(LayoutProcessor $subject, $jsLayout)
{
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to before the payment methods
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['beforeMethods']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
}
return $jsLayout;
}
answered Oct 3 '17 at 12:09
Klaas van der WeijKlaas van der Weij
165110
165110
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f176768%2fmagento2-reposition-billing-address-form-to-customer-email-region%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown