echo '<div class="notice">Sorry!!! You Don&rsquo;t Have Permission To This Action As You Already Confirmed Your Purchase Interest</div>';
        }
    } elseif ($valid_action && $_REQUEST['action'] == "edit") {
        $product_name = $_REQUEST['product_name'];
        wp_redirect(get_site_url() . '/product/' . $product_name . '/?product_interest_id=' . $product_interest_id, 301);
        exit;
        //$remove_success = wp_remove_interest( $current_user_id, $product_interest_id );
    } elseif ($valid_action && $_REQUEST['action'] == "interest_confirmed") {
        $user_interest_info = user_product_interest_details($product_interest_id);
        $interest_confirmation_link_expire = $user_interest_info[0]->interest_confirmation_link_expire;
        if ($user_interest_info[0]->interest_confirmation_link_expire) {
            $time_now = mktime(date('H'), date('i'), 0, date('m'), date('d'), date('Y'));
            if ($interest_confirmation_link_expire >= $time_now) {
                $wp_product_interest_data = array("interest_confirmed" => 1);
                $format_array = array("%d");
                $confirmed_success = wp_product_interest_update($wp_product_interest_data, $format_array, $product_interest_id);
            } else {
                $expire_error = _e("Sorry!!! Your Purchase Confirmation Time expired");
            }
        } else {
            $expire_error = _e("Sorry!!! Your Purchase Confirmation Time Not Set Yet");
        }
    } else {
        $action_error = 1;
    }
}
//$product_attributes = get_field('attributes');
$product_attributes = array();
$my_interest_list = wp_my_interest_list($current_user_id);
?>
		<!-- MAIN CONTENT -->	  	
function product_interest_insert($product_id)
{
    // Prepare Data to insert in wp_product_interest: Table and wp_product_interest_meta:Table
    global $wp_interest_form_data, $interest_start_date_time_as_text, $interest_start_date, $interest_end_date, $product_attributes, $product_data;
    $product_attributes = get_field('attributes');
    $wp_interest_form_data['user_id'] = $product_data['post_author'];
    $wp_interest_form_data['product_id'] = $product_id;
    $wp_interest_form_data['product_name'] = $product_data['post_title'];
    if ($wp_interest_form_data['asa_price_is_reasonable']) {
        $wp_interest_form_data['asa_price_is_reasonable'] = 1;
        $wp_interest_form_data['interest_start_date'] = "";
        $wp_interest_form_data['interest_date_range'] = "";
        $wp_interest_form_data['interest_end_date'] = "";
    } elseif ($interest_start_date_time_as_text) {
        $interest_end_date = date('Y-m-d', strtotime($interest_start_date . ' + ' . $wp_interest_form_data['interest_date_range'] . 'days'));
        $interest_end_date_arr = explode("-", $interest_end_date);
        $interest_end_date_time_as_text = mktime(0, 0, 0, $interest_end_date_arr[1], $interest_end_date_arr[2], $interest_end_date_arr[0]);
        $wp_interest_form_data['interest_end_date'] = $interest_end_date_time_as_text;
    }
    if (!is_user_logged_in()) {
        $wp_product_interest_data['user_id'] = "visitor";
    }
    $wp_interest_form_data['add_date'] = date("Y-m-d");
    if ($product_attributes) {
        foreach ($product_attributes as $product_attribute) {
            $product_attr[] = array('name' => $product_attribute['label'], 'value' => $_POST[$product_attribute['label']]);
        }
    }
    if (empty($product_interest_id)) {
        $product_interest_insert_id = wp_product_interest_insert($wp_interest_form_data, $format_array);
        if ($product_interest_insert_id && sizeof($product_attr) > 0) {
            $product_interest_meta_insert_id = wp_product_interest_meta_insert($product_interest_insert_id, $wp_interest_form_data, $product_attr);
        }
    }
    if (!empty($product_interest_id) && !$my_interest_meta_data[0]->interest_confirmed) {
        $product_interest_update_id = wp_product_interest_update($wp_interest_form_data, $format_array, $product_interest_id);
        $product_interest_meta_update_id = wp_product_interest_meta_update($product_interest_id, $wp_interest_form_data, $product_attr);
    }
    if ($product_interest_insert_id) {
        echo '<div class="notice">Congratulations!!! Product ' . $wp_interest_form_data['product_name'] . ' was successfully added to your interest list! <span class="close"></span></div>';
    } elseif ($product_interest_update_id || $product_interest_meta_update_id) {
        echo '<div class="notice">Congratulations!!! Product ' . $wp_interest_form_data['product_name'] . ' was successfully updated to your interest list! <span class="close"></span></div>';
    }
    if ($my_interest_meta_data[0]->interest_confirmed) {
        echo '<div class="notice">Sorry!!! You Don&rsquo;t Have Permission To This Action As You Already Confirmed Your Purchase Interest</div>';
    }
    if ($product_interest_id) {
        $valid_action = wp_check_valid_user_action($current_user_id, $product_interest_id, "product_interest");
        if ($valid_action) {
            $my_interest_meta_data = wp_my_interest_meta($current_user_id, $product_interest_id);
            if ($my_interest_meta_data) {
                foreach ($my_interest_meta_data as $my_interest_meta) {
                    $interest_meta_array[$my_interest_meta->meta_name] = $my_interest_meta->meta_value;
                }
            }
        }
    }
}