function fre_update_after_bidding($bid_id) { global $user_ID; if ('publish' != get_post_status($bid_id)) { wp_update_post(array('ID' => $bid_id, 'post_status' => 'publish')); } $project_id = get_post_field('post_parent', $bid_id); //update avg bids for project $total_bids = get_number_bids($project_id); $avg = get_post_meta($bid_id, 'bid_average', true); if ($total_bids > 0) { $avg = get_total_cost_bids($project_id) / $total_bids; } update_post_meta($project_id, 'bid_average', number_format($avg, 2)); update_post_meta($project_id, 'total_bids', $total_bids); $this->mail->bid_mail($bid_id); $pay_credit = get_credit_to_pay(); $pay_credit = -$pay_credit; update_credit_number($user_ID, $pay_credit); fre_update_user_free_bid_number(); wp_send_json(array('success' => true, 'msg' => __('You are bid successful', ET_DOMAIN))); }
<?php /** * The template for display a list bids of a project * @since 1.0 * @author Dakachi */ global $wp_query, $ae_post_factory, $post, $user_ID; $post_object = $ae_post_factory->get(PROJECT); $project = $post_object->current_post; $number_bids = (int) get_number_bids(get_the_ID()); //$sum = (float) get_total_cost_bids( get_the_ID() ); add_filter('posts_orderby', 'fre_order_by_bid_status'); $q_bid = new WP_Query(array('post_type' => BID, 'post_parent' => get_the_ID(), 'post_status' => array('publish', 'complete', 'accept'))); remove_filter('posts_orderby', 'fre_order_by_bid_status'); $biddata = array(); ?> <div class="col-xs-12 col-md-8"> <div class="row title-tab-project <?php if ($q_bid->found_posts < 1) { echo 'display-none'; } ?> "> <div class="col-xs-4 col-md-4"> <span><?php
function fre_update_after_bidding($bid_id) { if ('publish' != get_post_status($bid_id)) { wp_update_post(array('ID' => $bid_id, 'post_status' => 'publish')); } $project_id = get_post_field('post_parent', $bid_id); //update avg bids for project $total_bids = get_number_bids($project_id); $avg = get_post_meta($bid_id, 'bid_average', true); if ($total_bids > 0) { $avg = get_total_cost_bids($project_id) / $total_bids; } update_post_meta($project_id, 'bid_average', number_format($avg, 2)); update_post_meta($project_id, 'total_bids', $total_bids); $this->mail->bid_mail($bid_id); wp_send_json(array('success' => true, 'msg' => __('You are bid successful', 'bids-backend'))); }