skip to Main Content

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 ?

2

Answers


  1. Chosen as BEST ANSWER

    finally I fix it. it was so stupid. I just forgot to add page.php in my theme

    <?php get_header(); if (have_posts()) {while (have_posts({the_content();}}get_footer();
    

    because cart shortcut need to display in a page .


  2. @Ali Please share your code so I can have better idea.

    OR

    1. 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’ );

    2. Created folder “woocommerce” into your theme folder.

    3. Copy all files from “wp-content/plugins/woocommerce/templates/” to this folder.
    4. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search