Title: Shortcode for product variations
Last modified: August 30, 2016

---

# Shortcode for product variations

 *  Resolved [lapatente](https://wordpress.org/support/users/lapatente/)
 * (@lapatente)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/)
 * I am trying to use
 *     ```
       [product id="99"]
       [product sku="FOO"]
       ```
   
 * to call a product variation but is not working, not even with a specific SKU 
   for a specific product variation.
 * Does anyone know any simple shortcode to show product variations?
    It would be
   pretty helpful for my website.
 * Thanks a lot.
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468515)
 * That shortcode shows the product itself, not a child variation.
 * You can output a cart button for a variation using one of the product add to 
   cart shortcodes, but you cannot output a full variation. There is no view to 
   see individual variations in WC.
 *  [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * (@gabriel-reguly)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468654)
 * Hi,
 * lapatente has hired me and I have created such shortcode via a plugin.
 * It shows the variation title linked to product page. Also shows the variation
   attributes and stock level.
 * Not sure if this should be turned into a PR at github or simply released here
   at WordPress.org…
 * Any advices?
 * Cheers,
    Gabriel
 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468655)
 * Hi Gabriel
 * We can review it if you do a PR 🙂 Leave some screenshots and we’ll leave feedback.
 * Thanks!
 *  [Plugin Territory](https://wordpress.org/support/users/pluginterritory/)
 * (@pluginterritory)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468747)
 * Hi Mike,
 * A PR it will be then.
 * Cheers,
    Gabriel
 *  [Plugin Territory](https://wordpress.org/support/users/pluginterritory/)
 * (@pluginterritory)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468748)
 * Here it is: [https://github.com/greguly/woocommerce/pull/1](https://github.com/greguly/woocommerce/pull/1)
 *  [myburgh.bernard@gmail.com](https://wordpress.org/support/users/myburghbernardgmailcom/)
 * (@myburghbernardgmailcom)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468783)
 * I have a solution.
 * Use the shortcode: `[add_to_cart id="971"]`, with `971` being the id of the variation
   product, or rather, the unique id of a variation of a variable product.
 * Then for some reason I have to edit the actual woocommerce file “class-wc-shortcodes.
   php” becasue I can’t seem to get my theme file to override it.
    1. Open class-wc-shortcodes.php
    2. Look for the function with comment `Display a single product price + cart button.`,
       should be line 419.
    3. Then look for line: `<?php if ( 'true' == $atts['show_price'] ) : ?>`
    4. Inside there should be `<?php echo $product->get_price_html(); ?>`
    5. Now just add new things like:
 *  - `<?php echo $product->get_title(); ?>`
    - `<?php echo $product->get_categories(); ?>`
    - `<?php echo $product->get_sku(); ?>`
    - `<?php echo $product->get_image(); ?>`
 * Of course, you can get more detailed and put divs and things to style the output
   to look just like you are outputting a normal product using the shortcode `[product
   sku="ZN1U0000RS"]` for example.
 * This would be such sensationally easy functionality for woocommerce to add, i.
   e. when you put in the shortcode `[product sku="ZN1U0000RS"]` for example, it
   outputs the same regardless of whether it is a simple or variation of a variable
   product. Sometimes I want my client to add the variation I suggest, instead of
   having them go to the variable product page to select a variation. An sku is 
   an sku. An id is an id. A variation of a product should be treated just like 
   any other product. It deserved the same respect.
 *  [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * (@gabriel-reguly)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468787)
 * Beware that [myburgh.bernard@gmail.com](https://wordpress.org/support/topic/shortcode-for-product-variations/myburgh.bernard@gmail.com?output_format=md)‘
   s solution would be erased each time WooCommerce gets updated.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Shortcode for product variations’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [product variations](https://wordpress.org/support/topic-tag/product-variations/)

 * 7 replies
 * 5 participants
 * Last reply from: [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-product-variations/#post-6468787)
 * Status: resolved