Modify the “Add to Cart” button text for simple and variable products:

// Change "Add to Cart" text on shop page
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_text_archive' );
function custom_add_to_cart_text_archive() {
    return __( 'your text', 'woocommerce' );
}
// 
// // Change "Add to Cart" text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_text' );
function custom_add_to_cart_text() {
    return __( 'your text', 'woocommerce' );
}

Automatically redirect customers to the checkout page as soon as they add an item to their cart:

// Disable AJAX Add to Cart on the Shop page
add_action( 'wp_enqueue_scripts', 'disable_ajax_add_to_cart_on_shop' );
function disable_ajax_add_to_cart_on_shop() {
    if (is_shop() || is_product_category()) {
        wp_dequeue_script( 'wc-add-to-cart' );
    }
}

// Redirect to checkout after adding to cart
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
function custom_add_to_cart_redirect() {
    return wc_get_checkout_url();
}

Remove the “Related Products” section from product pages:

// Remove Related Products from Product Pages
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );

Enforces a minimum order amount for checkout:

// Set Minimum Order Amount for Checkout
add_action( 'woocommerce_checkout_process', 'custom_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'custom_minimum_order_amount' );
function custom_minimum_order_amount() {
    $minimum = 200; // Set minimum amount
    if ( WC()->cart->total < $minimum ) {
        if( is_cart() ) {
            wc_print_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to proceed to checkout.', 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );
        } else {
            wc_add_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to proceed to checkout.', 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );
        }
    }
}

Automatically apply a specific coupon to the cart:

// Automatically Apply a Coupon on Checkout
add_action( 'woocommerce_before_cart', 'apply_coupon_automatically' );
add_action( 'woocommerce_before_checkout_form', 'apply_coupon_automatically' );

function apply_coupon_automatically() {
    $coupon_code = 'test'; // Replace with the actual coupon code you want to apply.

    // Check if the cart does not already have the coupon applied
    if ( ! WC()->cart->has_discount( $coupon_code ) ) {
        WC()->cart->apply_coupon( $coupon_code );
        wc_print_notices();
    }
}

Add a custom fee to the WooCommerce checkout, for example, a handling fee or packaging fee:

// Add a Custom Fee to Checkout
add_action( 'woocommerce_cart_calculate_fees', 'add_custom_checkout_fee' );
function add_custom_checkout_fee() {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;
    
    WC()->cart->add_fee( 'Handling Fee', 5 );
}

You can hide product prices for visitors who are not logged in:

 // Hide Prices for Logged-Out Users
add_action( 'wp', 'hide_prices_for_logged_out_users' );
function hide_prices_for_logged_out_users() {
    if ( ! is_user_logged_in() && ! is_admin() ) {
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
        remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    }
}

Show a custom message on the Cart page when the customer qualifies for free shipping:

// Display a Free Shipping Notice
add_action( 'woocommerce_before_cart', 'custom_free_shipping_notice' );
function custom_free_shipping_notice() {
    $min_amount = 50; // Set minimum amount for free shipping
    $current_total = WC()->cart->subtotal;
    
    if ( $current_total >= $min_amount ) {
        echo '<div class="woocommerce-info">Congrats! You qualify for free shipping.</div>';
    }
}

Scroll to Top