get_default_language()); } $product_data = wc_get_product($product_id); $product_base_currency = $product_data->uwa_aelia_get_base_currency(); $args = array("currency" => $product_base_currency); $post_obj = get_post( $product_id ); // The WP_Post object $post_author = $post_obj->post_author; // <=== The post author ID do_action('ultimate_woocommerce_auction_before_place_bid', $product_id, $bid,$product_data); if (!is_user_logged_in()) { wc_add_notice(sprintf(__('Please Login/Register in to place your bid or buy the product. Login/Register →', 'woo_ua'), get_permalink(wc_get_page_id('myaccount'))), 'error'); return false; } $current_user = wp_get_current_user(); $user_status = get_user_meta($current_user->ID, 'uwa_block_user_status', true); if ($user_status == "uwa_block_user_to_bid") { $get_block_user_text = get_option('uwa_block_user_text'); if($get_block_user_text != ""){ wc_add_notice(sprintf(__($get_block_user_text, 'woo_ua')), 'error'); } else{ wc_add_notice(sprintf(__('You are not allow to place bid please contact to admin.', 'woo_ua')), 'error'); } return false; } if ((apply_filters( 'ultimate_woocommerce_auction_before_place_bid_filter', $product_data, $bid) == false) OR !is_object($product_data) ){ return false; } $uwa_allow_admin_to_bid = get_option('uwa_allow_admin_to_bid', "no"); $uwa_allow_owner_to_bid = get_option('uwa_allow_owner_to_bid', "no"); if(is_user_logged_in()){ /* check for bidder's address in automatic order */ $uwa_auto_order_enable = get_option('uwa_auto_order_enable'); if($uwa_auto_order_enable == "yes"){ $uwa_shipping_address_enable = get_option('uwa_shipping_address'); if($uwa_shipping_address_enable == "yes"){ //$customer_id = $current_user->ID; $customer_id = get_current_user_id(); $first_name = get_user_meta($customer_id, 'billing_first_name', true); $last_name = get_user_meta($customer_id, 'billing_last_name', true); $company = get_user_meta($customer_id, 'billing_company', true); $email = get_user_meta($customer_id, 'billing_email', true); $add_1 = get_user_meta($customer_id, 'billing_address_1', true); $add_2 = get_user_meta($customer_id, 'billing_address_2', true); $city = get_user_meta($customer_id, 'billing_city', true); $state = get_user_meta($customer_id, 'billing_state', true); $postcode = get_user_meta($customer_id, 'billing_postcode', true); $phone = get_user_meta($customer_id, 'billing_phone', true); $cntry_code = get_user_meta($customer_id, 'billing_country', true); if($first_name == "" || $last_name == "" || $email == "" || $add_1 == "" || $city == "" || $postcode == "" || $phone == "" || $cntry_code == "" ){ $myaccount_link = wc_get_endpoint_url('edit-address', 'billing', get_permalink(wc_get_page_id('myaccount'))); wc_add_notice(sprintf(__('You can not place a bid on the auction, please add billing details. ADD ADDRESS →', "woo_ua"), $myaccount_link ), 'error'); return false; } } } /* for administrator role only */ if(current_user_can('administrator')){ if($uwa_allow_admin_to_bid == "no" && $current_user->ID == $post_author){ wc_add_notice(sprintf(__('Sorry, you can not bid on your own auction product.', 'woo_ua')), 'error'); return false; } } else{ /* for seller/vendor/other role */ if($uwa_allow_owner_to_bid == "no" && $current_user->ID == $post_author){ wc_add_notice(sprintf(__('Sorry, you can not bid on your own auction product.', 'woo_ua')), 'error'); return false; } } } if ($bid <= 0) { wc_add_notice(sprintf(__('Please enter a value greater than 0!', 'woo_ua'), get_permalink(wc_get_page_id('myaccount'))), 'error'); return false; } /* Check if auction product expired */ if ($product_data -> is_uwa_expired()) { wc_add_notice( sprintf( __( 'This auction "%s" has expired', 'woo_ua' ), $product_data -> get_title()), 'error' ); return false; } /* Check if auction product Live or schedule */ if (!$product_data -> is_uwa_live()) { wc_add_notice(sprintf(__('Sorry, the auction for "%s" has not started yet', 'woo_ua'), $product_data -> get_title()),'error'); return false; } /* Check Stock */ if (!$product_data -> is_in_stock()) { wc_add_notice(sprintf(__('You cannot place a bid for "%s" because the product is out of stock.', 'woo_ua'), $product_data -> get_title()),'error'); return false; } /* Check User Can Max Bid */ $max_bid_amt = get_option( 'uwa_can_maximum_bid_amt'); if(empty($max_bid_amt)){ $max_bid_amt= 999999999999.99; } if ($bid >= $max_bid_amt) { wc_add_notice(sprintf(__('Bid Value must less than %s !', 'woo_ua'), wc_price($max_bid_amt, $args)), 'error'); return false; } $auction_type = $product_data->get_uwa_auction_type(); $auction_bid_value = $product_data->uwa_bid_value(); $auction_bid_increment = $product_data->get_uwa_auction_bid_increment(); $auction_current_bid = $product_data->get_uwa_auction_current_bid(); $auction_current_bider = $product_data->get_uwa_auction_current_bider(); $auction_high_bid = $product_data->get_uwa_auction_max_bid(); $auction_high_current_bider = $product_data->get_uwa_auction_max_current_bider(); $auction_reserved_price = $product_data->get_uwa_auction_reserved_price(); $auction_bid_count = $product_data->get_uwa_auction_bid_count(); //$uwa_proxy_disable_reserve_price = get_option('uwa_proxy_disable_reserve_price'); $uwa_proxy_disable_reserve_price = "testtest"; if ($product_data->get_uwa_auction_silent() == 'yes') { return $this->silent_bidplace_process($product_data, $bid); } if ($auction_type == 'normal') { if ( apply_filters( 'ultimate_woocommerce_auction_minimum_bid_value', $auction_bid_value, $product_data, $bid )<= ($bid )) { /* Check for proxy bidding */ if ($product_data->get_uwa_auction_proxy()) { if($bid > (float) $auction_high_bid && $auction_current_bider == $current_user->ID ){ update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid ); // update maxbid in usermeta $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); wc_add_notice(sprintf(__('You have changed your maximum bid successfully to %s', 'woo_ua'),wc_price( $bid, $args))); return false; } elseif($bid < (float) $auction_high_bid && $auction_current_bider == $current_user->ID ){ wc_add_notice(sprintf(__('New maximum bid cannot be smaller than old maximum bid.', 'woo_ua'),wc_price($bid, $args)),'error'); return false; } else { if ($bid > (float)$auction_high_bid) { if($uwa_proxy_disable_reserve_price =="yes"){ /*if ($auction_reserved_price && $product_data->is_uwa_reserve_met() === FALSE) { if ($bid > (float)$auction_reserved_price) { $curent_bid = (float)$auction_reserved_price; } else { $curent_bid = $bid ; } } else { if ($auction_high_bid){ $temp_bid = (float) $auction_high_bid + (float)$product_data->get_uwa_increase_bid_value(); $curent_bid = ($bid < $temp_bid) ? $bid : $temp_bid ; } else { $curent_bid = ($bid < $auction_bid_value) ? $bid : $auction_bid_value; } }*/ } else { if ($auction_high_bid){ $temp_bid = (float) $auction_high_bid + (float)$product_data->get_uwa_increase_bid_value(); $curent_bid = ($bid < $temp_bid) ? $bid : $temp_bid ; } else { $curent_bid = ($bid < $auction_bid_value) ? $bid : $auction_bid_value; } } if($auction_high_bid > $auction_current_bid){ $this->history_bid($product_id, $auction_high_bid, get_userdata($auction_high_current_bider), 1); } $curent_bid = apply_filters( 'ultimate_woocommerce_auction_proxy_curent_bid_value' , $curent_bid ,$product_data,$bid ); $outbiddeduser = $auction_current_bider; update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid ); // update maxbid in usermeta $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); update_post_meta($product_id, 'woo_ua_auction_max_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_current_bid', $curent_bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $history_bid_id = $this->history_bid($product_id, $curent_bid, $current_user, 0); WC()->mailer(); //$outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id, $outbiddeduser); } elseif($bid == (float)$auction_high_bid){ /*wc_add_notice(sprintf(__('Your amount matches with maximum bidding amount of an user. Kindly check new bid and enter more value.', 'woo_ua'), wc_price($bid, $args)),'error');*/ $get_proxy_same_maxbid = get_option('uwa_proxy_same_maxbid'); if($get_proxy_same_maxbid == "yes"){ /* --- place auto bid for max user ---- */ /*update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid ); $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); update_post_meta($product_id, 'woo_ua_auction_max_current_bider', $current_user->ID);*/ update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); /*update_post_meta($product_id, 'woo_ua_auction_current_bider', $auction_high_current_bider);*/ update_post_meta($product_id, 'woo_ua_auction_bid_count', (int) $auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $this->history_bid($product_id, $auction_high_bid, get_userdata($auction_high_current_bider), 1); update_user_meta($current_user->ID, "uwa_samemaxbid_bidmsg_display", "no"); update_user_meta($current_user->ID, "uwa_samemaxbid_bidmsg_auction", $product_id); wc_add_notice(sprintf(__('Your bid matches with maximum bid of an user. The bid of this item has been updated. Please check the latest bid and bid again.', 'woo_ua'), wc_price($bid, $args)), 'error'); return true; } else{ /* default */ wc_add_notice(sprintf(__('Your amount matches with maximum bidding amount of an user. Kindly check new bid and enter more value.', 'woo_ua'), wc_price($bid, $args)), 'error'); return false; } } else { $proxy_engine = true; $this->history_bid($product_id, $bid , $current_user, 0); if($bid == (float)$auction_high_bid) { $proxy_bid = $auction_high_bid; } else { $proxy_bid = apply_filters( 'ultimate_woocommerce_auction_proxy_bid_value' , $bid + $auction_bid_increment , $product_data , $bid ); if ($proxy_bid > (float)$auction_high_bid) $proxy_bid = (float)$auction_high_bid; } update_post_meta($product_id, 'woo_ua_auction_current_bid', $proxy_bid); update_post_meta($product_id, 'woo_ua_auction_current_bid_proxy', 'yes'); update_post_meta($product_id, 'woo_ua_auction_current_bider', $auction_high_current_bider); update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 2); $history_bid_id = $this -> history_bid($product_id, $proxy_bid, get_userdata($auction_high_current_bider), 1); wc_add_notice(sprintf(__('You have been outbid.', 'woo_ua'), $product_data -> get_title()),'error'); WC()->mailer(); $outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id, $outbiddeduser); } } } else { $outbiddeduser = $auction_current_bider; $curent_bid = $product_data -> get_uwa_current_bid(); update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 1); $history_bid_id = $this -> history_bid($product_id, $bid, $current_user); } } else { wc_add_notice(sprintf(__('Please enter a bid value for "%s" greater than the current bid. Your bid must be at least %s ', 'woo_ua'), $product_data->get_title(), wc_price($product_data->uwa_bid_value(), $args)),'error'); return false; } } elseif ($auction_type == 'reverse') { if (apply_filters( 'ultimate_woocommerce_auction_minimum_bid_value', $product_data->uwa_bid_value(), $product_data, $bid) >= $bid) { if ($product_data->get_uwa_auction_proxy() ) { if ($bid > (float)$auction_high_bid) { if ($auction_high_bid){ $temp_bid = (float) $auction_high_bid - (float)$product_data->get_uwa_increase_bid_value(); $curent_bid = $bid > $temp_bid ? $bid: $temp_bid ; } else { $curent_bid = $bid < $auction_bid_value ? $bid: $auction_bid_value; } if($auction_high_bid > $auction_current_bid){ $this->history_bid($product_id, $auction_high_bid, get_userdata($auction_high_current_bider), 1); } $outbiddeduser = $auction_current_bider; update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid); // update maxbid in usermeta $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); update_post_meta($product_id, 'woo_ua_auction_max_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_current_bid', $curent_bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $uwa_user_max_bid = $product_data->get_uwa_auction_max_bid(); $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $uwa_user_max_bid); $history_bid_id = $this->history_bid($product_id, $curent_bid, $current_user, 0); WC()->mailer(); //$outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id, $outbiddeduser); } else { $proxy_engine = true; $this->history_bid($product_id, $bid , $current_user, 0); if($bid == (float)$auction_high_bid) { $proxy_bid = $auction_high_bid; }else { $proxy_bid = apply_filters( 'ultimate_woocommerce_auction_proxy_bid_value' , $bid - $auction_bid_increment ,$product_data ,$bid ); if ($proxy_bid > (float)$auction_high_bid) $proxy_bid = (float)$auction_high_bid; } update_post_meta($product_id, 'woo_ua_auction_current_bid', $proxy_bid); update_post_meta($product_id, 'woo_ua_auction_current_bid_proxy', 'yes'); update_post_meta($product_id, 'woo_ua_auction_current_bider', $auction_high_current_bider); update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 2); $history_bid_id = $this -> history_bid($product_id, $proxy_bid, get_userdata($auction_high_current_bider), 1); wc_add_notice(sprintf(__('You have been outbid.', 'woo_ua'), $product_data -> get_title()),'error'); WC()->mailer(); $outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id, $outbiddeduser); } } else { $outbiddeduser = $auction_current_bider; $curent_bid = $product_data->get_uwa_current_bid(); update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $history_bid_id = $this -> history_bid($product_id, $bid, $current_user); } } else { /* wc_add_notice(sprintf(__('Please enter a bid value for "%s" greater than the current bid', 'woo_ua'), $product_data -> get_title()),'error'); */ wc_add_notice(sprintf(__('Please enter a bid value for "%s" less than the current bid', 'woo_ua'), $product_data -> get_title()),'error'); return false; } } else { wc_add_notice(sprintf(__('There was no bid Placed.', 'woo_ua'), $product_data -> get_title()),'error'); return false; } do_action('ultimate_woocommerce_auction_place_bid', array( 'product_id' => $product_id ,'log_id' => $history_bid_id )); return true; } /** * Process For Silent Bid * */ function silent_bidplace_process($product_data, $bid){ global $wpdb; $current_user = wp_get_current_user(); $product_id = $product_data->get_id(); $auction_type = $product_data->get_uwa_auction_type(); $auction_bid_count = $product_data->get_uwa_auction_bid_count(); $product_base_currency = $product_data->uwa_aelia_get_base_currency(); $args = array("currency" => $product_base_currency); if ( ($product_data -> is_uwa_user_biding($current_user->ID) > 0 ) && get_option( 'uwa_restrict_bidder_enable') == 'yes') { wc_add_notice(sprintf(__('You already placed bid for this auction. ', 'woo_ua'), $product_data -> get_title()),'error'); return false; } if ($auction_type == 'normal') { if ( !empty($product_data->get_uwa_auction_start_price())) { if ($product_data->get_uwa_auction_start_price() > $bid) { wc_add_notice(sprintf(__('Your bid is smaller for "%s".Your bid must be at least %s ', 'woo_ua'), $product_data -> get_title(), wc_price($product_data->get_uwa_auction_start_price(), $args )),'error'); return false; } /* check user bid must be greater than his previous max bid */ $slient_userid = $current_user->ID; /* Select max(bid) from wp_woo_ua_auction_log where userid = 2 and auction_id = 198 */ $user_max_bid = $wpdb->get_var('SELECT MAX(bid) FROM '.$wpdb->prefix.'woo_ua_auction_log WHERE auction_id = ' .$product_id .' AND userid = '.$slient_userid); /* echo $user_max_bid; */ if (!empty($user_max_bid) && $user_max_bid >= $bid){ if($user_max_bid == $bid){ wc_add_notice(sprintf(__('Your bid is same as your previous bid %s, Please enter higher bid.', 'woo_ua'), wc_price($user_max_bid, $args)), 'error'); return false; } elseif($user_max_bid > $bid){ wc_add_notice(sprintf(__('Your bid is lower than your previous bid %s, Please enter higher bid.', 'woo_ua'), wc_price($user_max_bid, $args)), 'error'); return false; } } /* end of if - user_max-bid */ } if ( $bid > (float)$product_data -> get_uwa_current_bid()) { update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); } update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 1); update_post_meta($product_id, 'woo_ua_auction_last_bid', $bid); $history_bid_id = $this->history_bid($product_id, $bid, $current_user); } elseif ($auction_type == 'reverse'){ if ( !empty($product_data->get_uwa_auction_start_price())) { if ($product_data->get_uwa_auction_start_price() < $bid) { wc_add_notice(sprintf(__('Your bid is greater for "%s".Your bid must be at least %s ', 'woo_ua'), $product_data -> get_title(), wc_price($product_data->get_uwa_auction_start_price(), $args )),'error'); return false; } /* check user bid must be less than his previous min bid */ $slient_userid = $current_user->ID; /* Select max(bid) from wp_woo_ua_auction_log where userid = 2 and auction_id = 198 */ $user_min_bid = $wpdb->get_var('SELECT MIN(bid) FROM '.$wpdb->prefix.'woo_ua_auction_log WHERE auction_id = ' .$product_id .' AND userid = '.$slient_userid); /* echo $user_min_bid; */ if (!empty($user_min_bid) && $user_min_bid <= $bid){ if($user_min_bid == $bid){ wc_add_notice(sprintf(__('Your bid is same as your previous bid %s, Please enter lower bid.', 'woo_ua'), wc_price($user_min_bid, $args)), 'error'); return false; } elseif($user_min_bid < $bid){ wc_add_notice(sprintf(__('Your bid is higher than your previous bid %s, Please enter lower bid.', 'woo_ua'), wc_price($user_min_bid, $args)), 'error'); return false; } } /* end of if - user_min_bid */ } if ($bid < (float)$product_data -> get_uwa_current_bid()) { update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); } update_post_meta($product_id, 'woo_ua_auction_bid_count',(int)$auction_bid_count + 1); update_post_meta($product_id, 'woo_ua_auction_last_bid', $bid); $history_bid_id = $this->history_bid($product_id, $bid, $current_user); } else{ wc_add_notice(sprintf(__('There was no bid', 'woo_ua'), $product_data -> get_title()),'error'); return false; } do_action('ultimate_woocommerce_auction_place_bid', array( 'product_id' => $product_id )); return true; } /** * Adding Bid data to history * * @param string $current_user, int $product_id, $bid, $proxy * @return. * */ public function history_bid($product_id, $bid, $current_user, $proxy = 0) { global $wpdb; $history_bid_id = false; $history_bid = $wpdb->insert($wpdb -> prefix . 'woo_ua_auction_log', array('userid' => $current_user->ID, 'auction_id' => $product_id, 'bid' => $bid, 'proxy' => $proxy , 'date' => current_time('mysql')), array('%d', '%d', '%f', '%d' , '%s')); if($history_bid){ $history_bid_id = $wpdb->insert_id; } return $history_bid_id; } /* place bid using AJAX */ /* added - new function */ public function ajax_uwa_bidplace( $product_id, $bid ) { global $product_data; global $sitepress; $proxy_engine = false; $history_bid_id = false; /* For WPML Support*/ if (function_exists('icl_object_id') && is_object($sitepress) && method_exists($sitepress, 'get_default_language')) { $product_id = icl_object_id($product_id ,'product',false, $sitepress->get_default_language()); } $ret_arr = array(); /* this is for main return */ $product_data = wc_get_product($product_id); $product_base_currency = $product_data->uwa_aelia_get_base_currency(); $args = array("currency" => $product_base_currency); $post_obj = get_post( $product_id ); // The WP_Post object $post_author = $post_obj->post_author; // <=== The post author ID if (!is_user_logged_in()) { $ret_arr1['error'] = sprintf(__('Please Login/Register in to place your bid or buy the product. Login/Register →', 'woo_ua'), get_permalink(wc_get_page_id('myaccount'))); $ret_arr1['status'] = false; return $ret_arr1; } $current_user = wp_get_current_user(); $user_status = get_user_meta($current_user->ID, 'uwa_block_user_status', true); if ($user_status =="uwa_block_user_to_bid") { $get_block_user_text = get_option('uwa_block_user_text'); if($get_block_user_text != ""){ $ret_arr7['error'] = sprintf(__($get_block_user_text, 'woo_ua')); } else{ $ret_arr7['error'] = sprintf(__('You are not allow to place bid please contact to admin.', 'woo_ua')); } $ret_arr7['status'] = false; return $ret_arr7; } $uwa_enabled_addons_list = get_option('uwa_addons_options_enabled'); if(!empty($uwa_enabled_addons_list)){ if(in_array('uwa_stripe_auto_debit_addon', $uwa_enabled_addons_list)) { global $woocommerce; $saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() ); $has_methods = (bool) $saved_methods; $payment_method_url = wc_get_account_endpoint_url('payment-methods'); if(!$has_methods){ $ret_arr70['error'] = sprintf(__('Please enter your credit card details before placing the bid. Submit here →', 'woo_ua'), $payment_method_url); $ret_arr70['status'] = false; return $ret_arr70; } } } if(!empty($uwa_enabled_addons_list)){ if(in_array('uwa_twilio_sms_addon', $uwa_enabled_addons_list)) { $uwa_twilio_sms_mobile_reqiured = get_option('uwa_twilio_sms_mobile_reqiured'); if($uwa_twilio_sms_mobile_reqiured != "yes"){ global $woocommerce; $ctm_phone = get_user_meta( get_current_user_id(), 'billing_phone', true ); $billing_country = get_user_meta( get_current_user_id(), 'billing_country', true ); $payment_method_url = wc_get_account_endpoint_url('edit-address'); if(empty($ctm_phone) || empty($billing_country)){ $ret_arr80['error'] = sprintf(__('Please enter Phone Number and Country details before placing the bid. Submit here →', 'woo_ua'), $payment_method_url); $ret_arr80['status'] = false; return $ret_arr80; } } } } $uwa_allow_admin_to_bid = get_option('uwa_allow_admin_to_bid', "no"); $uwa_allow_owner_to_bid = get_option('uwa_allow_owner_to_bid', "no"); if(is_user_logged_in()){ /* check for bidder's address in automatic order */ $uwa_auto_order_enable = get_option('uwa_auto_order_enable'); if($uwa_auto_order_enable == "yes"){ $uwa_shipping_address_enable = get_option('uwa_shipping_address'); if($uwa_shipping_address_enable == "yes"){ //$customer_id = $current_user->ID; $customer_id = get_current_user_id(); $first_name = get_user_meta($customer_id, 'billing_first_name', true); $last_name = get_user_meta($customer_id, 'billing_last_name', true); $company = get_user_meta($customer_id, 'billing_company', true); $email = get_user_meta($customer_id, 'billing_email', true); $add_1 = get_user_meta($customer_id, 'billing_address_1', true); $add_2 = get_user_meta($customer_id, 'billing_address_2', true); $city = get_user_meta($customer_id, 'billing_city', true); $state = get_user_meta($customer_id, 'billing_state', true); $postcode = get_user_meta($customer_id, 'billing_postcode', true); $phone = get_user_meta($customer_id, 'billing_phone', true); $cntry_code = get_user_meta($customer_id, 'billing_country', true); if($first_name == "" || $last_name == "" || $email == "" || $add_1 == "" || $city == "" || $postcode == "" || $phone == "" || $cntry_code == "" ){ $myaccount_link = wc_get_endpoint_url('edit-address', 'billing', get_permalink(wc_get_page_id('myaccount'))); $ret_arr16['error'] = sprintf(__('You can not place a bid on the auction, please add billing details. ADD ADDRESS →', "woo_ua"), $myaccount_link); $ret_arr16['status'] = false; return $ret_arr16; } } } /* for administrator role only */ if(current_user_can('administrator')){ if($uwa_allow_admin_to_bid == "no" && $current_user->ID == $post_author){ $ret_arr14['error'] = sprintf(__('Sorry, you can not bid on your own auction product.', 'woo_ua')); $ret_arr14['status'] = false; return $ret_arr14; } } else{ /* for seller/vendor/other role */ if($uwa_allow_owner_to_bid == "no" && $current_user->ID == $post_author){ $ret_arr15['error'] = sprintf(__('Sorry, you can not bid on your own auction product.', 'woo_ua')); $ret_arr15['status'] = false; return $ret_arr15; } } } if ($bid <= 0) { $ret_arr2['error'] = sprintf(__('Please enter a value greater than 0!', 'woo_ua'), get_permalink(wc_get_page_id('myaccount'))); $ret_arr2['status'] = false; return $ret_arr2; } /* Check if auction product expired */ if ($product_data -> is_uwa_expired()) { $ret_arr3['error'] = sprintf( __( 'This auction "%s" has expired', 'woo_ua' ), $product_data -> get_title()); $ret_arr3['status'] = false; return $ret_arr3; } /* Check if auction product Live or schedule */ if (!$product_data -> is_uwa_live()) { $ret_arr4['error'] = sprintf(__('Sorry, the auction for "%s" has not started yet', 'woo_ua'), $product_data -> get_title()); $ret_arr4['status'] = false; return $ret_arr4; } /* Check Stock */ if (!$product_data -> is_in_stock()) { $ret_arr5['error'] = sprintf(__('You cannot place a bid for "%s" because the product is out of stock.', 'woo_ua'), $product_data -> get_title()); $ret_arr5['status'] = false; return $ret_arr5; } /* Check User Can Max Bid */ $max_bid_amt = get_option( 'uwa_can_maximum_bid_amt'); if(empty($max_bid_amt)){ $max_bid_amt= 999999999999.99; } if ($bid >= $max_bid_amt) { $ret_arr6['error'] = sprintf(__('Bid Value must less than %s !', 'woo_ua'), wc_price($max_bid_amt, $args)); $ret_arr6['status'] = false; return $ret_arr6; } $current_user = wp_get_current_user(); $auction_type = $product_data->get_uwa_auction_type(); $auction_bid_value = $product_data->uwa_bid_value(); $auction_bid_increment = $product_data->get_uwa_auction_bid_increment(); $auction_current_bid = $product_data->get_uwa_auction_current_bid(); $auction_current_bider = $product_data->get_uwa_auction_current_bider(); $auction_high_bid = $product_data->get_uwa_auction_max_bid(); $auction_high_current_bider = $product_data->get_uwa_auction_max_current_bider(); $auction_reserved_price = $product_data->get_uwa_auction_reserved_price(); $auction_bid_count = $product_data->get_uwa_auction_bid_count(); //$uwa_proxy_disable_reserve_price = get_option('uwa_proxy_disable_reserve_price'); $uwa_proxy_disable_reserve_price = "testtest"; if ($product_data ->get_uwa_auction_silent() == 'yes') { /* here change function name */ return $this->ajax_silent_bidplace_process($product_data, $bid); } if ($auction_type == 'normal') { if ( apply_filters( 'ultimate_woocommerce_auction_minimum_bid_value', $auction_bid_value, $product_data, $bid )<= ($bid )) { /* Check for proxy bidding */ if ($product_data->get_uwa_auction_proxy()) { if($bid > (float) $auction_high_bid && $auction_current_bider == $current_user->ID ){ update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid ); // update maxbid in usermeta $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); $ret_arr7['success'] = sprintf(__('You have changed your maximum bid successfully to %s', 'woo_ua'), wc_price($bid, $args)); $ret_arr7['status'] = false; return $ret_arr7; } elseif($bid < (float) $auction_high_bid && $auction_current_bider == $current_user->ID ){ $ret_arr8['error'] = sprintf(__('New maximum bid cannot be smaller than old maximum bid.', 'woo_ua'), wc_price($bid, $args)); $ret_arr8['status'] = false; return $ret_arr8; } else { if ($bid > (float)$auction_high_bid) { if($uwa_proxy_disable_reserve_price == "yes"){ /*if ($auction_reserved_price && $product_data->is_uwa_reserve_met() === FALSE) { if ($bid > (float)$auction_reserved_price) { $curent_bid = (float)$auction_reserved_price; } else { $curent_bid = $bid ; } } else { if ($auction_high_bid){ $temp_bid = (float) $auction_high_bid + (float)$product_data->get_uwa_increase_bid_value(); $curent_bid = ($bid < $temp_bid) ? $bid : $temp_bid ; } else { $curent_bid = ($bid < $auction_bid_value) ? $bid : $auction_bid_value; } }*/ } else { if ($auction_high_bid){ $temp_bid = (float) $auction_high_bid + (float)$product_data->get_uwa_increase_bid_value(); $curent_bid = ($bid < $temp_bid) ? $bid : $temp_bid ; } else { $curent_bid = ($bid < $auction_bid_value) ? $bid : $auction_bid_value; } } if($auction_high_bid > $auction_current_bid){ $this->history_bid($product_id, $auction_high_bid, get_userdata($auction_high_current_bider), 1); } $curent_bid = apply_filters( 'ultimate_woocommerce_auction_proxy_curent_bid_value' , $curent_bid ,$product_data, $bid ); $outbiddeduser = $auction_current_bider; update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid ); // update maxbid in usermeta $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); update_post_meta($product_id, 'woo_ua_auction_max_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_current_bid', $curent_bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $history_bid_id = $this->history_bid($product_id, $curent_bid, $current_user, 0); WC()->mailer(); //$outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id, $outbiddeduser); } elseif($bid == (float)$auction_high_bid){ /*$ret_arr9['error'] = sprintf(__('Your amount matches with maximum bidding amount of an user. Kindly check new bid and enter more value.', 'woo_ua'), wc_price($bid, $args));*/ $get_proxy_same_maxbid = get_option('uwa_proxy_same_maxbid'); if($get_proxy_same_maxbid == "yes"){ /* --- place auto bid for max user ---- */ /*update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid ); $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); update_post_meta($product_id, 'woo_ua_auction_max_current_bider', $current_user->ID);*/ update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); /*update_post_meta($product_id, 'woo_ua_auction_current_bider', $auction_high_current_bider);*/ update_post_meta($product_id, 'woo_ua_auction_bid_count', (int) $auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $this->history_bid($product_id, $auction_high_bid, get_userdata($auction_high_current_bider), 1); update_user_meta($current_user->ID, "uwa_samemaxbid_bidmsg_display", "no"); update_user_meta($current_user->ID, "uwa_samemaxbid_bidmsg_auction", $product_id); $ret_arr9['error'] = sprintf(__('Your bid matches with maximum bid of an user. The bid of this item has been updated. Please check the latest bid and bid again.', 'woo_ua'), wc_price($bid, $args)); $ret_arr9['status'] = true; return $ret_arr9; } else{ /* default */ $ret_arr9['error'] = sprintf(__('Your amount matches with maximum bidding amount of an user. Kindly check new bid and enter more value.', 'woo_ua'), wc_price($bid, $args)); $ret_arr9['status'] = false; return $ret_arr9; } } else { $proxy_engine = true; $this->history_bid($product_id, $bid , $current_user, 0); if($bid == (float)$auction_high_bid) { $proxy_bid = $auction_high_bid; } else { $proxy_bid = apply_filters( 'ultimate_woocommerce_auction_proxy_bid_value' , $bid + $auction_bid_increment ,$product_data ,$bid ); if ($proxy_bid > (float)$auction_high_bid) $proxy_bid = (float)$auction_high_bid; } update_post_meta($product_id, 'woo_ua_auction_current_bid', $proxy_bid); update_post_meta($product_id, 'woo_ua_auction_current_bid_proxy', 'yes'); update_post_meta($product_id, 'woo_ua_auction_current_bider', $auction_high_current_bider); update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 2); $history_bid_id = $this->history_bid($product_id, $proxy_bid, get_userdata($auction_high_current_bider), 1); /*_notice(sprintf(__('You have been outbid.', 'woo_ua'), $product_data -> get_title()),'error');*/ $ret_arr['error'] = sprintf(__('You have been outbid.', 'woo_ua'), $product_data->get_title()); WC()->mailer(); $outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id, $outbiddeduser); } } } else { $outbiddeduser = $auction_current_bider; $curent_bid = $product_data -> get_uwa_current_bid(); update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 1); $history_bid_id = $this -> history_bid($product_id, $bid, $current_user); } } else { $ret_arr10['error'] = sprintf(__('Please enter a bid value for "%s" greater than the current bid. Your bid must be at least %s ', 'woo_ua'), $product_data -> get_title(), wc_price($product_data->uwa_bid_value(), $args)); $ret_arr10['status'] = false; return $ret_arr10; } } elseif ($auction_type == 'reverse') { if (apply_filters( 'ultimate_woocommerce_auction_minimum_bid_value', $product_data->uwa_bid_value(), $product_data, $bid) >= $bid) { if ($product_data->get_uwa_auction_proxy() ) { if ($bid > (float)$auction_high_bid) { if ($auction_high_bid){ $temp_bid = (float) $auction_high_bid - (float)$product_data->get_uwa_increase_bid_value(); $curent_bid = $bid > $temp_bid ? $bid: $temp_bid ; } else { $curent_bid = $bid < $auction_bid_value ? $bid: $auction_bid_value; } if($auction_high_bid > $auction_current_bid){ $this->history_bid($product_id, $auction_high_bid, get_userdata($auction_high_current_bider), 1); } $outbiddeduser = $auction_current_bider; update_post_meta($product_id, 'woo_ua_auction_max_bid', $bid); // update maxbid in usermeta $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $bid); update_post_meta($product_id, 'woo_ua_auction_max_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_current_bid', $curent_bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $uwa_user_max_bid = $product_data->get_uwa_auction_max_bid(); $maxbid_metakey = "woo_ua_auction_user_max_bid_".$product_id; update_user_meta($current_user->ID, $maxbid_metakey, $uwa_user_max_bid); $history_bid_id = $this->history_bid($product_id, $curent_bid, $current_user, 0); WC()->mailer(); //$outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id , $outbiddeduser); } else { $proxy_engine = true; $this->history_bid($product_id, $bid , $current_user, 0); if($bid == (float)$auction_high_bid) { $proxy_bid = $auction_high_bid; }else { $proxy_bid = apply_filters( 'ultimate_woocommerce_auction_proxy_bid_value' , $bid - $auction_bid_increment ,$product_data ,$bid ); if ($proxy_bid > (float)$auction_high_bid) $proxy_bid = (float)$auction_high_bid; } update_post_meta($product_id, 'woo_ua_auction_current_bid', $proxy_bid); update_post_meta($product_id, 'woo_ua_auction_current_bid_proxy', 'yes'); update_post_meta($product_id, 'woo_ua_auction_current_bider', $auction_high_current_bider); update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 2); $history_bid_id = $this -> history_bid($product_id, $proxy_bid, get_userdata($auction_high_current_bider), 1); $ret_arr['error'] = sprintf(__('You have been outbid.', 'woo_ua'), $product_data -> get_title()); WC()->mailer(); $outbiddeduser = $current_user->ID; do_action( 'uwa_pro_outbid_bid_email', $outbiddeduser, $product_data); do_action('ultimate_woocommerce_auction_outbid_bid', $product_id , $outbiddeduser); } } else { $outbiddeduser = $auction_current_bider; $curent_bid = $product_data->get_uwa_current_bid(); update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 1); delete_post_meta($product_id, 'woo_ua_auction_current_bid_proxy'); $history_bid_id = $this -> history_bid($product_id, $bid, $current_user); } } else { $ret_arr11['error'] = sprintf(__('Please enter a bid value for "%s" less than the current bid', 'woo_ua'), $product_data -> get_title()); $ret_arr11['status'] = false; return $ret_arr11; } } else { $ret_arr12['error'] = sprintf(__('There was no bid Placed.', 'woo_ua'), $product_data -> get_title()); $ret_arr12['status'] = false; return $ret_arr12; } do_action('ultimate_woocommerce_auction_place_bid', array( 'product_id' => $product_id ,'log_id' => $history_bid_id )); /*return true;*/ $ret_arr['status'] = true; return $ret_arr; } /* end of function - ajax_uwa_bidplace */ /** * Process For Silent Bid * */ /* here we added - new function */ function ajax_silent_bidplace_process($product_data, $bid){ global $wpdb; $sret_arr = array(); $current_user = wp_get_current_user(); $product_id = $product_data->get_id(); $auction_type = $product_data->get_uwa_auction_type(); $auction_bid_count = $product_data->get_uwa_auction_bid_count(); $product_base_currency = $product_data->uwa_aelia_get_base_currency(); $args = array("currency" => $product_base_currency); if ( ($product_data -> is_uwa_user_biding($current_user->ID) > 0 ) && get_option( 'uwa_restrict_bidder_enable') == 'yes') { $sret_arr1['error'] = sprintf(__('You already placed bid for this auction. ', 'woo_ua'), $product_data -> get_title()); $sret_arr1['status'] = false; return $sret_arr1; } if ($auction_type == 'normal') { if ( !empty($product_data->get_uwa_auction_start_price())) { if ($product_data->get_uwa_auction_start_price() > $bid) { $sret_arr2['error'] = sprintf(__('Your bid is smaller for "%s".Your bid must be at least %s ', 'woo_ua'), $product_data->get_title(), wc_price($product_data->get_uwa_auction_start_price(), $args )); $sret_arr2['status'] = false; return $sret_arr2; } /* check user bid must be greater than his previous max bid */ $slient_userid = $current_user->ID; /* Select max(bid) from wp_woo_ua_auction_log where userid = 2 and auction_id = 198 */ $user_max_bid = $wpdb->get_var('SELECT MAX(bid) FROM '.$wpdb->prefix.'woo_ua_auction_log WHERE auction_id = ' .$product_id .' AND userid = '.$slient_userid); /* echo $user_max_bid; */ if (!empty($user_max_bid) && $user_max_bid >= $bid){ if($user_max_bid == $bid){ $sret_arr3['error'] = sprintf(__('Your bid is same as your previous bid %s, Please enter higher bid.', 'woo_ua'), wc_price($user_max_bid, $args)); $sret_arr3['status'] = false; return $sret_arr3; } elseif($user_max_bid > $bid){ $sret_arr4['error'] = sprintf(__('Your bid is lower than your previous bid %s, Please enter higher bid.', 'woo_ua'), wc_price($user_max_bid, $args)); $sret_arr4['status'] = false; return $sret_arr4; } } /* end of if - user_max-bid */ } if ( $bid > (float)$product_data -> get_uwa_current_bid()) { update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); } update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 1); update_post_meta($product_id, 'woo_ua_auction_last_bid', $bid); $history_bid_id = $this->history_bid($product_id, $bid, $current_user); } elseif ($auction_type == 'reverse'){ if ( !empty($product_data->get_uwa_auction_start_price())) { if ($product_data->get_uwa_auction_start_price() < $bid) { $sret_arr5['error'] = sprintf(__('Your bid is greater for "%s".Your bid must be at least %s ', 'woo_ua'), $product_data -> get_title(), wc_price($product_data->get_uwa_auction_start_price(), $args )); $sret_arr5['status'] = false; return $sret_arr5; } /* check user bid must be less than his previous min bid */ $slient_userid = $current_user->ID; /* Select max(bid) from wp_woo_ua_auction_log where userid = 2 and auction_id = 198 */ $user_min_bid = $wpdb->get_var('SELECT MIN(bid) FROM '.$wpdb->prefix.'woo_ua_auction_log WHERE auction_id = ' .$product_id .' AND userid = '.$slient_userid); /* echo $user_min_bid; */ if (!empty($user_min_bid) && $user_min_bid <= $bid){ if($user_min_bid == $bid){ $sret_arr6['error'] = sprintf(__('Your bid is same as your previous bid %s, Please enter lower bid.', 'woo_ua'), wc_price($user_min_bid, $args)); $sret_arr6['status'] = false; return $sret_arr6; } elseif($user_min_bid < $bid){ $sret_arr7['error'] = sprintf(__('Your bid is higher than your previous bid %s, Please enter lower bid.', 'woo_ua'), wc_price($user_min_bid, $args)); $sret_arr7['status'] = false; return $sret_arr7; } } /* end of if - user_min_bid */ } if ($bid < (float)$product_data -> get_uwa_current_bid()) { update_post_meta($product_id, 'woo_ua_auction_current_bid', $bid); update_post_meta($product_id, 'woo_ua_auction_current_bider', $current_user->ID); } update_post_meta($product_id, 'woo_ua_auction_bid_count', (int)$auction_bid_count + 1); update_post_meta($product_id, 'woo_ua_auction_last_bid', $bid); $history_bid_id = $this->history_bid($product_id, $bid, $current_user); } else{ $sret_arr8['error'] = sprintf(__('There was no bid', 'woo_ua'), $product_data -> get_title()); $sret_arr8['status'] = false; return $sret_arr8; } do_action('ultimate_woocommerce_auction_place_bid', array( 'product_id' => $product_id )); $sret_arr['status'] = true; return $sret_arr; } /* end of function - ajax_silent_bidplace_process */ }hide_errors(); } } /** * Check for ajax request and fire action. * */ public static function do_uwa_ajax() { global $wp_query; if ( ! empty( $_GET['uwa-ajax'] ) ) { self::wc_ajax_headers(); do_action( 'uwa_ajax_' . sanitize_text_field( $_GET['uwa-ajax'] ) ); wp_die(); } } /** * Send headers for Ajax Requests. * */ private static function wc_ajax_headers() { send_origin_headers(); @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); @header( 'X-Robots-Tag: noindex' ); send_nosniff_header(); nocache_headers(); status_header( 200 ); }}UWA_AJAX::init();Submit here →', 'woo_ua'), $payment_method_url), 'error'); return false; }}/*function uwa_get_stripe_buyer_premium_value($winner_bid){ $uwa_buyer_price = 0; $uwa_bpm_type = get_option('uwa_buyers_premium_type'); $uwa_bpm_amt = get_option('uwa_buyers_premium_rate'); if(isset($uwa_bpm_amt) && !empty($uwa_bpm_amt)){ if(isset($uwa_bpm_type) && !empty($uwa_bpm_type)){ if($uwa_bpm_type == 'percentage'){ $uwa_buyer_price = ($winner_bid * $uwa_bpm_amt)/100; /* calculations for min max buyers premium $uwa_bpm_min_val = get_option("uwa_buyers_min_premium", ""); $uwa_bpm_max_val = get_option("uwa_buyers_max_premium", ""); $min_val = $uwa_bpm_min_val; $max_val = $uwa_bpm_max_val; if($min_val > 0 ){ if($uwa_buyer_price < $min_val ){ $uwa_buyer_price = $min_val; } } if($max_val > 0 ){ if($uwa_buyer_price > $max_val ){ $uwa_buyer_price = $max_val; } } } else{ $uwa_buyer_price = $uwa_bpm_amt; } } } return $uwa_buyer_price; }*/function uwa_get_stripe_buyer_premium_value($product_id, $winner_bid){ $uwa_buyer_price = 0; if($product_id > 0){ $level = get_post_meta($product_id, 'woo_ua_buyer_level', true); if($level == "product_level"){ /* set buyers premium at product level */ $uwa_bpm_type = get_post_meta($product_id, 'woo_ua_buyer_type', true); $uwa_bpm_amt = get_post_meta($product_id, 'woo_ua_buyer_fee_amt', true); if(isset($uwa_bpm_amt) && !empty($uwa_bpm_amt)){ if(isset($uwa_bpm_type) && !empty($uwa_bpm_type)){ if($uwa_bpm_type == 'percentage'){ $uwa_buyer_price = ($winner_bid * $uwa_bpm_amt)/100; /* calculations for min max buyers premium */ $uwa_bpm_min_val = get_post_meta($product_id, 'woo_ua_buyer_min_amt', true); $uwa_bpm_max_val = get_post_meta($product_id, 'woo_ua_buyer_max_amt', true); $min_val = $uwa_bpm_min_val; $max_val = $uwa_bpm_max_val; if($min_val > 0 ){ if($uwa_buyer_price < $min_val ){ $uwa_buyer_price = $min_val; } } if($max_val > 0 ){ if($uwa_buyer_price > $max_val ){ $uwa_buyer_price = $max_val; } } } else{ $uwa_buyer_price = $uwa_bpm_amt; } } } /* end of if - isset */ } else{ /* set buyers premium globally */ $uwa_bpm_type = get_option('uwa_buyers_premium_type'); $uwa_bpm_amt = get_option('uwa_buyers_premium_rate'); if(isset($uwa_bpm_amt) && !empty($uwa_bpm_amt)){ if(isset($uwa_bpm_type) && !empty($uwa_bpm_type)){ if($uwa_bpm_type == 'percentage'){ $uwa_buyer_price = ($winner_bid * $uwa_bpm_amt)/100; /* calculations for min max buyers premium */ $uwa_bpm_min_val = get_option("uwa_buyers_min_premium", ""); $uwa_bpm_max_val = get_option("uwa_buyers_max_premium", ""); $min_val = $uwa_bpm_min_val; $max_val = $uwa_bpm_max_val; if($min_val > 0 ){ if($uwa_buyer_price < $min_val ){ $uwa_buyer_price = $min_val; } } if($max_val > 0 ){ if($uwa_buyer_price > $max_val ){ $uwa_buyer_price = $max_val; } } } else{ $uwa_buyer_price = $uwa_bpm_amt; } } } /* end of if - isset */ } /* end of else - globally */ } /* end of if - productid */ return $uwa_buyer_price; }function uwa_get_stripe_auto_debit_value($stripe_amt){ global $wpdb; $uwa_product_price = 0; $uwa_stripe_charge_type = get_option('uwa_stripe_charge_type'); if($uwa_stripe_charge_type == "uwa_stripe_charge_type_partially"){ $uwa_partially_type = get_option('uwa_stripe_charge_type_partially_type'); $uwa_partially_amt = get_option('uwa_stripe_charge_type_partially_amt'); if(isset($uwa_partially_amt) && !empty($uwa_partially_amt)){ if(isset($uwa_partially_type) && !empty($uwa_partially_type)){ if($uwa_partially_type == 'percentage'){ $uwa_product_price = ($stripe_amt * $uwa_partially_amt)/100; } else{ $uwa_product_price = $uwa_partially_amt; } } } } elseif($uwa_stripe_charge_type == "uwa_stripe_charge_type_full"){ $uwa_product_price = $stripe_amt; } else { $uwa_product_price = 0; } return $uwa_product_price;}/* check post author */function uwa_stripe_addon_is_vendor_product( $auction_post_author = '') { $auction_post_author_data = new WP_User( $auction_post_author ); if(in_array('wcfm_vendor', $auction_post_author_data->roles)){ return true; } else { return false; } }function uwa_get_stripe_auto_debit_admin_commission($winner_bid_amt){ global $wpdb, $WCFM, $WCFMmp; $commission_amount = 0; $wcfm_commission_options = get_option( 'wcfm_commission_options', array() ); $vendor_commission_for = $wcfm_commission_options['commission_for']; $commission_percent = $wcfm_commission_options['commission_percent']; $commission_fixed = $wcfm_commission_options['commission_fixed']; $commission_mode = $wcfm_commission_options['commission_mode']; //percent fixed percent_fixed if($commission_mode == 'percent'){ $commission_amount = ($winner_bid_amt * $commission_percent)/100; } elseif($commission_mode == 'fixed') { $commission_amount = $commission_fixed; } elseif($commission_mode == 'percent_fixed') { $commission_amount1 = ($winner_bid_amt * $commission_percent)/100; $commission_amount2 = $commission_fixed; $commission_amount = $commission_amount1 + $commission_amount2; } if($vendor_commission_for == 'admin') { $commission_amount = $commission_amount; } else { $commission_amount = $winner_bid_amt - $commission_amount; } return $commission_amount;} function uwa_get_stripe_auto_debit_value_vendor($stripe_amt_vendor){ global $wpdb; $uwa_product_price_vendor = 0; $uwa_stripe_charge_type_vendor = get_option('uwa_stripe_charge_type'); if($uwa_stripe_charge_type_vendor == "uwa_stripe_charge_type_partially"){ $uwa_partially_type_vendor = get_option( 'uwa_stripe_charge_type_partially_type'); $uwa_partially_amt_vendor = get_option( 'uwa_stripe_charge_type_partially_amt'); if(isset($uwa_partially_type_vendor) && !empty($uwa_partially_type_vendor)){ if(isset($uwa_partially_amt_vendor) && !empty($uwa_partially_amt_vendor)){ if($uwa_partially_type_vendor == 'percentage'){ $uwa_product_price_vendor = ($stripe_amt_vendor * $uwa_partially_amt_vendor)/100; } else{ $uwa_product_price_vendor = $uwa_partially_amt_vendor; } } } } elseif($uwa_stripe_charge_type_vendor == "uwa_stripe_charge_type_full"){ $uwa_product_price_vendor = $stripe_amt_vendor; } else { $uwa_product_price_vendor = 0; } return $uwa_product_price_vendor;}/*add_action( 'ultimate_woocommerce_auction_close','uwa_stripe_addon_get_winner_info_cut_payment'); */add_action( 'ultimate_woocommerce_auction_autodabit_payment','uwa_stripe_addon_get_winner_info_cut_payment'); function uwa_stripe_addon_get_winner_info_cut_payment( $auction_id ) { global $wpdb,$woocommerce, $post,$WCFM; /* For one time auto dabit call */ $auto_debit_one_time_payment = get_post_meta( $auction_id, '_done_one_time_payment', true ); $auto_debit_status = get_post_meta( $auction_id, '_uwa_stripe_auto_debit_status', true ); if($auto_debit_one_time_payment!='done_one_time_payment_1'){ add_post_meta($auction_id, '_done_one_time_payment','done_one_time_payment_0'); } if($auto_debit_status !="paid"){ if($auto_debit_one_time_payment !="done_one_time_payment_1" ){ $product = wc_get_product($auction_id); $cuserid = $product->get_uwa_auction_current_bider(); $expired_auct = $product->get_uwa_auction_expired(); $saved_methods = wc_get_customer_saved_methods_list( $cuserid ); $has_methods = (bool) $saved_methods; if($has_methods){ if ( !empty($cuserid) && $expired_auct == '2' ) { $product_id = $product->get_id(); $winning_bid_amt = $product->get_uwa_auction_current_bid(); $get_charged_for_winner = get_option( "_uwa_w_s_charge_".$product_id."_".$cuserid, false); if(empty($get_charged_for_winner)){ add_option("_uwa_w_s_charge_".$product_id."_".$cuserid, "added"); } else { update_option("_uwa_w_s_charge_".$product_id."_".$cuserid, "added"); } $auction_post_author = get_post_field( 'post_author', $product_id ); $wcfm_withdrawal_options = get_option( 'wcfm_withdrawal_options', array()); $withdrawal_payment_methods = $wcfm_withdrawal_options['payment_methods']; $vendor_stripe_id = get_user_meta($auction_post_author, 'stripe_user_id', true ); $set = ""; if(is_array($withdrawal_payment_methods)) { if(in_array("stripe_split", $withdrawal_payment_methods) && !empty($vendor_stripe_id)){ $set = "yes"; } } $vendor_product = uwa_stripe_addon_is_vendor_product( $auction_post_author ); if($vendor_product && $set == "yes"){ /* vendor auto debit */ $uwa_price_vendor = 0; $total_amt = uwa_get_stripe_auto_debit_value_vendor($winning_bid_amt); $uwa_price_vendor = uwa_get_stripe_auto_debit_value_vendor( $winning_bid_amt); $uwa_admin_commission = $uwa_price_vendor; $uwa_admin_commission = uwa_get_stripe_auto_debit_admin_commission( $uwa_price_vendor); /* buyers_premium */ $uwa_stripe_buyers_premium_enable_vendor = get_option( 'uwa_stripe_buyers_premium_enable'); if($uwa_stripe_buyers_premium_enable_vendor == "yes"){ $uwa_buyers_price_vendor = uwa_get_stripe_buyer_premium_value($product_id, $winning_bid_amt); /*$uwa_buyers_premium_for = get_option('uwa_buyers_premium_for', "uwa_admin");*/ $all_data = uwa_get_buyer_premium_data($product_id); $bpm_givento = $all_data['bpm_givento']; $uwa_buyers_premium_for = $bpm_givento; /* buyers_premium for vendor */ if($uwa_buyers_premium_for=="uwa_owners"){ $uwa_price_vendor = $uwa_price_vendor + $uwa_buyers_price_vendor; } else { $uwa_admin_commission = $uwa_admin_commission + $uwa_buyers_price_vendor; } $total_amt = $total_amt + $uwa_buyers_price_vendor; } /* end of if - enable_vendor */ $paid_tobe_vendor = 0; $paid_tobe_vendor = $total_amt - $uwa_admin_commission; //this amount to paid vendor $vendor_amt = $paid_tobe_vendor; if(!empty($total_amt) && $total_amt > 0) { $total_amt = wc_format_decimal($total_amt,2); $vendor_amt = wc_format_decimal($paid_tobe_vendor,2); $get_charged_for_winner = get_option( "_uwa_w_s_charge_".$product_id."_".$cuserid, false); if($get_charged_for_winner == "added"){ // payment is pending.. make payment if($total_amt > 0){ require_once ( UW_AUCTION_PRO_ADDONS .'stripe_auto_debit/lib/uwa-stripe/stripe-main.php' ); uwa_winner_make_strip_payment_vendor($cuserid, $vendor_amt, $total_amt, $product_id, $uwa_price_vendor, $uwa_buyers_price_vendor, $vendor_stripe_id); } } } /* end of if - empty total amt */ } /* end of if - vendor product */ else{ $w_product_price = 0; $uwa_stripe_product_price = 0; $uwa_stripe_product_price = uwa_get_stripe_auto_debit_value( $winning_bid_amt); $w_product_price = uwa_get_stripe_auto_debit_value($winning_bid_amt); $uwa_stripe_buyers_premium_enable = get_option( 'uwa_stripe_buyers_premium_enable'); $uwa_stripe_buyer_price = 0; if($uwa_stripe_buyers_premium_enable == "yes"){ $uwa_stripe_buyer_price = uwa_get_stripe_buyer_premium_value($product_id, $winning_bid_amt); $w_product_price = $w_product_price + $uwa_stripe_buyer_price; } if(!empty($w_product_price) && $w_product_price > 0) { $total_amt = wc_format_decimal($w_product_price,2); $get_charged_for_winner = get_option( "_uwa_w_s_charge_".$product_id."_".$cuserid, false); //if($get_charged_for_winner == false){ if($get_charged_for_winner == "added"){ // if payment is pending.. make payment if($total_amt > 0){ require_once (UW_AUCTION_PRO_ADDONS . 'stripe_auto_debit/lib/uwa-stripe/stripe-main.php'); uwa_winner_make_strip_payment($cuserid, $total_amt, $product_id, $uwa_stripe_product_price, $uwa_stripe_buyer_price); } } } /* end of if - product price > 0 */ } /* end of else */ } /* end of if - empty $cuserid */ } /* end of if - has methods */ else { uwa_create_log("Auto Debit this user have no saved payment method : UserID#".$cuserid); } } } else { uwa_create_log("Auto Debit All ready Done For this Product : ProductID#".$auction_id); } /* end of if - has Paid Status */ }add_action( 'woocommerce_payment_token_set_default', 'update_customer_payment_source', 10, 2 );function update_customer_payment_source( $payment_method_id ) { global $woocommerce, $wpdb; require_once (UW_AUCTION_PRO_ADDONS .'stripe_auto_debit/lib/uwa-stripe/stripe-main.php'); if(empty($payment_method_id)){ global $wpdb; $id = get_current_user_id(); $sql = "SELECT token_id FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE user_id = %s AND is_default = 1"; // populate vars and run query $default_id = $wpdb->get_var( $wpdb->prepare( $sql, $id ) ); $payment_method_id = $default_id; } // Get the Stripe customer object $arr_stripe = get_option("woocommerce_stripe_settings"); if(is_array($arr_stripe) && count($arr_stripe)){ $stripe_customer_id = get_user_meta( get_current_user_id(), '_stripe_customer_id', true); if(!$stripe_customer_id){ $stripe_customer_id = get_user_meta( get_current_user_id(), $wpdb->prefix.'_stripe_customer_id', true); } $is_enabled = $arr_stripe['enabled']; if($is_enabled == 'yes'){ $is_testmode = $arr_stripe['testmode']; if($is_testmode == 'yes'){ //$publishable_key = $arr_stripe['test_publishable_key']; $secret_key = $arr_stripe['test_secret_key']; } elseif ($is_testmode == 'no') { //$publishable_key = $arr_stripe['publishable_key']; $secret_key = $arr_stripe['secret_key']; } } } $stripe = new \Stripe\StripeClient( $secret_key ); $stripe_customer = new \Stripe\Customer( $stripe_customer_id ); $token = WC_Payment_Tokens::get( $payment_method_id ); // Update the default payment source $default_token = $token->get_token(); $stripe->customers->update( $stripe_customer_id, ['invoice_settings' => ['default_payment_method' => $default_token]] ); return $default_token; } __('Please make sure you have entered a mobile phone number and test message.', 'woo_ua'), ); /* Register globally scripts */ wp_register_script( 'uwa-twilio-sms-admin', UW_AUCTION_PRO_ASSETS_URL . '/js/addons/uwa-twilio-sms-admin.js', array('jquery'), UW_AUCTION_PRO_VERSION ); wp_localize_script('uwa-twilio-sms-admin', 'UWA_TWILIO_SMS', array('ajaxurl' => admin_url('admin-ajax.php'), 'UWA_TWILIO_SMS_NONCE' => wp_create_nonce('UtAajax-nonce') )); wp_localize_script('uwa-twilio-sms-admin', 'uwa_twilio_data', $uwa_twilio_data); wp_enqueue_script( 'uwa-twilio-sms-admin' ); } }UWA_Twilio_SMS_Scripts::get_instance(); Page not found – Matthew Price, Auctioneer & Real Estate Broker




It looks like nothing was found at this location. Maybe try one of the links below or a search?