A little php help with simple auction integration?

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Ultimate A little php help with simple auction integration?

Viewing 8 reply threads
  • Author
    Posts
    • #109118
      James Bieniek
      Participant

      I am looking to make auction listing more uniform/streamlined.

      I don’t want users to have to select the start date, end date, and relisting duration – I want these to be hard-coded to be uniform.

      I managed to get an instant auction start using “timestamp”. I then needed help coding 14 days duration. He came up with some new bits, but i am having trouble, it gets over-ridden or whatever. I am sure this is simple for anyone that knows php and a bit about this plugin. Below is specifically what im looking at with some extra comments:

      /* He gave me this 3 lines instead of ‘timestamp’ – add two variables */
      $_format=”Y-m-d h:m:s”; //format of the date (I like m-d-Y, but seems the actual auction plugin displays it anyway.)
      $_CurrentTime=new DateTime(); //get current date from system
      $_Current_to=$_CurrentTime->add(new DateInterval(‘P14D’)); // add 14 days to the current day

      ^I assume that will work one way or another…

      $product_id = 0;
      $_auction_item_condition = ‘new’;
      $_auction_type = ‘normal’;
      $_auction_proxy = get_option(‘simple_auctions_proxy_auction_on’, ‘no’);
      $_auction_sealed = ‘no’;
      $_auction_start_price = ”;
      $_auction_bid_increment = ”;
      $_auction_reserved_price = ”;
      $_regular_price = ”;
      ^all this above is fine, just added for context

      $_auction_dates_from = ‘$_CurrentTime->format($_format)’; <-this apparently works
      $_auction_dates_to = ‘$_Current_to->format($_format)’; <-perhaps this will work if I remove some code from bottom of file or just css display:none? lol

      $relist_auction_dates_from = ”;
      $relist_auction_dates_to = ”; <-IDK about these 2 considering above edits, regardless I would like 14 days relisting, only option: yes/no which is already there via checkbox

      $_auction_automatic_relist = ”;
      $_auction_relist_fail_time = ”;
      $_auction_relist_not_paid_time = ”;
      $_auction_relist_duration = ”; <- simply type: “14 days”?

      …Below would be more code (you may see all in attached file) I think some of it needs to be removed for above edits to work correctly?

    • #109119
      James Bieniek
      Participant

      Here is the whole code (hopefully)…I needed to change to txt file

    • #109872
      WCFM Forum
      Member

      HI,

      Please do not edit template, add this code to your site for the purpose –

      add_filter( 'wcfm_product_manage_wcsauction_fields', function( $auction_fileds, $product_id ) {
        if( !$product_id ) {
        	$_format = "Y-m-d h:m:s";
        	$_CurrentTime = new DateTime();
        	if( isset( $auction_fileds['_auction_dates_from'] ) ) {
        		$auction_fileds['_auction_dates_from']['value'] = $_CurrentTime->format($_format);
      		}
      		if( isset( $auction_fileds['_auction_dates_to'] ) ) {
      			$_Current_to = $_CurrentTime->add(new DateInterval('P14D')); 
      			$auction_fileds['_auction_dates_to']['value'] = $_Current_to->format($_format);
      		}
        }
        $auction_fileds = wcfm_hide_field( '_auction_dates_from', $auction_fileds );
        $auction_fileds = wcfm_hide_field( '_auction_dates_to', $auction_fileds );
        return $auction_fileds;
      }, 50, 2 );

      Add this code to your child theme’s functions.php
      In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/

      Thank You

    • #115039
      Auhouse.ru
      Participant

      I need the same code, only for 24 hours

    • #115285
      WCFM Forum
      Member

      OK, please try this revised code –

      add_filter( 'wcfm_product_manage_wcsauction_fields', function( $auction_fileds, $product_id ) {
        if( !$product_id ) {
        	$_format = "Y-m-d h:m:s";
        	$_CurrentTime = new DateTime();
        	if( isset( $auction_fileds['_auction_dates_from'] ) ) {
        		$auction_fileds['_auction_dates_from']['value'] = $_CurrentTime->format($_format);
      		}
      		if( isset( $auction_fileds['_auction_dates_to'] ) ) {
      			$_Current_to = $_CurrentTime->add(new DateInterval('P1D')); 
      			$auction_fileds['_auction_dates_to']['value'] = $_Current_to->format($_format);
      		}
        }
        $auction_fileds = wcfm_hide_field( '_auction_dates_from', $auction_fileds );
        $auction_fileds = wcfm_hide_field( '_auction_dates_to', $auction_fileds );
        return $auction_fileds;
      }, 50, 2 );

      Thank You

    • #115297
      Auhouse.ru
      Participant

      I added the code, I added the auction and it lasts 8 hours, I need 24 hours

      Attachments:
      You must be logged in to view attached files.
    • #115550
      WCFM Forum
      Member

      Please use this revised code –

      add_filter( 'wcfm_product_manage_wcsauction_fields', function( $auction_fileds, $product_id ) {
        if( !$product_id ) {
        	$_format = "Y-m-d H:i";
        	$_CurrentTime = current_time( 'timestamp', 0 );
        	if( isset( $auction_fileds['_auction_dates_from'] ) ) {
        		$auction_fileds['_auction_dates_from']['value'] = date( $_format, $_CurrentTime );
      		}
      		if( isset( $auction_fileds['_auction_dates_to'] ) ) {
      			$auction_fileds['_auction_dates_to']['value'] = date( $_format, strtotime('+1 day', $_CurrentTime ) );
      		}
        }
        $auction_fileds = wcfm_hide_field( '_auction_dates_from', $auction_fileds );
        $auction_fileds = wcfm_hide_field( '_auction_dates_to', $auction_fileds );
        return $auction_fileds;
      }, 50, 2 );

      Thank You

    • #118478
      Auhouse.ru
      Participant

      The code works for new products. When transferring from ordinary goods to auction, dates are not set

    • #125658
      Auhouse.ru
      Participant

      Hello, is there a solution?

Viewing 8 reply threads
  • You must be logged in to reply to this topic.