Show a popup message before redirect
Question
i just wrote this functions:
add_action('woocommerce_before_single_product', 'product_out_of_stock_redirect');
function product_out_of_stock_redirect(){
global $post;
global $product;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) {
$product_cat_id = $term->term_id;
break;
}
$terms1 = get_the_terms( $post->ID, 'pa_marca' );
foreach ( $terms1 as $term1 ) {
$marca = $term1->name;
break;
}
$marca = str_replace(".","-",$marca);
$marca = str_replace("/","-",$marca);
$marca = str_replace("'","",$marca);
if (!$marca) {
$link = get_term_link( (int)$product_cat_id, 'product_cat' );
}
else { $link = get_term_link( (int)$product_cat_id, 'product_cat' ); $link= $link . "?filter_marca=" . $marca; }
if (!$product->is_in_stock()){
wp_redirect( $link, 301 );
exit(); // Always after wp_redirect() to avoid an error
}
}
as you can see this simply functions redirects all user that visit an outofstock products to another page.
But i need to add an alert to keep user informated of that…how can i add a simply popup that alerts an user?
0
woocommerce
4 years
2020-05-30T06:10:19-05:00
2020-05-30T06:10:19-05:00 0 Answers
98 views
0
Leave an answer