function getLevelLimitReached($product_id, $post_id, $level) { global $wpdb; //$sql = "SELECT SUM(prod_price) AS LevelPurchaseTotal FROM ".$wpdb->prefix."ign_pay_info WHERE product_id = '".$product_id."' AND product_level = '".$level."'"; $sql = "SELECT COUNT(*) AS TotalOrders FROM " . $wpdb->prefix . "ign_pay_info WHERE product_id = '" . $product_id . "' AND product_level = '" . $level . "'"; //echo $sql."<br />"; $level_purchase_so_far = $wpdb->get_row($sql)->TotalOrders; if ($level_purchase_so_far == "") { //If there are no purchases $level_purchase_so_far will be empty, so putting condition $level_purchase_so_far = 0; } //echo "level_purchase_so_far: ".$level_purchase_so_far."<br />"; if ($level == 1) { $product_details = getProductDetails($product_id); if (isset($product_details)) { $meta_limit = $product_details->ign_product_limit; } } else { // getting the level limit set, from the wp_postmeta $meta_limit = get_post_meta($post_id, "ign_product_level_" . $level . "_limit", true); } // Setting the level limit to non-formatted number $meta_limit = floatval(preg_replace('/[^\\d.]/', '', $meta_limit)); if (empty($meta_limit)) { return false; } if ($level_purchase_so_far < $meta_limit) { return false; } else { if ($level_purchase_so_far >= $meta_limit) { return true; } } }
<?php include_once 'functions.php'; require $this->template_path . 'config.php'; ?> <div id="wrapper"> <?php $productId = mysql_real_escape_string($_POST['pid']); $pro_details = getProductDetails($productId); $product_brand = $pro_details["brand"]; $product_model = $pro_details["model"]; $product_marprice = $pro_details["mprice"]; $product_aucprice = $pro_details["aprice"]; $product_description = $pro_details["description"]; $product_time_end = $pro_details["aend"]; $product_time = $product_time_end - time(); $token_needed = $pro_details["bid"]; if ($token_needed <= 200) { $tokenneed = 1; } if ($token_needed <= 400 && $token_needed > 200) { $tokenneed = 2; } if ($token_needed <= 600 && $token_needed > 400) { $tokenneed = 3; } if ($token_needed <= 800 && $token_needed > 600) { $tokenneed = 4; } if ($token_needed <= 1000 && $token_needed > 800) { $tokenneed = 5;