Q:

Get Woocommerce product by slug

I have a function to grab products by their category and return specific data about them using their category slug like so: 
$itemArgs = array( 
    'post_type' => 'product', 
    'posts_per_page' => 1000, 
    'product_cat' => $request['id'], 
    'include_children' => false 
);
$loop = new WP_Query( $itemArgs );
if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
  //DO STUFF
endwhile; endif;

Which works fantastically. What I need now is to get a product by its own slug. Where the one above might get every product for "Cookies" category, this one should return just the "Chocolate Chip" product. 
I've tried replacing 'product_cat' with 'slug' and 'product_slug' but those don't appear to work. This seems like a fairly straightforward thing to do... there's documentation on finding a product by 48 different properties... slug is not one for some reason. I just get the entirety of the product collection returned.

A:

If you look at the  Wordpress codex post about the WP_Query You will see a part which talks about Page and Posts Parameters. There you will see you can use the name parameter.
Assuming your product slug is chocolate-chip, you can use this to retrieve your product with the post_type and name parameters:
$itemArgs = array(
        'post_type' => 'product',
        'name' => 'chocolate-chip'
    );
$query = new WP_Query($itemArgs);

