我正在尝试隐藏通过WooCommerce简易拍卖插件赢得拍卖后显示的“立即付款”按钮。我已经尝试了很多次,但是从未尝试过,现在我陷入了困境。我可以简单地使用CSS隐藏按钮,但是问题是,使用相同的div类(包括各种插件和主题),会有更多的功能。而且,如果我在插件的源代码中更改了div类,则下一次更新可能会将其重置为默认值。因此,我想用一个功能将其隐藏在主题的functions.php中。
非常感谢您抽出宝贵的时间帮助我。
woocommerce_simple_auction_pay_now_button
是“立即付款”按钮的挂钩/过滤器,这是源代码:
/**
* Ajax finish auction
*
* Function for finishing auction with ajax when countdown is down to zero
*
* @access public
* @param array
* @return string
*
*/
function ajax_finish_auction() {
if (isset($_POST["post_id"])) {
usleep(mt_rand(2000000,5000000));
$product_data = wc_get_product( wc_clean( $_POST["post_id"] ) );
if ($product_data->is_closed()) {
if (isset($_POST["ret"]) && $_POST["ret"] != '0') {
if ($product_data->is_reserved()) {
if (!$product_data->is_reserve_met()) {
_e("Reserve price has not been met", 'wc_simple_auctions');
die();
}
}
if ($product_data->get_auction_current_bider()) {
echo "<div>";
printf(__("Winning bid is %s by %s.", 'wc_simple_auctions'), wc_price($product_data->get_curent_bid()), get_userdata($product_data->get_auction_current_bider())->display_name);
if (get_current_user_id() == $product_data->get_auction_current_bider()){
echo '<a href="'.apply_filters( 'woocommerce_simple_auction_pay_now_button',esc_attr(add_query_arg("pay-auction",$product_data->get_id(), simple_auction_get_checkout_url()))).'" class="button">'.__( 'Pay Now', 'wc_simple_auctions' ).'</a>';
}
echo "</div>";
} else {
echo "<div>";
_e("There were no bids for this auction.", 'wc_simple_auctions');
echo "</div>";
die();
}
}
} else {
echo "<div>";
if (isset($_POST["future"]) && $_POST["future"] == 'true') {
printf(__("Auction has started please refresh page.", 'wc_simple_auctions'));
} elseif (isset($_POST["future"]) && $_POST["future"] == 'false') {
printf(__("Auction has finished please refresh page.", 'wc_simple_auctions'));
} else {
printf(__("Please refresh page.", 'wc_simple_auctions'));
}
echo "</div>";
}
}
die();
}