• Resolved andygroove

    (@andygroove)


    Hello
    I try to use function for order by stock status in my store catalog but this code drop ACF get_field() function
    when function on, get_field return only ID of post (https://skr.sh/sGyfgZ3GwaP)
    and when function off, all right, get_field return array (https://skr.sh/sGyHPC9UUOw)
    please help me to find a reason

    add_filter( 'posts_clauses', 'order_by_stock_status', 2000 );
    function order_by_stock_status( $posts_clauses ) {
    global $wpdb;
    
    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;
    }

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support ACF Support

    (@acfsupport)

    Hi @andygroove

    ACF Support Team here. This forum is generally used by ACF users helping each other out.

    However, we would love to continue investigating and troubleshooting this issue, please can you create a ticket using our support form and we can look into it further.

Viewing 1 replies (of 1 total)
  • The topic ‘posts_clauses drop ACF get_field function’ is closed to new replies.