Merge pull request #13744 from woocommerce/fix/rest-api-variation-default-attributes
[REST API] Fixed a minor bug that prevents saving default_attributes
This commit is contained in:
commit
b3fc0f31fa
|
@ -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 ) {
|
||||
|
|
|
@ -820,13 +820,14 @@ class WC_API_Products extends WC_API_Resource {
|
|||
* @param array $request
|
||||
* @return WC_Product
|
||||
*/
|
||||
protected function save_default_attributes( $product, $request ) {
|
||||
protected function save_default_attributes( $product, $request ) {
|
||||
// Update default attributes options setting.
|
||||
if ( isset( $request['default_attribute'] ) ) {
|
||||
$request['default_attributes'] = $request['default_attribute'];
|
||||
}
|
||||
|
||||
if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) {
|
||||
$attributes = $product->get_attributes();
|
||||
$default_attributes = array();
|
||||
|
||||
foreach ( $request['default_attributes'] as $default_attr_key => $default_attr ) {
|
||||
|
|
|
@ -1312,6 +1312,7 @@ class WC_API_Products extends WC_API_Resource {
|
|||
}
|
||||
|
||||
if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) {
|
||||
$attributes = $product->get_attributes();
|
||||
$default_attributes = array();
|
||||
|
||||
foreach ( $request['default_attributes'] as $default_attr_key => $default_attr ) {
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue