Advertisement
wpgenie

fix for bid input - Enfold theme

Mar 4th, 2019 (edited)
1,493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.00 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Auction bid
  4.  * bid.php template for Enfold theme to fix double plus / minus button issue
  5.  *
  6.  * usage: copy this template file to your_theme/wooocommerce/single-product/bid.php
  7.  */
  8.  
  9. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  10.  
  11. global $woocommerce, $product, $post;
  12. if(!(method_exists( $product, 'get_type') && $product->get_type() == 'auction')){
  13.     return;
  14. }
  15. $current_user = wp_get_current_user();
  16. $product_id =  $product->get_id();
  17. $user_max_bid = $product->get_user_max_bid($product_id ,$current_user->ID );
  18. $max_min_bid_text = $product->get_auction_type() == 'reverse' ? __( 'Your min bid is', 'wc_simple_auctions' ) : __( 'Your max bid is', 'wc_simple_auctions' );
  19. $gmt_offset = get_option('gmt_offset') > 0 ? '+'.get_option('gmt_offset') : get_option('gmt_offset')
  20.  
  21. ?>
  22.    
  23. <p class="auction-condition"><?php echo apply_filters('conditiond_text', __( 'Item condition:', 'wc_simple_auctions' ), $product); ?><span class="curent-bid"> <?php  _e($product->get_condition(),'wc_simple_auctions' )  ?></span></p>
  24.  
  25. <?php if(($product->is_closed() === FALSE ) and ($product->is_started() === TRUE )) : ?>           
  26.        
  27.     <div class="auction-time" id="countdown"><?php echo apply_filters('time_text', __( 'Time left:', 'wc_simple_auctions' ), $product_id); ?>
  28.         <div class="main-auction auction-time-countdown" data-time="<?php echo $product->get_seconds_remaining() ?>" data-auctionid="<?php echo $product_id ?>" data-format="<?php echo get_option( 'simple_auctions_countdown_format' ) ?>"></div>
  29.     </div>
  30.  
  31.     <div class='auction-ajax-change' >
  32.        
  33.         <p class="auction-end"><?php echo apply_filters('time_left_text', __( 'Auction ends:', 'wc_simple_auctions' ), $product); ?> <?php echo  date_i18n( get_option( 'date_format' ),  strtotime( $product->get_auction_end_time() ));  ?>  <?php echo  date_i18n( get_option( 'time_format' ),  strtotime( $product->get_auction_end_time() ));  ?> <br />
  34.             <?php printf(__('Timezone: %s','wc_simple_auctions') , get_option('timezone_string') ? get_option('timezone_string') : __('UTC ','wc_simple_auctions').$gmt_offset) ?>
  35.         </p>
  36.  
  37.         <?php if ($product->get_auction_sealed() != 'yes'){ ?>
  38.             <p class="auction-bid"><?php echo $product->get_price_html() ?> </p>
  39.            
  40.             <?php if(($product->is_reserved() === TRUE) &&( $product->is_reserve_met() === FALSE )  ) : ?>
  41.                 <p class="reserve hold"  data-auction-id="<?php echo esc_attr( $product_id ); ?>" ><?php echo apply_filters('reserve_bid_text', __( "Reserve price has not been met", 'wc_simple_auctions' )); ?></p>
  42.             <?php endif; ?>
  43.            
  44.             <?php if(($product->is_reserved() === TRUE) &&( $product->is_reserve_met() === TRUE )  ) : ?>
  45.                 <p class="reserve free"  data-auction-id="<?php echo esc_attr( $product_id ); ?>"><?php echo apply_filters('reserve_met_bid_text', __( "Reserve price has been met", 'wc_simple_auctions' )); ?></p>
  46.             <?php endif; ?>
  47.         <?php } elseif($product->get_auction_sealed() == 'yes'){?>
  48.                 <p class="sealed-text"><?php echo apply_filters('sealed_bid_text', __( "This auction is <a href='#'>sealed</a>.", 'wc_simple_auctions' )); ?>
  49.                     <span class='sealed-bid-desc' style="display:none;"><?php _e( "In this type of auction all bidders simultaneously submit sealed bids so that no bidder knows the bid of any other participant. The highest bidder pays the price they submitted. If two bids with same value are placed for auction the one which was placed first wins the auction.", 'wc_simple_auctions' ) ?></span>
  50.                 </p>
  51.                 <?php
  52.                 if (!empty($product->get_auction_start_price())) {?>
  53.                     <?php if($product->get_auction_type() == 'reverse' ) : ?>
  54.                             <p class="sealed-min-text"><?php echo apply_filters('sealed_min_text', sprintf(__( "Maximum bid for this auction is %s.", 'wc_simple_auctions' ), wc_price($product ->get_auction_start_price()))); ?></p>
  55.                     <?php else : ?>
  56.                             <p class="sealed-min-text"><?php echo apply_filters('sealed_min_text', sprintf(__( "Minimum bid for this auction is %s.", 'wc_simple_auctions' ), wc_price($product ->get_auction_start_price()))); ?></p>         
  57.                     <?php endif; ?>        
  58.                 <?php } ?> 
  59.         <?php } ?> 
  60.  
  61.         <?php if($product->get_auction_type() == 'reverse' ) : ?>
  62.             <p class="reverse"><?php echo apply_filters('reverse_auction_text', __( "This is reverse auction.", 'wc_simple_auctions' )); ?></p>
  63.         <?php endif; ?>
  64.         <?php if ($product->get_auction_sealed() != 'yes'){ ?>
  65.             <?php if ($product->get_auction_proxy() &&  $product->get_auction_max_current_bider() && get_current_user_id() == $product->get_auction_max_current_bider()) {?>
  66.  
  67.                 <p class="max-bid"><?php  _e( $max_min_bid_text , 'wc_simple_auctions' ) ?> <?php echo wc_price($product->get_auction_max_bid()) ?>
  68.             <?php } ?>
  69.         <?php } elseif($user_max_bid > 0){ ?>
  70.             <p class="max-bid"><?php  _e( $max_min_bid_text , 'wc_simple_auctions' ) ?> <?php echo wc_price($user_max_bid) ?>
  71.         <?php } ?> 
  72.         <?php do_action('woocommerce_before_bid_form'); ?>
  73.         <form class="auction_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo $product_id; ?>">
  74.            
  75.             <?php do_action('woocommerce_before_bid_button'); ?>
  76.            
  77.             <input type="hidden" name="bid" value="<?php echo esc_attr( $product_id ); ?>" />  
  78.             <?php if($product->get_auction_type() == 'reverse' ) : ?>
  79.                 <div class="quantity">
  80.                    
  81.                     <input type="number" name="bid_value" data-auction-id="<?php echo esc_attr( $product_id ); ?>"  <?php if ($product->get_auction_sealed() != 'yes'){ ?> value="<?php echo $product->bid_value() ?>" max="<?php echo $product->bid_value()  ?>"  <?php } ?> step="any" size="<?php echo strlen($product->get_curent_bid())+2 ?>" title="bid"  class="input-text  qty bid text left">
  82.                    
  83.                 </div> 
  84.                     <button type="submit" class="bid_button button alt"><?php echo apply_filters('bid_text', __( 'Bid', 'wc_simple_auctions' ), $product); ?></button>
  85.                            
  86.             <?php else : ?>
  87.                 <div class="quantity">
  88.                            
  89.                     <input type="number" name="bid_value" data-auction-id="<?php echo esc_attr( $product_id ); ?>" <?php if ($product->get_auction_sealed() != 'yes'){ ?>  value="<?php echo $product->bid_value()  ?>" min="<?php echo $product->bid_value()  ?>" <?php } ?>  step="any" size="<?php echo strlen($product->get_curent_bid())+2 ?>" title="bid"  class="input-text qty  bid text left">
  90.                    
  91.                 </div> 
  92.             <button type="submit" class="bid_button button alt"><?php echo apply_filters('bid_text', __( 'Bid', 'wc_simple_auctions' ), $product); ?></button>
  93.             <?php endif; ?>
  94.            
  95.             <input type="hidden" name="place-bid" value="<?php echo $product_id; ?>" />
  96.             <input type="hidden" name="product_id" value="<?php echo esc_attr( $product_id ); ?>" />
  97.             <?php if ( is_user_logged_in() ) { ?>
  98.                 <input type="hidden" name="user_id" value="<?php echo  get_current_user_id(); ?>" />
  99.             <?php  } ?>
  100.             <?php do_action('woocommerce_after_bid_button'); ?>
  101.         </form>
  102.        
  103.                
  104.         <?php do_action('woocommerce_after_bid_form'); ?>
  105.        
  106.        
  107.     </div>             
  108.  
  109. <?php elseif (($product->is_closed() === FALSE ) and ($product->is_started() === FALSE )):?>
  110.    
  111.     <div class="auction-time future" id="countdown"><?php echo apply_filters('auction_starts_text', __( 'Auction starts in:', 'wc_simple_auctions' ), $product); ?>
  112.         <div class="auction-time-countdown future" data-time="<?php echo $product->get_seconds_to_auction() ?>" data-format="<?php echo get_option( 'simple_auctions_countdown_format' ) ?>"></div>
  113.     </div>
  114.    
  115.     <p class="auction-starts"><?php echo apply_filters('time_text', __( 'Auction starts:', 'wc_simple_auctions' ), $product_id); ?> <?php echo  date_i18n( get_option( 'date_format' ),  strtotime( $product->get_auction_start_time() ));  ?>  <?php echo  date_i18n( get_option( 'time_format' ),  strtotime( $product->get_auction_start_time() ));  ?></p>
  116.     <p class="auction-end"><?php echo apply_filters('time_text', __( 'Auction ends:', 'wc_simple_auctions' ), $product_id); ?> <?php echo  date_i18n( get_option( 'date_format' ),  strtotime( $product->get_auction_end_time() ));  ?>  <?php echo  date_i18n( get_option( 'time_format' ),  strtotime( $product->get_auction_end_time() ));  ?> </p>
  117.    
  118. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement