code snippet turning theme in to blank page
-
hi i have been using following code snippet to redirect add to cart to custom product page but something is messing up with entire website can u please check whats wrong with the snippet
and what lines should i have to add to redirect add to cart button to a specific product page
function my_custom_add_to_cart_redirect( $url ) {if ( ! isset( $_REQUEST[‘add-to-cart’] ) || ! is_numeric( $_REQUEST[‘add-to-cart’] ) ) {
return $url;
}$product_id = apply_filters( ‘woocommerce_add_to_cart_product_id’, absint( $_REQUEST[‘add-to-cart’] ) );
// Only redirect the product IDs in the array to the checkout
if ( in_array( $product_id, array( 334, 329, 321, 303, 311, 304) ) ) {
$url = get_permalink( $product_id );
}return $url;
}
add_filter( ‘woocommerce_add_to_cart_redirect’, ‘my_custom_add_to_cart_redirect’ );
- The topic ‘code snippet turning theme in to blank page’ is closed to new replies.