Warn users of shipping rates to test for existence of meta_data correctly.

As per the info in the issue itself, using `isset()` gives incorrect result all the time, so warn developers about the problem.
This commit is contained in:
Peter Fabian 2021-10-15 13:30:34 +02:00 committed by Nestor Soriano
parent 3611d46437
commit 4ea28030f2
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
1 changed files with 3 additions and 0 deletions

View File

@ -65,6 +65,9 @@ class WC_Shipping_Rate {
* @return bool
*/
public function __isset( $key ) {
if ( 'meta_data' === $key ) {
wc_doing_it_wrong( __FUNCTION__, __( 'Use `array_key_exists` to check for meta_data on Shipping rates to get the correct result.', 'woocommerce' ), '6.0' );
}
return isset( $this->data[ $key ] );
}