This is super easy to do with meta_query
s:
$args = array(
//basics
'post_type' => 'prizes', // from question
'post_status' => 'publish', // you didn't have this, but it's good practice
'posts_per_page' => 3, // I don't know where you got 'showposts', but that's WAY old
//order
'orderby' => 'rand',
//meta query
'meta_query' => array(
array(
'key' => $my_meta['pointsvalue'],
'value' => ( $calctotalnew - number_format( $cart->total, 2 ) ),
'compare' => '<=',
'type' => 'NUMERIC'
)
)
);
$my_query = new WP_Query( $args );
Also, your $do_not_duplicate
is completely non-sensical. It’s setup but never called, you probably want to address that.
I filled in some of the details for you, they may not be right. The documentation on WP_Query
will help you get everything correct.