From 45370d3e61c5d3ac61fb426fd70b2e12af18d790 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 23 Nov 2018 11:00:30 -0400 Subject: [PATCH] fix `0` value attribute permalink calculation, property population in REST api --- includes/api/v2/class-wc-rest-products-v2-controller.php | 2 +- includes/class-wc-product-variation.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/api/v2/class-wc-rest-products-v2-controller.php b/includes/api/v2/class-wc-rest-products-v2-controller.php index 0a9e5ecc868..c9ca9b612c7 100644 --- a/includes/api/v2/class-wc-rest-products-v2-controller.php +++ b/includes/api/v2/class-wc-rest-products-v2-controller.php @@ -524,7 +524,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_Legacy_Products_Controller foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { $name = str_replace( 'attribute_', '', $attribute_name ); - if ( ! $attribute ) { + if ( empty( $attribute ) && '0' !== $attribute ) { continue; } diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php index e0d157cd972..55b6a947ed3 100644 --- a/includes/class-wc-product-variation.php +++ b/includes/class-wc-product-variation.php @@ -167,7 +167,7 @@ class WC_Product_Variation extends WC_Product_Simple { $data = $this->get_variation_attributes(); } - $data = array_filter( $data ); + $data = array_filter( $data, 'wc_array_filter_default_attributes' ); if ( empty( $data ) ) { return $url;