Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wp php get product item attributes name

$args = array(
    'category'  => array( 'category_slug' )
    // or 'term_taxonomy_id' => 4 i.e. category ID
);

foreach( wc_get_products($args) as $product ){

    foreach( $product->get_attributes() as $attr_name => $attr ){

        echo wc_attribute_label( $attr_name ); // attr label
        // or get_taxonomy( $attr_name )->labels->singular_name;

        foreach( $attr->get_terms() as $term ){

            echo $term->name;
        }
    }
}
Source by wordpress.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #wp #php #product #item #attributes
ADD COMMENT
Topic
Name
7+8 =