- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm looking to remove the billing address from the payment-step. I moved the option to add a billing address to the shipping step.
Now I know there is an option in the admin:
/* config: stores/configuration/sales/checkout/checkout-options/display_billing_address_on = payment_page */
But I want it to work even if that option is not selected.
I am able to unset the billing address from all payment methods but that also removes the checkout_agreement field.
/* config: checkout/options/display_billing_address_on = payment_method */
if (isset($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children']
)) {
foreach ($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'] as $key => $payment) {
unset($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'][$key]);
}
}
How can change this so the checkout_agreements stay? I would prefer a pretty solution, not just hide it in the CSS and would also love to be able to only change files in my module so it is easy to implement. I feel like I have to change checkout_index_index under Magento_Checkout_Agreements and that I should do something with the displayArea in there but i'm not sure what. I would love an option like what the config option does with the billing address. So an option to move the agreements to the bottom of the page. Or just delete the billing address area and leave the agreements alone.
Can anyone help me?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with below code for agreements block to prevent in checkout page,
if (isset($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] )) { foreach ($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] as $key => $payment) { if($key == 'before-place-order') { foreach ($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children']['before-place-order']['children'] as $key => $payment) { if($key == 'agreements') { continue; } } } unset($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children'] ['payment']['children']['payments-list']['children'][$key]); } }
I have updated my answer please check again, Replace return true with continue.
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with below code for agreements block to prevent in checkout page,
if (isset($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] )) { foreach ($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] as $key => $payment) { if($key == 'before-place-order') { foreach ($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children']['before-place-order']['children'] as $key => $payment) { if($key == 'agreements') { continue; } } } unset($jsLayoutResult['components']['checkout']['children']['steps']['children']['billing-step']['children'] ['payment']['children']['payments-list']['children'][$key]); } }
I have updated my answer please check again, Replace return true with continue.
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Removing billing address from payment method without removing agreements.
Thanks for the quick response. Sadly I get an error:
Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /home/aaaaaa/domains/aaaaaaaa.nl/public_html/vendor/magento/module-checkout/Model/Layout/AbstractTotalsProcessor.php on line 44
Phpstorm complains about the return value being a bool and expecting an array and the 'payment' and 'key' used in the foreach inside while also being used by the outer foreach. Do you know how to fix that? Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Removing billing address from payment method without removing agreements.
Ah you changed the code and now it works, thanks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Removing billing address from payment method without removing agreements.
-- Gone --
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Removing billing address from payment method without removing agreements.
Hello @SannNL,
Will that be possible to use in 2.2.5?
Would you provide me a little "how to" include your code to disable the billing information on the checkout page? I would like to let my customers checkout without entering their billing information.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Removing billing address from payment method without removing agreements.
Yes it works on 2.2.5. I just upgraded to that. You can create a plugin on LayoutProcessor.php and then paste Rakesh's code in there
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Removing billing address from payment method without removing agreements.
Where should I insert this code for ? can give the roots of this that file, thanks.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Removing billing address from payment method without removing agreements.
Hello,
I am interested too, which file is this?
Thanks