Hello guys how are you? Welcome back to my blog therichpost.com. Guys today in this post, I will tell you Integrating a bidding/auction feature into Dokan Multivendor
Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:
Here is the working steps and please follow carefully:
Integrating a bidding/auction feature into Dokan Multivendor (a WordPress-based marketplace solution) can be done using a combination of plugins and custom development. Here’s how you can do it:
1. Using an Auction Plugin (Recommended for Ease)
The easiest way to add bidding functionality is by using an auction plugin that integrates with WooCommerce and works alongside Dokan. Some good options include:
A. WooCommerce Simple Auctions
📌 Link: WooCommerce Simple Auctions
✅ Features:
- Fully compatible with WooCommerce
- Supports standard, reverse, and sealed auctions
- Allows vendors to list auctions
How to Integrate:
- Install & activate WooCommerce Simple Auctions.
- Configure auction settings in WooCommerce > Settings > Auctions.
- Allow vendors to create auction products by configuring Dokan settings.
- Ensure auction functionality works with Dokan’s vendor dashboard.
B. YITH Auctions for WooCommerce
📌 Link: YITH Auctions
✅ Features:
- Allows scheduled auctions
- Supports automatic and manual bidding
- Works with Dokan (but requires testing for full compatibility)
Setup:
- Install YITH Auctions for WooCommerce.
- Enable auction product types for vendors.
- Adjust auction settings based on your marketplace needs.
2. Custom Development (If You Need Full Control)
If you need a deeply integrated, custom bidding system, you can develop it using custom code inside your child theme or via a custom plugin.
Steps for Custom Development:
- Extend WooCommerce Product Types
- Create a new product type called
auction
in WooCommerce. - Modify Dokan’s product submission form to include auction fields.
- Auction Logic Implementation
- Set bid increments, start/end times, reserve prices.
- Use AJAX to handle real-time bidding updates.
- Implement winner selection & automatic payment processing.
- Vendor Dashboard Integration
- Allow vendors to manage their auctions within Dokan’s vendor dashboard.
- Provide bid history and auction status updates.
- User Notifications & Payments
- Notify bidders when they are outbid.
- Ensure payment is processed securely via WooCommerce after an auction ends.
3. Using an Add-On for Dokan (If Available)
Check if Dokan or third-party developers provide an auction add-on. Sometimes, specialized Dokan add-ons exist that integrate directly with WooCommerce Auctions.
Which Option is Best?
🔹 For Quick & Easy Setup: Use WooCommerce Simple Auctions
🔹 For Flexibility & More Features: Use YITH Auctions
🔹 For Custom Solutions: Develop a custom bidding system inside Dokan
Do you need a plugin recommendation based on your marketplace setup? 🚀
🛠 Steps to Build a Custom Auction Feature in Dokan
1. Extend WooCommerce to Support Auctions
Dokan vendors list products using WooCommerce product types, so you’ll need to add an auction product type.
👉 Define a New Auction Product Type
Add this code in your custom plugin or functions.php
of your child theme:
function register_auction_product_type() { class WC_Product_Auction extends WC_Product { public function __construct($product) { parent::__construct($product); $this->product_type = 'auction'; } } } add_action('init', 'register_auction_product_type');
Then, allow this product type in WooCommerce:
function add_auction_product_type($types) { $types['auction'] = __('Auction', 'your-text-domain'); return $types; } add_filter('product_type_selector', 'add_auction_product_type');
2. Modify Dokan’s Product Submission Form
By default, Dokan doesn’t have an auction option, so we need to modify the Dokan product submission form to include auction fields.
👉 Add Auction Fields in Vendor Dashboard
Use the dokan_product_edit_after_inventory_variants
hook to insert fields:
function dokan_add_auction_fields() { ?> <div class="dokan-form-group"> <label for="auction_start_price"><?php _e('Starting Price', 'your-text-domain'); ?></label> <input type="number" class="dokan-form-control" name="auction_start_price" required> </div> <div class="dokan-form-group"> <label for="auction_end_time"><?php _e('End Time', 'your-text-domain'); ?></label> <input type="datetime-local" class="dokan-form-control" name="auction_end_time" required> </div> <?php } add_action('dokan_product_edit_after_inventory_variants', 'dokan_add_auction_fields');
3. Save Auction Data
When the vendor submits a product, save auction-related fields.
function save_dokan_auction_meta($post_id) { if (isset($_POST['auction_start_price'])) { update_post_meta($post_id, '_auction_start_price', sanitize_text_field($_POST['auction_start_price'])); } if (isset($_POST['auction_end_time'])) { update_post_meta($post_id, '_auction_end_time', sanitize_text_field($_POST['auction_end_time'])); } } add_action('dokan_process_product_meta', 'save_dokan_auction_meta');
4. Handle Bidding System
You’ll need to create a bidding form and update the highest bid dynamically.
👉 Add Bidding Form on Product Page
Modify the WooCommerce product page template to show a bid form if it’s an auction product.
function display_bid_form() { global $product; if ($product->get_type() !== 'auction') { return; } $current_bid = get_post_meta($product->get_id(), '_highest_bid', true) ?: get_post_meta($product->get_id(), '_auction_start_price', true); ?> <div class="auction-bidding"> <p>Current Bid: <?php echo wc_price($current_bid); ?></p> <form method="POST"> <input type="hidden" name="product_id" value="<?php echo $product->get_id(); ?>"> <input type="number" name="bid_amount" min="<?php echo $current_bid + 1; ?>" required> <button type="submit" name="place_bid"><?php _e('Place Bid', 'your-text-domain'); ?></button> </form> </div> <?php } add_action('woocommerce_single_product_summary', 'display_bid_form', 25);
👉 Process Bids
Capture bid submissions and update the highest bid.
function process_bid_submission() { if (isset($_POST['place_bid'])) { $product_id = intval($_POST['product_id']); $bid_amount = floatval($_POST['bid_amount']); $current_highest_bid = get_post_meta($product_id, '_highest_bid', true) ?: get_post_meta($product_id, '_auction_start_price', true); if ($bid_amount > $current_highest_bid) { update_post_meta($product_id, '_highest_bid', $bid_amount); update_post_meta($product_id, '_highest_bidder', get_current_user_id()); wc_add_notice(__('Your bid has been placed!', 'your-text-domain'), 'success'); } else { wc_add_notice(__('Your bid must be higher than the current bid.', 'your-text-domain'), 'error'); } } } add_action('wp', 'process_bid_submission');
5. Close the Auction & Select the Winner
Create a function to automatically end the auction and declare a winner.
function check_auction_end() { $args = array( 'post_type' => 'product', 'meta_query' => array( array( 'key' => '_auction_end_time', 'value' => current_time('mysql'), 'compare' => '<=', 'type' => 'DATETIME', ), ), ); $auctions = get_posts($args); foreach ($auctions as $auction) { $winner_id = get_post_meta($auction->ID, '_highest_bidder', true); if ($winner_id) { $winner = get_userdata($winner_id); $winner_email = $winner->user_email; $winner_bid = get_post_meta($auction->ID, '_highest_bid', true); wp_mail($winner_email, "You've won the auction!", "Congratulations! You won the auction for " . get_the_title($auction->ID) . " with a bid of " . wc_price($winner_bid)); update_post_meta($auction->ID, '_auction_status', 'ended'); } } } add_action('wp', 'check_auction_end');
🎯 Final Thoughts
✅ What This Custom Solution Provides:
- Vendors can create auctions inside their Dokan dashboards.
- Customers can bid on auction products.
- Automatic winner selection when the auction ends.
- Email notifications to the highest bidder.
🚀 Extra Features You Can Add:
- Real-time bidding updates with AJAX.
- Reserve price functionality (minimum amount must be reached for auction to be valid).
- Buy Now option alongside bidding.
- Stripe/PayPal integration for automatic payments.
Would you like me to refine any part of the code or add additional features? 🚀
Ajay
Thanks