mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-02 12:02:25 +08:00
https://stackoverflow.com/questions/49523236/change-read-more-button-link-on-out-of-stock-woocommerce-products
10 lines
343 B
Text
10 lines
343 B
Text
add_filter( 'woocommerce_product_add_to_cart_url', 'out_of_stock_read_more_url', 50, 2 );
|
|
function out_of_stock_read_more_url( $link, $product ) {
|
|
// Only for "Out of stock" products
|
|
if( $product->get_stock_status() == 'outofstock' ){
|
|
|
|
// Here below we change the link
|
|
$link = home_url("/");
|
|
}
|
|
return $link;
|
|
}
|