Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 3be6767

Browse files
authored
show attributes in simple products (#6274)
1 parent 1e5dfec commit 3be6767

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/StoreApi/Schemas/V1/ProductSchema.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,14 +659,15 @@ protected function get_attributes( \WC_Product $product ) {
659659
$return = [];
660660

661661
foreach ( $attributes as $attribute_slug => $attribute ) {
662-
// Only visible and variation attributes will be exposed by this API.
663-
if ( ! $attribute->get_visible() || ! $attribute->get_variation() ) {
662+
// Only visible or variation attributes will be exposed by this API.
663+
if ( ! $attribute->get_visible() && ! $attribute->get_variation() ) {
664664
continue;
665665
}
666666

667667
$terms = $attribute->is_taxonomy() ? array_map( [ $this, 'prepare_product_attribute_taxonomy_value' ], $attribute->get_terms() ) : array_map( [ $this, 'prepare_product_attribute_value' ], $attribute->get_options() );
668668
// Custom attribute names are sanitized to be the array keys.
669669
// So when we do the array_key_exists check below we also need to sanitize the attribute names.
670+
670671
$sanitized_attribute_name = sanitize_key( $attribute->get_name() );
671672

672673
if ( array_key_exists( $sanitized_attribute_name, $default_attributes ) ) {

0 commit comments

Comments
 (0)