WC_Coupon_Data_Store_CPT::get_coupon_meta_as_array
Get a metadata value that is stored as either a string consisting of a comma-separated list of values or as a serialized array.
WooCommerce always stores the coupon product ids as a comma-separated string, but it seems that some plugins mistakenly change these to an array.
Метод класса: WC_Coupon_Data_Store_CPT{}
Хуков нет.
Возвращает
Массив. The metadata value as an array, with empty values removed.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_coupon_meta_as_array( $coupon_id, $meta_key );
- $coupon_id(int) (обязательный)
- The coupon id.
- $meta_key(строка) (обязательный)
- The meta key to get.
Код WC_Coupon_Data_Store_CPT::get_coupon_meta_as_array() WC Coupon Data Store CPT::get coupon meta as array WC 10.6.2
private function get_coupon_meta_as_array( $coupon_id, string $meta_key ) {
$meta_value = get_post_meta( $coupon_id, $meta_key, true );
return array_filter(
is_array( $meta_value ) ? $meta_value : explode( ',', $meta_value )
);
}