0
  • Create a custom field for dynamic url
  • Or use a static url using commented line

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  ) {
    if( $product->get_stock_status() == 'outofstock'){
        $custom_url = get_field('waitlist', $product->get_id());
        if(!empty($custom_url )){
          $link = $custom_url ;
        }
    }
    // if($product->get_id()=='22313'){
    //   $link = home_url("/cart/");
    // }
    return $link;
}

Jagdish Sarma Asked question April 16, 2024
Add a Comment