Advertisement
wpgenie

Added min bid increase to auction-bid-form.php

Jul 8th, 2020 (edited)
2,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.13 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Auction bid
  4.  * this is modified file woocommerce-simple-auctions/templates/single-product/auction-bid-form.php
  5.  * it should be copied to your_child_theme/woocommerce/single-product/auction-bid-form.php in order to be loaded instead of original template
  6.  *
  7.  */
  8.  
  9. if ( ! defined( 'ABSPATH' ) ) {
  10.     exit; // Exit if accessed directly
  11. }
  12.  
  13. global $product, $post;
  14.  
  15. if ( ! ( $product && $product->get_type() == 'auction' ) ) {
  16.     return;
  17. }
  18. $current_user     = wp_get_current_user();
  19. $product_id       = $product->get_id();
  20. $user_max_bid     = $product->get_user_max_bid( $product_id, $current_user->ID );
  21. $max_min_bid_text = $product->get_auction_type() == 'reverse' ? esc_html__( 'Your min bid is', 'wc_simple_auctions' ) : esc_html__( 'Your max bid is', 'wc_simple_auctions' );
  22. ?>
  23.  
  24. <?php if ( ( $product->is_closed() === false ) and ( $product->is_started() === true ) ) : ?>  
  25.  
  26.     <?php do_action( 'woocommerce_before_bid_form' ); ?>
  27.  
  28.     <form class="auction_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo esc_attr( $product_id ); ?>">
  29.  
  30.         <?php do_action( 'woocommerce_before_bid_button' ); ?>
  31.  
  32.         <input type="hidden" name="bid" value="<?php echo esc_attr( $product_id ); ?>" />  
  33.        
  34.         <div class="quantity buttons_added">
  35.  
  36.             <input type="button" value="+" class="plus" /> 
  37.  
  38.             <input type="text" name="bid_value"
  39.                 data-auction-id="<?php echo esc_attr( $product_id ); ?>"
  40.             <?php if ( $product->get_auction_sealed() != 'yes' ) { ?>
  41.                 value="<?php echo esc_attr( number_format( $product->bid_value(), wc_get_price_decimals() == 0 ? 2 : wc_get_price_decimals() , wc_get_price_decimal_separator(), wc_get_price_thousand_separator() ) ); ?>"
  42.             <?php } ?>
  43.  
  44.             <?php
  45.             if ($product->get_auction_sealed() != 'yes'){
  46.                 if ( $product->get_auction_type() == 'reverse' ) { ?>
  47.                     max="<?php echo esc_attr( number_format( $product->bid_value(), wc_get_price_decimals(), wc_get_price_decimal_separator(), wc_get_price_thousand_separator() ) ); ?>"
  48.                 <?php } else { ?>
  49.                     min="<?php echo esc_attr( number_format( $product->bid_value(), wc_get_price_decimals(), wc_get_price_decimal_separator(), wc_get_price_thousand_separator() ) ); ?>"
  50.                 <?php } ?>
  51.             <?php } ?>
  52.                 step="<?php echo ($product->get_increase_bid_value()) ? $product->get_increase_bid_value() : '1' ?>"
  53.                 size="<?php echo strlen( $product->get_curent_bid() ) + 2; ?>"
  54.                 title="bid"
  55.                 class="input-text qty bid text left"
  56.             />
  57.             <input type="button" value="-" class="minus" />
  58.         </div>
  59.  
  60.         <button type="submit" class="bid_button button alt"><?php echo apply_filters( 'bid_text', esc_html__( 'Bid', 'wc_simple_auctions' ), $product ); ?></button>
  61.        
  62.         <input type="hidden" name="place-bid" value="<?php echo esc_attr( $product_id ); ?>" />
  63.         <input type="hidden" name="product_id" value="<?php echo esc_attr( $product_id ); ?>" />
  64.  
  65.         <?php if ( is_user_logged_in() ) { ?>
  66.             <input type="hidden" name="user_id" value="<?php echo get_current_user_id(); ?>" />
  67.         <?php } ?>
  68.  
  69.         <?php do_action( 'woocommerce_after_bid_button' ); ?>
  70.  
  71.     </form>
  72.  
  73.     <?php do_action( 'woocommerce_after_bid_form' ); ?>    
  74.  
  75. <?php endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement