@yazdaniwp Pls, can you help. I notice when I try adding a product https://mydomain.com/?add-to-cart=1260 it gives me this error message saying your cart is empty. This is my code, can you direct me on the right one>>>
add_action( 'init', 'ywp_goto_product_after_add_to_cart' );
function ywp_goto_product_after_add_to_cart() {
if ( ! isset ( $_GET['add-to-cart'] ) ) return;
// Remove #
$product_id = intval( $_GET['add-to-cart'] );
// Check id is a product id
$product = wc_get_product( $product_id );
if ( $product ) {
$url = get_the_permalink( $product_id );
wp_safe_redirect( 'cart' );
exit;
}
}
-
This reply was modified 5 years, 8 months ago by Henry I..
@yazdaniwp THANK YOUUUUUUUUU SO MUCH. Been worried because these issues have made me lose a lot of sales. Thanks. It worked, I hard to add “checkout” in place of $url because I want them redirected to my Checkout Page. Thanks.