Minimum Order Restriction

// // minimum order amount for checkout // // add_action(‘woocommerce_checkout_process’, ‘wc_minimum_order_amount’); add_action(‘woocommerce_before_cart’ , ‘wc_minimum_order_amount’); function wc_minimum_order_amount() { $minimum = 200; $cart_total = WC()->cart->total; $shipping_total = WC()->cart->get_shipping_total(); if (($cart_total – $shipping_total) < $minimum) { if (is_cart()) { wc_print_notice( sprintf('Your current order…Continue reading

Hide Variation Dropdown if Product Out of Stock

add_action( ‘woocommerce_before_single_product’, ‘custom_check_variations_stock_status’ ); function custom_check_variations_stock_status() { global $product; if ( $product->is_type( ‘variable’ ) ) { $variations = $product->get_available_variations(); $all_out_of_stock = true; foreach ( $variations as $variation ) { if ( $variation[‘is_in_stock’] ) { $all_out_of_stock = false; break; } }…Continue reading

Post reading time shortcode

function reading_time() { if ( empty( $post ) && isset( $GLOBALS[‘post’] ) ) { $post = $GLOBALS[‘post’]; $content = get_post_field( ‘post_content’, $post->ID ); $word_count = str_word_count( strip_tags( $content ) ); $readingtime = ceil($word_count / 260); if ($readingtime == 1) {…Continue reading

Post class update

add_filter( ‘body_class’, function( $classes ) { $acc_type=tmwp_get_user_role(); if (!$acc_type) $acc_type=’anonymous’; return array_merge( $classes, array(‘acc-type-‘.strtolower($acc_type),tmwp_get_page_class()) ); } );Continue reading

Frontend – Custom logout

add_action( ‘init’, ‘custom_logout’ ); function custom_logout() { if ( strpos($_SERVER[‘REQUEST_URI’], ‘/customer-logout’) !== false ) { wp_logout(); $redirect_url = home_url(); wp_safe_redirect($redirect_url); exit; } }Continue reading

Save images as WEBP (copy)

/** * Convert Uploaded Images to WebP Format * * This snippet converts uploaded images (JPEG, PNG, GIF) to WebP format * automatically in WordPress. Ideal for use in a theme’s functions.php file, * or with plugins like Code Snippets…Continue reading