How to manage bundles in default Woocommerce?
- Create a Variable product
- Add Only one attribute e.g. Packages
- Enter attribute values with pipe signs
- Go to variations tab and pre select attributes values for each value
- Put different prices for each variation
Ready!
Now use the following code to get an array or packages and variations:
$packages = array();
if($variable){
$product_details = new WC_Product_Variable(get_the_ID());
$variations = $product_details->get_available_variations();
if(!empty($variations)){
foreach($variations as $data){
$attr = $data['attributes'];
$package_key = array_keys($attr);
$attr = array_filter($attr, 'strlen');
$attr = current($attr);
$packages[$attr] = $data['variation_id'];
}
$package_key = current($package_key);
}
}
Last updated: May 29, 2014