How To Change Place Order Button Text on WooCommerce Checkout Page

How To Change Place Order Button Text on WooCommerce Checkout Page
69 Views
<?php
add_filter( 'woocommerce_order_button_text', 'cxc_wooCommerce_checkout_page_custom_button_text' );
function cxc_wooCommerce_checkout_page_custom_button_text( $button_text ) {
	return 'Complete Order'; // Add new text is here.. 
}
?>

Specific Product Is In The Cart Change Place Order Text

<?php
add_filter( 'woocommerce_order_button_text', 'cxc_wooCommerce_checkout_page_custom_button_text_for_product' );
function cxc_wooCommerce_checkout_page_custom_button_text_for_product( $button_text ) {

	$product_id = 181; // a specific product ID you would like to check .... 
	if( WC()->cart->find_product_in_cart( WC()->cart->generate_cart_id( $product_id ) ) ) {
		$button_text = 'Complete Order';
	}
	return $button_text;
}
?>

Change Place Order Button Text Based on Categories

<?php
add_filter( 'woocommerce_order_button_text', 'cxc_checkout_page_custom_button_text_categories' );
function cxc_checkout_page_custom_button_text_categories( $button_text ) {

	$terms_check = false;

	foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {

		$product = ( $cart_item['data'] ) ? $cart_item['data'] : '';
    	// check if posters is the category of the product in the cart
		if ( has_term( 'posters', 'product_cat', $product->id ) ) {
			$terms_check = true;
			break;
		}
	}       

	if ( $terms_check ) {
		return 'Complete Order'; 
	}

}
?>

Change Place Order button text In woocommerce_order_button_html hook

<?php
add_filter( 'woocommerce_order_button_html', 'cxc_checkout_page_custom_button_html' );
function cxc_checkout_page_custom_button_html( $button_html ) {
	$button_html = str_replace( 'Place order', 'Complete Order', $button_html );
	return $button_html;
}
?>
<?php
add_filter( 'woocommerce_order_button_html', 'cxc_checkout_page_custom_button_html' );
function cxc_checkout_page_custom_button_html( $button_html ) {

	$order_button_text = 'Complete Order';
	$button_html = '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="'. $order_button_text .'" data-value="'. $order_button_text .'">' . $order_button_text . '</button>';
	return $button_html;
}
?>

Change Place Order Button Text for Payment Gateways

<?php
add_filter( 'gettext', 'cxc_checkout_custom_place_order_button_text', 20, 3 );
function cxc_checkout_custom_place_order_button_text( $translated_text, $text, $domain ) {

	switch ( $translated_text ) {

		case 'Place order' :
		$translated_text = __( 'Complete Order', 'cxc-codexcoach' );
		break;

		// Chnage place order button by button label
		/*case 'Complete Order' :
		$translated_text = __( 'Place order', 'cxc-codexcoach' );
		break;*/

		/*case 'Proceed to PayPal' :
		$translated_text = __( 'Pay with PayPal', 'cxc-codexcoach' );
		break;*/
	}

	return $translated_text;
}
?>
<?php
add_filter( 'woocommerce_available_payment_gateways', 'cxc_rename_place_order_button_payment_gateway' );
function cxc_rename_place_order_button_payment_gateway( $gateways ) {

    if ( $gateways['cod'] ) {
        $gateways['cod']->order_button_text = 'Confirm Cash on Delivery';
    } 
    
    return $gateways;
}
?>

Was this article helpful?
YesNo

Leave a comment

Your email address will not be published.