// // 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
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
function fn_currentyear () { $year = date_i18n (‘Y’); return $year; } add_shortcode (‘currentyear’, ‘fn_currentyear’);Continue reading
/** * @link https://library.wpcode.com/snippet/323j86jo/ */ add_filter( ‘simpay_decimal_places’, function() { return 0; } );Continue reading
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
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
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
/** * 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