[REST API] Fixed a minor bug that prevents saving default_attributes

This commit is contained in:
Claudio Sanches 2017-03-23 17:19:07 -03:00
parent 590c78ca98
commit 8371882002
2 changed files with 3 additions and 2 deletions

View File

@ -1188,7 +1188,8 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
*/
protected function save_default_attributes( $product, $request ) {
if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) {
$attributes = $product->get_variation_attributes();
$attributes = $product->get_attributes();
$default_attributes = array();
foreach ( $request['default_attributes'] as $attribute ) {

View File

@ -1003,7 +1003,7 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller {
*/
protected function save_default_attributes( $product, $request ) {
if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) {
$attributes = $product->get_variation_attributes();
$attributes = $product->get_attributes();
$default_attributes = array();
foreach ( $request['default_attributes'] as $attribute ) {