How to enable disable ship to different address woocommerce

How to enable disable ship to different address woocommerce
1875 Views
4.3
(123)

Try these 2 Solution

This is a WooCommerce feature. You can just change this in the WooCommerce shipping options.

WooCommerce > Settings > Shipping > Shipping Option > (select) Force shipping to the customer billing address.

Disable “Ship to different address” 

Once done, the box “Ship to a different address” will be hidden on the checkout page

Uncheck “Ship to different address” 

Out of the box, if you want to uncheck the box by default, please go to WooCommerce > Settings > Shipping > Shipping Option > (select) Default to customer billing address.

Once done, “Ship to a different address” will not be checked by default.

Solutions 2

<?php
  add_action( 'wp_footer', 'cxc_checkout_force_shipping_address' );

function cxc_checkout_force_shipping_address() {
	?>
	<script type="text/javascript">

		var diffAddress = document.querySelector('#ship-to-different-address');

		diffAddress.outerHTML = '<h3>Shipping details</h3><input type="checkbox" checked="checked" value="1" name="ship_to_different_address" class="hidden" style="display: none;" />';

	</script>
	<?php
}
?>

Are you selling products online? Or are you a developer? Do you want to provide the option “ship to different addresses” in WoCommerce to your customer?

You cannot adjust “ship to a different address?” in WooCommerce. To enable/disable, you must use a custom code. Don’t worry; I’ve got you covered!

Ship to a different address button image

There are two requirements for using this code.

Make ship to a different address button “checked” by Default

Let’s explain this step by step:

Make the ship to a different address button “checked” by default
To make the default “Ship to a Different Address” checkbox checked in the WooCommerce Checkout page, add the below code to the functions.php file.

<?php
  add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true' );
?>

Disable the ship to a different address button

Disable “Ship To A Different Address” on WooCommerce Checkout, and add the below code on the functions.php file.

<?php
   add_filter( 'woocommerce_ship_to_different_address_checked', '__return_false' );
?>

PHP snippets can be included at the bottom of your child theme’s functions.php file. CSS, on the other hand, should be included in your child theme’s style.css file. When changing such files, be sure you understand what you’re doing.

If you have any questions then contact us through the comment or contact us form.

How useful was this blog?

Click on a star to rate it!

Average rating 4.3 / 5. Vote count: 123

No votes so far! Be the first to rate this blog.

Leave a comment

Your email address will not be published. Required fields are marked *