• Resolved ChriDi

    (@chridi)


    I installed and tested WPML for about a week. After deactivating it I realized the product_category shortcode wasn’t working as usual anymore. Like on the homepage, only 2 instead of 4 products were visible, but it depended on sorting and the particular category used in the shortcode.

    Tuns out I was able to fix it by using the function provided on this site:
    https://websavers.ca/woocommerce-shortcodes-not-showing-products

    function custom_woocommerce_shortcode_products_query( $args ) {
       if ( 'yes' == get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
         $args['meta_query'][] = array(
           'key' => '_stock_status',
           'value' => 'instock',
           'compare' => 'IN'
         );
       }
       return $args;
    }
    
    add_filter( 'woocommerce_shortcode_products_query', 'custom_woocommerce_shortcode_products_query' );

    Thing is: why is this needed only after installing and deactivating WPML, never had issues with the shortcodes before. Somethign WPML might have messed up?

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @chridi It’s possible that WPML may have broken the stock status of the products. It works by duplicating every post for the multiple languages. This means there are 2+ of every product in the store, and they are linked together as well.

    Were you able to find a permanent solution?

    Hi @chridi,

    We have not heard back from you in a while, so I am going to go ahead and close this thread. If you are still experiencing issues and it is tied to WooCommerce (WPML is redirecting you back here) please open a new thread, reference this one and let us know!

    Have a great day ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Deactivating WPML breaks shortcode functionality’ is closed to new replies.