Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp wc php out of stock product to bottom

add_filter('posts_clauses', 'order_by_stock_status');
function order_by_stock_status($posts_clauses) {
    global $wpdb;
    // only change query on WooCommerce loops
    if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) {
        $posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
        $posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
        $posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
    }
    return $posts_clauses;
}
Comment

PREVIOUS NEXT
Code Example
Php :: fallo al conectar al servidor ftp wordpress 
Php :: macrotime phph 
Php :: joomla print query 
Php :: Show All Categories as Links 
Php :: vindecoder.eu php 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://D:/Program Files/Composer - PHP/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223 
Php :: laravel select only one word from string 
Php :: AuthController 
Php :: get percentage rating in laravel 
Php :: create config value file in php 
Php :: laravel auth sha-1 
Php :: php howto ignore file with BOM 
Php :: PHP is not configured to connect to MySQL 
Php :: laravel get url parameter value in controller 
Php :: unnamed place placeholders pdo 
Php :: php get referrer ajax 
Php :: Find category name & link 
Php :: laravel @class 
Php :: custom validation in laravel 
Php :: php split 
Php :: xss=removed 
Php :: select statement of table in phpmyadmin 
Php :: php check if stdclass object has property 
Php :: php session destroy not working 
Php :: php heredoc function 
Php :: php number formatter 
Php :: set config key dynamic laravel 
Php :: laravel guard 
Php :: php for loop stack overflow 
Php :: This domain is not registered with Tiny Cloud. Please see the quickstart guide or create an account. 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =