function wc_redirects__add_to_cart_redirect($url)
{
    static $cached_result = null;
    if (isset($cached_result)) {
        return $cached_result;
    }
    if (!isset($_REQUEST['add-to-cart'])) {
        return $url;
    }
    $product_id = apply_filters('woocommerce_add_to_cart_product_id', absint($_REQUEST['add-to-cart']));
    $selected_redirection_type = get_post_meta($product_id, WC_REDIRECTS__REDIRECTION_TYPE_META_NAME, true);
    if (!empty($selected_redirection_type)) {
        foreach (wc_redirects__get_valid_redirection_types() as $redirection_type) {
            if ($redirection_type['name'] === $selected_redirection_type) {
                $result = call_user_func($redirection_type['callback']);
                if ($result === false) {
                    wc_add_notice("Item added to cart, but redirection " . "to {$redirection_type['label']} failed.");
                } else {
                    $url = $result;
                }
                break;
            }
        }
    }
    return $cached_result = $url;
}
function wc_redirects__wc_admin_product_data_panels()
{
    global $post;
    /** @noinspection PhpUnusedLocalVariableInspection */
    $selected_redirection_type = get_post_meta($post->ID, WC_REDIRECTS__REDIRECTION_TYPE_META_NAME, true);
    /** @noinspection PhpUnusedLocalVariableInspection */
    $redirection_types = wc_redirects__get_valid_redirection_types();
    /** @noinspection PhpUnusedLocalVariableInspection */
    $redirection_type_meta_name = WC_REDIRECTS__REDIRECTION_TYPE_META_NAME;
    include WC_REDIRECTS__TEMPLATES_DIR . 'wc-admin/product-data-panel.php';
}