Created
September 15, 2016 11:15
-
-
Save mohammadmursaleen/d8b8ed269f91173f669aefdd9e4fc339 to your computer and use it in GitHub Desktop.
WooCommerce funciton to get prices of all variations on single product page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('woocommerce_before_single_product','mm_display_variations_with_prices'); | |
function mm_display_variations_with_prices(){ | |
global $product,$woocommerce; | |
$variations = $product->get_available_variations(); | |
foreach($variations as $variation){ | |
echo '<pre>'; | |
$product_variation = new WC_Product_Variation($variation['variation_id']); | |
$regular_price = $product_variation->regular_price; | |
var_dump($variation['variation_id'] . ' -- ' . $regular_price); | |
echo '</pre>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment