How To Change Place Order Button Text on Checkout Page WooCommerce

How-To-Change-Place-Order-Button-Text-on-Checkout-Page-WooCommerce-3
2056 Views
3.4
(548)

You may modify the text of the WooCommerce checkout button from “Place Order” to your custom text without requiring a plugin. It is simple.

In this tutorial, I’ll guide you through the steps of changing the wording on your checkout button.

<?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

Another intriguing possibility is to tailor the Place Order button to certain items. First, you’ll need the product IDs for your items.

<?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

Similarly, you may vary the wording of the Place Order button based on the category of the goods in the basket. You must first locate the product’s category slug.

To find the category slug, navigate to Products > Categories on your dashboard, where you will see a list of all the products available in your store.

<?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

You can modify the text of the Place Order button based on the payment gateway or payment method selected by the customer.

The first step is to find out what the payment gateway ID is. You can accomplish this by employing the Inspect tool. Navigate to WooCommerce > Settings and choose the Payments tab. All of the payment gateways that you’ve added will be listed here.

Then, right-click on the payment gateway or payment method to which you want to make changes to the Place Order button, and select Inspect. The payment gateway ID will be displayed on the adjacent screen, as shown below.

<?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;
}
?>

That’s all! These are the many options for customizing the Place Order button text in WooCommerce. After you’ve finished adding your code, don’t forget to update the CodexCoach theme functions file.

Also read:

How to Add Custom Product Fields in WooCommerce

Display Most Popular Posts by Views in WordPress

Featured image is not showing on custom post type

FAQ

How do I change the text on the payment button in WooCommerce?

You can easily change the text of the “Proceed to Checkout” button in WooCommerce. Simply navigate to Settings > Checkout, type in your new text in the “Proceed to Checkout” field, and save your changes.

How useful was this blog?

Click on a star to rate it!

Average rating 3.4 / 5. Vote count: 548

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 *