add_action( 'woocommerce_after_bid_button', 'custom_add_coment_textarea_on_bid',10);
function custom_add_coment_textarea_on_bid(){
global $product;
echo '<div class="coment-on-bid" style="clear:both">';
_e('Note:');
echo '<textarea name="coment_on_bid"></textarea>';
echo '</div>';
}
add_filter('woocommerce_simple_auctions_before_place_bid_filter', 'check_if_there_is_note_on_bid',10);
function check_if_there_is_note_on_bid($product_data){
global $_POST;
if( (!isset($_POST['coment_on_bid'] ) or !$_POST['coment_on_bid']) && $product_data->get_auction_sealed() == 'yes'){
wc_add_notice(__('You must add note to your bid!', 'wc_simple_auctions'), 'error');
return false;
}
return $product_data;
}
add_action('woocommerce_simple_auctions_log_bid', 'custom_save_comment_on_bid', 10, 4 );
function custom_save_comment_on_bid($log_bid_id, $product_id,$bid, $current_user ){
global $_POST;
if(isset($_POST['coment_on_bid'] ) AND $_POST['coment_on_bid'] AND ($log_bid_id )){
add_post_meta($data['product_id'], 'bid_note_'.$log_bid_id , sanitize_text_field( $_POST['coment_on_bid']),true);
}
}
add_action('woocommerce_simple_auction_admin_history_header','add_note_woocommerce_simple_auction_admin_history_header');
function add_note_woocommerce_simple_auction_admin_history_header($product){
if($product->get_auction_sealed() == 'yes'){
echo '<th>';
_e('Note', 'wc_simple_auctions');
echo '</th>';
}
}
add_action('woocommerce_simple_auction_admin_history_row','add_note_woocommerce_simple_auction_admin_history_row',10,2);
function add_note_woocommerce_simple_auction_admin_history_row($product, $auction_history){
$bid_note = get_post_meta( $product->get_id(), 'bid_note_'.$auction_history->id, true );
echo '<td>';
echo $bid_note;
echo '</td>';
}
Comments