Customize Checkout Page in Woocommerce

By | July 29, 2017

Hide Billing field on Checkout Page Woocommerce

#

Hide Shipping field on Checkout Page Woocommerce

#

Reorder Billing fields on Checkout Page Woocommerce

# WooCommerce version 2.6 and below
function reorder_wc_billing_fields($fields) {
	 $order = array(
        "billing_first_name", 
        "billing_last_name", 
        "billing_company", 
        "billing_address_1", 
        "billing_postcode", 
        "billing_city", 
        "billing_email", 
        "billing_phone"
    );
    foreach($order as $field)
    {
        $ordered_fields[$field] = $fields["billing"][$field];
    }

    $fields["billing"] = $ordered_fields;
    return $fields;
}
add_filter('woocommerce_checkout_fields','reorder_wc_billing_fields');
?>

Reorder Shipping fields on Checkout Page Woocommerce

# WooCommerce version 2.6 and below
function reorder_wc_shipping_fields($fields) {

    $order = array(   
        "shipping_first_name", 
        "shipping_last_name", 
        "shipping_company", 
        "shipping_address_1", 
        "shipping_postcode", 
        "shipping_city", 
        "shipping_email", 
        "shipping_phone"

    );
    foreach( $order as $field ) {
        $ordered_fields[$field] = $fields["shipping"][$field];
    }

    $fields["shipping"] = $ordered_fields;
    return $fields;
}
add_filter("woocommerce_checkout_fields", "reorder_wc_shipping_fields");
?>

By Default Checked Terms and Condition checkbox on Checkout Page Woocommerce

# WooCommerce version 2.6 and below
function ls_wc_terms_and_condition( $terms_is_checked ) {return true;}
add_filter( 'woocommerce_terms_is_checked', 'ls_wc_terms_and_condition', 10 );
add_filter( 'woocommerce_terms_is_checked_default', 'ls_wc_terms_and_condition', 10 );

Customize WooCommerce Shipping Address Fields Order

#
add_filter( 'woocommerce_order_formatted_shipping_address' , 'woo_custom_order_formatted_shipping_address' );
function woo_custom_order_formatted_shipping_address() {
	$address = array(
		'first_name' 	=> $this->shipping_first_name,
		'last_name'		=> $this->shipping_last_name,
		'company'		=> $this->shipping_company,
		'address_1'		=> $this->shipping_address_1,
		'address_2'		=> $this->shipping_address_2,
		'city'			=> $this->shipping_city,
		'state'			=> $this->shipping_state,
		'postcode'		=> $this->shipping_postcode,
		'country'		=> $this->shipping_country
	);
 return $address;
}

Customize WooCommerce Billing Address Fields Order

#
add_filter( 'woocommerce_order_formatted_billing_address' , 'woo_custom_order_formatted_billing_address' );
function woo_custom_order_formatted_billing_address() {
	$address = array(
		'first_name'	=> $this->billing_first_name,
		'last_name'		=> $this->billing_last_name,
		'company'		=> $this->billing_company,
		'address_1'		=> $this->billing_address_1,
		'address_2'		=> $this->billing_address_2,
		'city'			=> $this->billing_city,
		'state'			=> $this->billing_state,
		'postcode'		=> $this->billing_postcode,
		'country'		=> $this->billing_country
	);
return $address;
}

Remove Shipping Labels on WooCommerce Cart page (e.g. “Flat Rate”)

#
add_filter( 'woocommerce_cart_shipping_method_full_label', 'ls_remove_shipping_label', 10, 2 );
  
function ls_remove_shipping_label($label, $method) {
$new_label = preg_replace( '/^.+:/', '', $label );
return $new_label;
}

On Order Placed Thank you page change “Thank you. Your order has been received” text by own custom text use

#
add_filter( 'woocommerce_thankyou_order_received_text', 'lsw_thank_you' );
function lsw_thank_you() {
 $added_text = '

Thank you very much!

‘; return $added_text ; }