WC_AJAX::get_variation()
Get a matching variation based on posted attributes.
Метод класса: WC_AJAX{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = WC_AJAX::get_variation();
Код WC_AJAX::get_variation() WC AJAX::get variation WC 9.3.3
public static function get_variation() { ob_start(); // phpcs:disable WordPress.Security.NonceVerification.Missing if ( empty( $_POST['product_id'] ) ) { wp_die(); } $variable_product = wc_get_product( absint( $_POST['product_id'] ) ); if ( ! $variable_product ) { wp_die(); } $data_store = WC_Data_Store::load( 'product' ); $variation_id = $data_store->find_matching_product_variation( $variable_product, wp_unslash( $_POST ) ); $variation = $variation_id ? $variable_product->get_available_variation( $variation_id ) : false; wp_send_json( $variation ); // phpcs:enable }