• Resolved Kuler89

    (@kuler89)


    Hello,

    I absolutely love your plugin. It’s just what I’ve been looking for. And the PRO version should give me everything I need for my store. I just have one tiny problem. I’m using a plugin that sorts products based on stock status. In stock products go first followed by out of stock products.

    Any idea how I could make it work with AWS search?
    Here’s a complete code for the plugin I’m using:

    /** * Sorting out of stock WooCommerce products - Order product collections by stock status, in-stock products first. */ 
    class iWC_Orderby_Stock_Status { public function __construct() { 
    // Check if WooCommerce is active 
    
    if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000); } } public 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())) { $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; } } new iWC_Orderby_Stock_Status; 
    
    /** * END. */

    Any idea how I can adjust it to work with aws search as well?

    Thank you very much

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Need help adjusting my product sorting plugin’ is closed to new replies.