Skip to content

Instantly share code, notes, and snippets.

@cdsaenz
Forked from gorkamu/Woo_WC_Product_Variable.php
Created October 4, 2022 00:51
Show Gist options
  • Save cdsaenz/8e5aa715e5f125a2074ee1562bfe8946 to your computer and use it in GitHub Desktop.
Save cdsaenz/8e5aa715e5f125a2074ee1562bfe8946 to your computer and use it in GitHub Desktop.
Extended Woocommerce Variation Class
<?php
class Woo_WC_Product_Variable extends WC_Product_Variable {
public function get_all_variations() {
$available_variations = array();
foreach($this->get_children() as $child_id){
$variation = wc_get_product($child_id);
$available_variations[] = $this->get_available_variation($variation);
}
return array_values(array_filter($available_variations));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment