I include woocommerce/template in my theme with this name : ‘woocommerce’ and also use add_theme_support() in my functions.php to introduce it .
but when user add a product to cart and wants to see the cart , user redirect to index.php
what should I do to fix this ?
Question posted in Woocommerce
The official Woocommerce documentation can be found here.
The official Woocommerce documentation can be found here.
2
Answers
finally I fix it. it was so stupid. I just forgot to add page.php in my theme
because cart shortcut need to display in a page .
@Ali Please share your code so I can have better idea.
OR
Add Theme Support Code to functions.php file
function mytheme_add_woocommerce_support() {
add_theme_support( ‘woocommerce’ );
}
add_action( ‘after_setup_theme’, ‘mytheme_add_woocommerce_support’ );
Created folder “woocommerce” into your theme folder.
Add below code to functions.php file.
function my_custom_add_to_cart_redirect( $url ) {
$url = get_permalink( get_option( ‘woocommerce_checkout_page_id’ ) );
return $url;
}
add_filter( ‘woocommerce_add_to_cart_redirect’, ‘my_custom_add_to_cart_redirect’ );
Try this.