I am using trust payments ad I want to hide and disable billing and shipping address from checkout(Place order without billing address). I am able to hide the billing address by following this: https://bsscommerce.com/blog/magento-2-remove-billing-shipping-address-from-checkout/ but not able to place order without it. Any help would be appreciated.
1 Answer
Ideally you do not want to remove billing address but best workaround would be to hide billing address using CSS and simply set the billing address value to default to the shipping address.
Copy file vendor/magento/module-checkout/view/frontend/web/js/model/checkout-data-resolver.js
to app/code/Vendor/Module/view/frontend/web/js/checkout-data-resolver.js
Edit file app/code/Vendor/Module/view/frontend/web/js/checkout-data-resolver.js
and comment out code and automatically set billing to match shipping around line 231:
applyBillingAddress: function () {
var shippingAddress;
if (quote.billingAddress()) {
selectBillingAddress(quote.billingAddress());
return;
}
shippingAddress = quote.shippingAddress();
selectBillingAddress(quote.shippingAddress());
/*if (shippingAddress &&
shippingAddress.canUseForBilling() &&
(shippingAddress.isDefaultShipping() || !quote.isVirtual())
) {
selectBillingAddress(quote.shippingAddress());
}*/
}
then we can just add a display:none
to the billing class of .checkout-billing-address
in your custom _payments.less
class
If shipping is also needed to be removed then might I suggest reading this article as it might help https://bsscommerce.com/blog/magento-2-remove-billing-shipping-address-from-checkout/
-
I tried the link and was able to hide the addresses but place order is still not working.– mechanicSep 2, 2022 at 20:17
-
Can you please update your question and provide screenshots of what you want to be done, and what it is currently doing? Unfortunately, I cant help without seeing what is going on.– InfinriSep 2, 2022 at 20:20
-
Let's just say I want to place an order without filling in the shipping and billing addresses on checkout.– mechanicSep 2, 2022 at 20:35
-
Then your best option is to populate your shipping form with customer data (such as name, address, zip, etc.), set billing info to default to what is in shipping and just hide the forms. Removing these forms will not work mainly because there are a few core files using either shipping or billing details, so YOU DO NEED THEM.– InfinriSep 2, 2022 at 20:56
-