When you’re using WC Vendors Pro plugin + WooCommerce Simple Auction extension, you might wants to change the calendar into a day range. For example : 1 Day, 3 Days, 7 Days, etc.

Still didn’t get what I mean? Please see the sample below.

How to do that?

What we need to do is go to wp-content/plugins/wc-vendors-pro-simple-auctions/class-wcv-simple-auctions.php and add these following pieces of code.

First, we need to build the form, here is the example :

// Auction Duration
WCVendors_Pro_Form_Helper::select( apply_filters( 'wcv_simple_auctions_auction_duration', array(
'post_id' => $post_id,
'id' => '_auction_duration',
'label' => __( '<i class="fa fa-calendar"></i> Duration', 'wc_simple_auctions' ),
'class' => 'form-control',
'desc_tip' => 'true',
'description' => sprintf( __( 'Select how long your listing will run.', 'wcvendors-pro-simple-auctions' ) ),
'wrapper_start' => '<div id="duration-box" class="column large-6">',
'wrapper_end' => '</div>',
'options' => array( '3' => __('3 days', 'wc_simple_auctions'),
'5' => __('5 days', 'wc_simple_auctions'),
'7' => __('7 days', 'wc_simple_auctions'),
'10' => __('10 days', 'wc_simple_auctions'))))

Next, after we have the form, we need to pass the value to the database. Here is the tricks :

//Start Date - Set default to todays date
update_post_meta( $post_id, '_auction_dates_from', stripslashes( date('Y-m-d H:i') ) );
//End Date - conditional
if (isset($_POST['_auction_duration'])):
$aucdur = $_POST['_auction_duration'] + 1;
$duration = "+".$aucdur." day";
update_post_meta( $post_id, '_auction_dates_to', stripslashes( date('Y-m-d H:i', strtotime($duration)) ) );

As you can see, on the default form we have Start Date and End Date. With this modified system, we will always use today’s date as the Start Date. And we will count the user’s selection as the End Date. For example, if we chose 3 Days, then the End Date will be today’s date + 3 days. Simple.

I hope it useful for anyone who wants to achieve the same thing.

Any questions? Feel free to leave your comment on the form below. 😉