아래의 코드는 맞춤 'On Auction Now!'버튼을 사용하여 장바구니에 추가 할 수 있습니다. 버튼을, 나는 또한 완전히 ...
대신, "가격"버튼 "장바구니에 추가"템플릿을 제거에만 '경매'제품 범주, CSS로 숨어있는, 코드를 재검토 한도 제품 가격 ...
숨기기
코드 :
// Remove the price on archive pages (like shop) for 'auction' product category
add_action('woocommerce_after_shop_loop_item_title', 'remove_price_from_archives', 9);
function remove_price_from_archives(){
global $product, $post;
// Only for 'auction' product category
if (has_term('clothing', 'product_cat'))
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
}
// Replace add to cart button on archive pages (like shop) for 'auction' product category
add_action('woocommerce_after_shop_loop_item', 'replace_add_to_cart_button_in_archives', 9);
function replace_add_to_cart_button_in_archives() {
global $product, $post;
// Only for 'auction' product category
if (! has_term('clothing', 'product_cat')) return;
// remove add to cart button
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
$skusearch = $product->get_sku();
$style = 'style="font-size:100%;color:#fff;padding:.618em 1em;border-radius:3px;background-color:#ed1c24;font-weight:700;"';
$href = 'href="https://www.wirebids.com/search?q=' . $skusearch . '&open_closed=open"';
echo '<div style="margin-top:24px;">
<a '.$href.' id="auction" '.$style.' target="blank">' . __ ('On Auction Now!', 'your-plugin') . '</a>
</div>';
}
// Remove the displayed price and add-to-cart button on single product pages for 'auction' product category
// Replace add to cart by your custom "On Auction Now!" button
add_action('woocommerce_single_product_summary', 'remove_the_displayed_price_from_variable_products', 9);
function remove_the_displayed_price_from_variable_products() {
global $product, $post;
// Only for 'auction' product category
if (has_term('clothing', 'product_cat')){
// remove product price
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
// remove add-to-cart button
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
// Add your custom "On Auction Now!" button
add_action('woocommerce_single_product_summary', 'replace_add_to_cart_by_auction', 30);
}
}
// This function displays your custom button replacement in single product pages
function replace_add_to_cart_by_auction(){
global $product;
$skusearch = $product->get_sku();
$style = 'style="font-size:100%;color:#fff;padding:.618em 1em;border-radius:3px;background-color:#ed1c24;font-weight:700;"';
$href = 'href="https://www.wirebids.com/search?q=' . $skusearch . '&open_closed=open"';
echo '<p>Click This Button To View The Lot</p>
<a '.$href.' id="auction" '.$style.' target="blank">' . __ ('On Auction Now!', 'your-plugin') . '</a>';
}
코드 활성 자식 테마 (또는 테마)의 function.php 파일에 간다 나 또한 어떤 플러그인 파일입니다.
이 코드는 테스트되었으며 작동합니다.
한 가지 문제 만 있습니다. http://boggsequipment.com/product-category/used-products/이 코드를 사용하고있는 웹 사이트입니다. 어떤 이유에서든, 첫 번째 경매 항목 다음에이 첫 번째 항목 이후의 항목에는 '더 많은 링크 읽기'링크가 표시되지 않습니다. 모든 상점 페이지의 경우 인 것 같습니다. 네 생각을 말해봐. 그것 이외에, 그것은 완벽하게 작동합니다. – hippocoder
문제가 웹 사이트의 다른 코드와 관련되어 있었지만 Loic의 코드에는 문제가 없었습니다. – hippocoder