Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Ultimate › A little php help with simple auction integration?
Tagged: custom php, simple auctions
- This topic has 8 replies, 3 voices, and was last updated 4 years, 6 months ago by Auhouse.ru.
- AuthorPosts
- February 28, 2020 at 1:14 am #109118James BieniekParticipant
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?
- February 28, 2020 at 1:21 am #109119James BieniekParticipant
Here is the whole code (hopefully)…I needed to change to txt file
- March 4, 2020 at 1:38 pm #109872WCFM ForumMember
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
- April 3, 2020 at 2:58 pm #115039Auhouse.ruParticipant
I need the same code, only for 24 hours
- April 4, 2020 at 1:42 pm #115285WCFM ForumMember
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
- April 4, 2020 at 2:19 pm #115297Auhouse.ruParticipant
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. - April 5, 2020 at 10:50 am #115550WCFM ForumMember
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
- April 12, 2020 at 8:29 pm #118478Auhouse.ruParticipant
The code works for new products. When transferring from ordinary goods to auction, dates are not set
- May 2, 2020 at 1:29 pm #125658Auhouse.ruParticipant
Hello, is there a solution?
- AuthorPosts
- You must be logged in to reply to this topic.