1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
/** * Show all product attributes on the product page */ function isa_woocommerce_all_pa(){ global $product; $attributes = $product->get_attributes(); if ( ! $attributes ) { return; } $out = ''; foreach ( $attributes as $attribute ) { // skip variations if ( $attribute['is_variation'] ) { continue; } if ( $attribute['is_taxonomy'] ) { $terms = wp_get_post_terms( $product->id, $attribute['name'], 'all' ); // get the taxonomy $tax = $terms[0]->taxonomy; // get the tax object $tax_object = get_taxonomy($tax); // get tax label if ( isset ($tax_object->labels->name) ) { $tax_label = $tax_object->labels->name; } elseif ( isset( $tax_object->label ) ) { $tax_label = $tax_object->label; } foreach ( $terms as $term ) { $out .= $tax_label . ': '; $out .= $term->name . '<br />'; } } else { $out .= $attribute['name'] . ': '; $out .= $attribute['value'] . '<br />'; } } echo $out; } add_action('woocommerce_single_product_summary', 'isa_woocommerce_all_pa', 25); |