Code Snippets

Custom min bid increase based on current bid value

Is there a possibility to have minimal bid increments based on current bid amount? Yes, and you can use this code snippet in your child theme functions.php or via Code Snippets plugin. function afw_bid_value_classes( $metadata, $object_id, $meta_key, $single ) { if ( isset( $meta_key ) && '_auction_bid_increment' === $meta_key ) { $product = wc_get_product( $object_id ); if( (! $product) || $product->get_type() != 'auction' ){ return $metadata; } $bid_value = $product->get_curent_bid(); switch ( $bid_value ) { ...
Read More
/ Code Snippets

How can I prevent subscriber role from bidding?

To accomplish that you can use code snippet below: /* Code snippet that prevents bidding based on user role Add to your functions.php */ add_filter( 'auctions_for_woocommerce_before_place_bid_filter' , 'afw_prevent_bid_by_user_role' ); function afw_prevent_bid_by_user_role() { $current_user = wp_get_current_user(); if ( in_array ( 'subscriber', $current_user->roles ) ){ wc_add_notice( esc_html__('Your user role cannot bid.', 'auctions-for-woocommerce'), 'error' ); return FALSE; } else { // user can place a bid return TRUE; } } ...
Read More
/ Code Snippets

Automatically create a WC order when the auction ends (with Auctions for WooCommerce)

Alex created code that programmatically creates a WooCommerce order when an auction (with bids) ends (thanks Alex!). You can use it as code snippet in your functions.php or as standalone plugin. Download it here https://github.com/f2pnt8/WooCommerce-Create-Order-on-Auction-End ...
Read More
/ Code Snippets

How can I place “Add to Watchlist” link to product archive page for all auctions?

You can add this code (thx Mike) to your child theme functions.php file: // display "add to watchlist" on all product archive pages add_action( 'woocommerce_shop_loop_item_title', 'add_to_watchlist', 50 ); function add_to_watchlist() { global $product; if (isset($product) && $product == true) { wc_get_template('single-product/watchlist-link.php'); } } ...
Read More
/ Code Snippets