Skip to content

Commit

Permalink
fix: added attribute slug with product api
Browse files Browse the repository at this point in the history
  • Loading branch information
kapilpaul committed Nov 27, 2020
1 parent 944cc89 commit 955f5cf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions includes/REST/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1412,12 +1412,14 @@ protected function get_attributes( $product ) {
$option_term = get_term_by( 'slug', $attribute, $name );
$attributes[] = array(
'id' => wc_attribute_taxonomy_id_by_name( $name ),
'slug' => $attribute_name,
'name' => $this->get_attribute_taxonomy_name( $name, $_product ),
'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->name : $attribute,
);
} else {
$attributes[] = array(
'id' => 0,
'slug' => $attribute_name,
'name' => $this->get_attribute_taxonomy_name( $name, $_product ),
'option' => $attribute,
);
Expand All @@ -1427,6 +1429,7 @@ protected function get_attributes( $product ) {
foreach ( $product->get_attributes() as $attribute ) {
$attributes[] = array(
'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name( $attribute['name'] ) : 0,
'slug' => $attribute['name'],
'name' => $this->get_attribute_taxonomy_name( $attribute['name'], $product ),
'position' => (int) $attribute['position'],
'visible' => (bool) $attribute['is_visible'],
Expand Down

0 comments on commit 955f5cf

Please sign in to comment.