I want to remove the “Ship to a different address?” checkbox from the WooCommerce checkout page, but I am encountering an issue with the checkout calculations.
Here’s the scenario:
- I want to keep the “Ship to a different address?” functionality checked by default (always using the shipping address for billing).
- When I remove the checkbox using a WooCommerce hook like
remove_action
, the JavaScript logic incheckout.min.js
treats the checkbox as unchecked. - As a result, WooCommerce uses the billing address for calculations instead of the shipping address.
Currently, I’ve modified the checkout.min.js
file to always consider shipping fields in the update_checkout_action
function:
update_checkout_action: function (o) {
var r = e("#shipping_country").val(),
c = e("#shipping_state").val(),
i = e("#shipping_postcode").val(),
n = e("#shipping_city").val(),
a = e("#shipping_address_1").val(),
u = e("#shipping_address_2").val(),
d = r,
s = c,
m = i,
l = n,
p = a,
h = u;
var g = {
s_country: d,
s_state: s,
s_postcode: m,
s_city: l,
s_address: p,
s_address_2: h,
// other data...
};
// ajax call...
}
This modification works as expected. However, I want to avoid modifying the core checkout.min.js file.
A way to hook into WooCommerce to remove the checkbox (#ship-to-different-address) from the DOM.
Ensure that WooCommerce calculations still use the shipping address, even if the checkbox is removed.
Avoid modifying the core WooCommerce files.
Is there a way to achieve this using hooks, custom JavaScript, or another clean method?