[Support request] Elements stopped working

Home Forums Support [Support request] Elements stopped working

Home Forums Support Elements stopped working

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1671222
    chris

    Hi some of my hook elements have stopped working, not sure why but all the ones i had to display on the woo product archive page have stopped displaying on there.

    Is there any reason for this to have happened?

    #1671241
    Ying
    Staff
    Customer Support

    Hi Chris,

    Could you check if there’s any conflicts in terms of location settings?

    If not, try disable all plugins except GP Premium and woocommerce to test.

    If you can’t find any issues, could you please provide login info using the private info field.

    Thanks!

    #1671244
    chris

    Literally nothing has changed other than me adding products to the site which wouldn’t of interfered.

    #1671253
    Ying
    Staff
    Customer Support

    The login you provided doesn’t work for me.

    But could you try what I said in my previous reply first? Thanks!

    #1671313
    chris

    This snippet is causing the issue, but im not sure how?

    /**
    * 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 – Order product collections by stock status, instock products first.
    */

    #1671393
    Elvin
    Staff
    Customer Support

    Hi there,

    I believe you’ve taken it from this? https://stackoverflow.com/a/40629857

    Can you try this one and not change anything and see if it works? Let us know.

    A wise man once said:
    "Have you cleared your cache?"

    #1672989
    chris

    That doesnt seem to work fully. When clicking a category the out of stock products dont display after the in stock products, which is what the whole piece of code was for i believe.

    As i say, i tried the code you supplied but it doesnt do what the first piece did, thanks for the reply

    #1673023
    chris

    The snipper im using is this one: https://wpdoityourself.com/sorting-out-of-stock-woocommerce-products-wordpress/

    im not sure why it effects the elements dissapearing from the shop archive page.

    #1673126
    Elvin
    Staff
    Customer Support

    I’m not exactly sure how these snippets fare with the most recent updates of WooCommerce. Perhaps that’s actually why it stopped working.

    But IMO I think what better to do is to filter the product query.

    Something like this – https://stackoverflow.com/a/62353255

    Note: This isn’t actually a GP question but rather, a WooCommerce plugin question related to its product queries. It may be best to ask WooCommerce’s support if they have any best practice/recommendation on how to do this.

    A wise man once said:
    "Have you cleared your cache?"

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.