Home

Code examples

Code Snippets

Focused code examples for customising auction and competition behaviour.

Competitions for Woo – Sequential ticket numbers

This code snippet requires Competitions for Woo v3.0.2 or higher. add_filter( ‘competitions_for_woocommerce_generate_random_ticket_numbers’, ‘custom_sequential_ticket_numbers’, 10, 3 ); function custom_sequential_ticket_numbers( $random_tickets, $product_id, $qty ) { $available_tickets = competitions_for_woocommerce_get_available_ticket( $product_id ); if ( empty( $available_tickets ) ) { return $random_tickets; } sort( $available_tickets ); $sequential_tickets = array_slice( $available_tickets, 0, $qty ); return $sequential_tickets; }  

View snippet: Competitions for Woo – Sequential ticket numbers

Prevent proxy bidding to automatically raise bid to the reserve price (if proxy bid amount is higher than reserve price)

In case you need proxy bidding not to reach reserve price instantly ie when reserve price is lower than current bid, next bid will be current bid + min bid increase, you can use code below in your child theme functions.php: add_filter( ‘auctions_for_woocommerce_proxy_bid_to_reserve’ , ‘__return_false’, 20, 3 );

View snippet: Prevent proxy bidding to automatically raise bid to the reserve price (if proxy bid amount is higher than reserve price)

Woodmart bid input fix

Here is a bit of CSS and PHP that makes Auctions for WooCommerce bid input look a bit better in Woodmart Theme. Code should go to child theme functions.php and style.css function custom_enqueue_script() { $product = wc_get_product( get_the_ID() ); if ( $product && $product->get_type() == ‘auction’) { wp_add_inline_script( ‘wd-woocommerce-quantity’, ‘jQuery(document).ready(function($) { woodmartThemeModule.$document.off(“click”, “.plus, .minus”); });’); […]

View snippet: Woodmart bid input fix

Salient Theme CSS for bid input

Here is a bit of CSS that makes Auctions for WooCommerce bid input look a bit better in Salient Theme. .auction_form.cart div.quantity { width: auto !important; border: none; margin: 0 10px 0 0 !important; position: initial !important; opacity: 1 !important; visibility: visible !important; pointer-events: initial !important; float:left !important; } .auction_form .quantity.buttons_added {display: block !important; visibility: […]

View snippet: Salient Theme CSS for bid input

Bootscore Theme CSS for bid input

Here is a bit of CSS that makes Auctions for WooCommerce bid input look a bit better in Bootscore Theme. input.input-text.qty.bid.text.left {display: inline} .quantity.buttons_added {display: contents} input.plus, input.minus,button.bid_button.button.alt { width: 40px; } button.bid_button.button.alt { margin: 0 0 0 10px; }

View snippet: Bootscore Theme CSS for bid input

Redirect to the Cart page when winner clicks Pay Now

Redirect to the Cart page instead of going directly to Checkout when winning bidder clicks Pay Now, this code snippet requires Auctions for WooCommerce v2.5 or higher: add_filter( ‘auctions_for_woocommerce_pay_now_button’ , ‘custom_auctions_for_woocommerce_pay_now_button’, 10); function custom_auctions_for_woocommerce_pay_now_button( $data ){ global $product; if ( ! $product ) { return $data; } return esc_url( add_query_arg( ‘pay-auction’, $product->get_auction_id(), wc_get_cart_url() ) ); […]

View snippet: Redirect to the Cart page when winner clicks Pay Now

Display “no results” message when there are no results in shortcode

To add message if there are no results in shortcode please use code snippet below: function afw_action_woocommerce_shortcode_products_loop_no_results( $attributes ) { echo __( ‘No auction(s) found.’, ‘my-custom-language-domain’ ); } add_action( ‘woocommerce_shortcode_ending_soon_auctions_loop_no_results’, ‘afw_action_woocommerce_shortcode_products_loop_no_results’, 10, 1 ); add_action( ‘woocommerce_shortcode_all_user_auctions_loop_no_results’, ‘afw_action_woocommerce_shortcode_products_loop_no_results’, 10, 1 ); For ending_soon_auctions shortcode hook is woocommerce_shortcode_ending_soon_auctions_loop_no_results, in general hook is woocommerce_shortcode_[shortcode_name]_loop_no_results. This is applicable for […]

View snippet: Display “no results” message when there are no results in shortcode

Pay Now adds won auction to cart instead going to checkout

Here is modified template where Pay Now button adds won auction to cart rather than going to classic checkout. Template should be placed in your child theme, wp-content\themes\child-theme-name\woocommerce\single-product\pay.php <?php /** * Auction pay * */ ​ if ( ! defined( ‘ABSPATH’ ) ) { exit; // Exit if accessed directly } ​ global $product, $post; […]

View snippet: Pay Now adds won auction to cart instead going to checkout