get_meta( '_custom_thank_you_page' ); $priority = $product->get_meta( '_custom_thank_you_page_priority' ); if ( \WooCommerce_Custom_Thank_You_Pages\is_url( $value ) ) { $selected_value = esc_url( $value ); $selected_text = $selected_value; } elseif ( is_numeric( $value ) && $value != 0 ) { $selected_value = absint( $value ); $selected_text = get_the_title( $selected_value ); } else { $selected_value = null; $selected_text = null; } ?>
get_meta( '_custom_thank_you_page' ); $priority = $variation->get_meta( '_custom_thank_you_page_priority' ); if ( \WooCommerce_Custom_Thank_You_Pages\is_url( $value ) ) { $selected_value = esc_url( $value ); $selected_text = $selected_value; } elseif ( is_numeric( $value ) && $value != 0 ) { $selected_value = absint( $value ); $selected_text = get_the_title( $selected_value ); } else { $selected_value = null; $selected_text = null; } ?>update_meta_data( '_custom_thank_you_page', esc_url_raw( $url ) ); } elseif ( get_post_status( $url ) !== false ) { $product->update_meta_data( '_custom_thank_you_page', absint( $url ) ); } else { $product->update_meta_data( '_custom_thank_you_page', '' ); } } if ( isset( $_POST['custom_thank_you_page_priority'] ) ) { $product->update_meta_data( '_custom_thank_you_page_priority', absint( $_POST['custom_thank_you_page_priority'] ) ); } $product->save(); update_excluded_thank_you_pages(); } add_action( 'woocommerce_process_product_meta', 'WooCommerce_Custom_Thank_You_Pages\Admin\save_custom_thank_you_page', 10 ); /** * Save variation custom thank you page value. * * Save the set custom thank you page URL or post ID to the meta table. * * @since 1.0.0 * * @param int $variation_id Variation ID being saved. * @param int $i Index of variation. */ function save_variable_custom_thank_you_page( $variation_id, $i ) { $custom_thank_you_page = $_POST['variable_custom_thank_you_page'] ?: array(); foreach ( $custom_thank_you_page as $k => $v ) { if ( ! isset( $custom_thank_you_page[ $i ] ) ) { continue; } $variation = wc_get_product( $variation_id ); $value = $custom_thank_you_page[ $i ]; if ( \WooCommerce_Custom_Thank_You_Pages\is_url( $value ) ) { $variation->update_meta_data( '_custom_thank_you_page', esc_url_raw( $value ) ); } elseif ( get_post_status( $value ) !== false ) { $variation->update_meta_data( '_custom_thank_you_page', absint( $value ) ); } else { $variation->update_meta_data( '_custom_thank_you_page', '' ); } $variation->update_meta_data( '_custom_thank_you_page_priority', absint( $_POST['custom_thank_you_page_priority'] ) ); $variation->save(); } update_excluded_thank_you_pages(); } add_action( 'woocommerce_save_product_variation', 'WooCommerce_Custom_Thank_You_Pages\Admin\save_variable_custom_thank_you_page', 10, 2 );