woocommerce display global $product in my custom shortcode

I need to display global $product in my custom shortcode. I am trying to create a manual layout of $product with only products with "category C".

so in my shortcode i declared

//Create display Apple function    
function wpb_displayApples_shortcode() { 
        global $product;
        echo '<pre>';
        print_r($product);
        echo '</pre>';
    } 
    // register shortcode
    add_shortcode('displaydisplayApples', 'wpb_displayApples_shortcode');

but my functions return blank $product

When i use $woocommerce, I get data but I can not locate my products.

How do i get all my products on my custom shortcode, to manually display control my products layout?

Solutions

So after researching more I found this code from Woocommerce get products

$args = array(
        'post_type'      => 'product',
        'posts_per_page' => 10,
        'product_cat'    => 'hoodies'
    );

    $loop = new WP_Query( $args );

    while ( $loop->have_posts() ) : $loop->the_post();
        global $product;
        echo '<br /><a href="'.get_permalink().'">' . woocommerce_get_product_thumbnail().' '.get_the_title().'</a>';
    endwhile;

    wp_reset_query();

Similar questions

Exclude a woocommerce product category from wordpress global search results
I'm using this code to exclude some post category from the wordpress search results : My problem is that it doesn't work for woocommerce categories and products are not filtered. How can I filter some woocommerce categories too ?
Woocommerce - how to display the grouped product that a simple product belongs to on it's single product page?
I have a Woocommerce site where several of my simple products are also part of grouped products. We don't mind selling these individually or as a set, so grouped products are perfect for what we're doing. However, we'd like to add extra emphasis on a product page when that a product is part of a group, ideally with a link to the grouped product. So...
How to display the woocommerce product tags of only featured product or recent product.
I need to display the tags of the specific product. for example, if the user selects the recent products I need to display the tags of only recent products or if the user selects the featured products I need to display the tags of only featured product. anyone, there to help me out with this problem. Thanks in advance
Display product variation description or product short description based on product type in WooCommerce checkout
This code snippet displays product short description at WooCommerce checkout: The issue is that a variable product can only have 1 product short description, so all of the product variations have the same exact description. Is it possible to modify this code snippet to display product variation description instead of product short description for v...
How to have Function of a plugin using global vars into a shortcode?
I am trying to convert this piece of code into a shortcode so it can be used inside my posts. Is it possible? I cant think of how to do it as I am beginner in wordpress and learning via books/youtube and wordpress documentation. The code is: The goal is to have that be executed in the post as [authorlink] If it isnt possible to do so can I add the ...
How to exclude shortcode from specific page IDs if it's set to global
At this moment I am using the code below, to add a shortcode for a table on all the posts and pages, but I would like to exclude few pages and any post with a specific tag. (ex. page ids 10,20 and tag id 30) I am quite new to all of this, and I am still learning. Thanks for the help in advance.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.