Check data is an array in set_variation method

Closes #16232
This commit is contained in:
Mike Jolley 2017-07-24 10:43:34 +01:00
parent c5055ed2f7
commit 504a216582
1 changed files with 5 additions and 3 deletions

View File

@ -165,9 +165,11 @@ class WC_Order_Item_Product extends WC_Order_Item {
*
* @param array $data Key/Value pairs
*/
public function set_variation( $data ) {
foreach ( $data as $key => $value ) {
$this->add_meta_data( str_replace( 'attribute_', '', $key ), $value, true );
public function set_variation( $data = array() ) {
if ( is_array( $data ) ) {
foreach ( $data as $key => $value ) {
$this->add_meta_data( str_replace( 'attribute_', '', $key ), $value, true );
}
}
}