/** * Auto Complete all WooCommerce orders. * Add to theme functions.php file */ add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); function custom_woocommerce_auto_complete_order( $order_id ) { global $woocommerce; if ( !$order_id ) return; $order = new WC_Order( $order_id ); $order->update_status( 'completed' ); }
Archive | Snippets
Re-order the product tabs in WooCommerce
add_filter( 'woocommerce_product_tabs', 'reorder_woocommerce_product_tabs', 98 ); function reorder_woocommerce_product_tabs( $tabs ) { $tabs['reviews']['priority'] = 5; // Reviews first $tabs['description']['priority'] = 10; // Description second $tabs['additional_information']['priority'] = 15; // Additional information third return $tabs; }
Hide excerpts for all WordPress posts
add_filter( 'the_excerpt', 'custom_excerpt' ); function custom_excerpt() { return ''; }
Control excerpt length in WordPress
function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
Show trailing zeros on prices in WooCommerce
// Show trailing zeros on prices, default is to hide it. add_filter( 'woocommerce_price_trim_zeros', 'wc_hide_trailing_zeros', 10, 1 ); function wc_hide_trailing_zeros( $trim ) { // set to false to show trailing zeros return false; }