woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.3k stars 10.74k forks source link

404 Page in Thank You / order-recieved page #4863

Closed MrVibe closed 10 years ago

MrVibe commented 10 years ago

Hi, I am getting a 404 page after a custom completes an order. Earlier there used to be a setting to set a custom thank you page, how can this be done now ? All WooCommerce templates used in the theme are up to date as per system status. There has been a lot of changes in WooCommerce. Mainly in the settings (which I believe earlier were much simple and great). I could not find any info in this regard on woothemes documents so assuming the documentation work is still in progress. Let me know if this is a known issue.

mikejolley commented 10 years ago

The gateway you are using needs to be updated to return the user to the order-received endpoint, rather than the 'thanks' page which no longer exists. Check with the author of the payment gateway.

MrVibe commented 10 years ago

The payment gateway is payal and I am testing it with sandbox ..

mikejolley commented 10 years ago

Go save your permalinks in settings > permalinks. See if other endpoints are working, e.g the edit address one under "my account"

MrVibe commented 10 years ago

Well, just to notify the above issue is still not resolved. And confirming that all the other end points are also returning a 404 page. I have flushed the permalinks countless times. The issue is basically with a custom plugin which registers custom post type and adds meta boxes. I am adding new custom post types on init hook and the flush_rewrite_rules( false ) is called only on plugin activation. I am testing this on WP, WP + BP, WP + Multisite + BP and all return 404 page on all the WooCommerce endpoints.

Any help in this regard would be highly useful.

mikejolley commented 10 years ago

Want to provide the code?

MrVibe commented 10 years ago

Attached is the file which registers all the custom post types and flushes the permalinks when the plugin is activated.

On Thu, Mar 20, 2014 at 2:34 PM, Mike Jolley notifications@github.comwrote:

Want to provide the code?

Reply to this email directly or view it on GitHubhttps://github.com/woothemes/woocommerce/issues/4863#issuecomment-38146364 .

mikejolley commented 10 years ago

No attached. Do it via the github site.

MrVibe commented 10 years ago

Here's the snippet, which I think may be causing the issue. Rest of the code does not do anything with permalinks..


add_action( 'admin_menu', 'register_lms_menu_page' );

function register_lms_menu_page(){
    add_menu_page( 'Learning Management System', 'LMS', 'edit_posts', 'lms', 'vibe_lms_dashboard','',7 );
    add_submenu_page( 'lms', 'Statistics', 'Statistics',  'edit_posts', 'lms-stats', 'vibe_lms_stats' );
    add_submenu_page( 'lms', 'Settings', 'Settings',  'manage_options', 'lms-settings', 'vibe_lms_settings' );
    //admin.php?page=lms
   // add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function )
}

/*== PORTFOLIO == */
if(!function_exists('register_lms')){
function register_lms($init=NULL) {

    register_post_type( 'course',
        array(
            'labels' => array(
                'name' => 'Courses',
                'menu_name' => 'Courses',
                'singular_name' => 'Course',
                'add_new_item' => 'Add New Course',
                'all_items' => 'All Courses'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'capapbility_type' => 'post',
            'has_archive' => true,
            'show_in_menu' => 'lms',
            'show_in_nav_menus' => true,
            'taxonomies' => array( 'course-cat'),
            'supports' => array( 'title','editor','thumbnail','author','comments','excerpt','revisions'),
            'hierarchical' => true,
            'show_in_nav_menus' => true,
            'rewrite' => array( 'slug' => 'course', 'hierarchical' => true, 'with_front' => false )
        )
    );
    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );

    register_taxonomy( 'course-cat', array( 'course'),
        array(
            'labels' => array(
                'name' => 'Category',
                'menu_name' => 'Category',
                'singular_name' => 'Category',
                'add_new_item' => 'Add New Category',
                'all_items' => 'All Categories'
            ),
            'public' => true,
            'hierarchical' => true,
            'show_ui' => true,
            'show_in_menu' => 'lms',
            'show_admin_column' => true,
            'query_var' => 'course-cat',           
            'show_in_nav_menus' => true,
            'rewrite' => array( 'slug' => 'course-cat', 'hierarchical' => true, 'with_front' => false ),
        )
    );

    register_post_type( 'unit',
        array(
            'labels' => array(
                'name' => 'Units',
                'menu_name' => 'Units',
                'singular_name' => 'Unit',
                'add_new_item' => 'Add New Unit',
                'all_items' => 'All Units'
            ),
            'public' => true,
            'taxonomies' => array( 'module-tag'),
            'publicly_queryable' => true,
            'show_ui' => true,
            'has_archive' => true,
            'show_in_menu' => 'lms',
            'show_in_nav_menus' => true,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'post-formats', 'revisions' ),
            'hierarchical' => true,
            'show_in_nav_menus' => false,
            'rewrite' => array( 'slug' => 'unit', 'hierarchical' => true, 'with_front' => false )
        )
     );   
    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );

     register_taxonomy( 'module-tag', array( 'unit'),
        array(
            'labels' => array(
                'name' => 'Tag',
                'menu_name' => 'Tag',
                'singular_name' => 'Tag',
                'add_new_item' => 'Add New Tag',
                'all_items' => 'All Tags'
            ),
            'public' => true,
            'hierarchical' => false,
            'show_ui' => true,
            'show_admin_column' => 'true',
            'show_in_nav_menus' => true,
            'rewrite' => array( 'slug' => 'module-tag', 'hierarchical' => true, 'with_front' => false ),
        )
    );

     register_post_type( 'quiz',
        array(
            'labels' => array(
                'name' => 'Quizes',
                'menu_name' => 'Quizes',
                'singular_name' => 'Quiz',
                'all_items' => 'All Quizes'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'has_archive' => true,
            'show_in_menu' => 'lms',
            'show_in_nav_menus' => true,
            'supports' => array( 'title','editor','thumbnail', 'revisions' ),
            'hierarchical' => true,
            'show_in_nav_menus' => false,
            'rewrite' => array( 'slug' => 'quiz','hierarchical' => true, 'with_front' => false )
        )
     );  

    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );

     register_post_type( 'question',
        array(
            'labels' => array(
                'name' => 'Question Bank',
                'menu_name' => 'Question Bank',
                'singular_name' => 'Question',
                'all_items' => 'All Questions'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'has_archive' => true,
            'show_in_menu' => 'lms',
            'show_in_nav_menus' => true,
            'supports' => array( 'title','editor', 'comments','revisions' ),
            'hierarchical' => true,
            'show_in_nav_menus' => false,
            'rewrite' => array( 'slug' => 'question','hierarchical' => true, 'with_front' => false )
        )
     ); 
    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );

     register_taxonomy( 'question-tag', array( 'question'),
        array(
            'labels' => array(
                'name' => 'Tag',
                'menu_name' => 'Tag',
                'singular_name' => 'Tag',
                'add_new_item' => 'Add New Tag',
                'all_items' => 'All Tags'
            ),
            'public' => true,
            'hierarchical' => false,
            'show_ui' => true,
            'show_admin_column' => 'true',
            'show_in_nav_menus' => true,
            'rewrite' => array( 'slug' => 'question-tag', 'hierarchical' => false, 'with_front' => false ),
        )
    ); 

    add_post_type_support('question','comments');

/*====== Version 1.4 EVENTS =====*/

if ( in_array( 'wplms-events/wplms-events.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {     
     flush_rewrite_rules( false );
register_post_type( 'wplms-event',
        array(
            'labels' => array(
                'name' => 'Events',
                'menu_name' => 'Events',
                'singular_name' => 'Event',
                'add_new_item' => 'Add New Events',
                'all_items' => 'All Events'
            ),
            'public' => true,
            'taxonomies' => array( 'event-type'),
            'publicly_queryable' => true,
            'show_ui' => true,
            'has_archive' => true,
            'show_in_menu' => 'lms',
            'show_in_nav_menus' => true,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'post-formats', 'revisions' ),
            'hierarchical' => true,
            'show_in_nav_menus' => false,
            'rewrite' => array( 'slug' => 'event', 'hierarchical' => true, 'with_front' => true )
        )
     );   
     flush_rewrite_rules( false );

 register_taxonomy( 'event-type', array( 'wplms-event'),
        array(
            'labels' => array(
                'name' => 'Event type',
                'menu_name' => 'Event type',
                'singular_name' => 'Event type',
                'add_new_item' => 'Add New Event type',
                'all_items' => 'All Event types'
            ),
            'public' => true,
            'hierarchical' => true,
            'show_ui' => true,
            'show_admin_column' => true,
            'show_in_nav_menus' => true,
            'rewrite' => array( 'slug' => 'event-type', 'hierarchical' => true, 'with_front' => false ),
        )
    );
 add_post_type_support('wplms-event','comments');
}
/*====== Version 1.3 RECORD PAYMENTS =====*/
    register_post_type( 'payments',
        array(
            'labels' => array(
                'name' => 'Payments',
                'menu_name' => 'Payments',
                'singular_name' => 'Payment',
                'add_new_item' => 'Add New Payment',
                'all_items' => 'Payments History'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'has_archive' => false,
            'show_in_menu' => 'lms',
            'show_in_nav_menus' => false,
            'supports' => array( 'title'),
            'hierarchical' => false,
            'rewrite' => array( 'slug' => 'payments', 'hierarchical' => false, 'with_front' => false )
        )
     );   
    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );

/*====== Version 1.3.2 CERTIFICATE TEMPLATES =====*/
    register_post_type( 'certificate',
        array(
            'labels' => array(
                'name' => 'Certificate Template',
                'menu_name' => 'Certificates Template',
                'singular_name' => 'Certificate Template',
                'add_new_item' => 'Add New Certificate',
                'all_items' => 'Certificate Templates'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'has_archive' => false,
            'show_in_menu' => 'lms',
            'show_in_nav_menus' => false,
            'supports' => array( 'title','editor'),
            'hierarchical' => false,
            'rewrite' => array( 'slug' => 'certificates', 'hierarchical' => false, 'with_front' => false )
        )
     ); 

    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );

    }
}

/*== Testimonials == */
if(!function_exists('register_testimonials')){
function register_testimonials($init=NULL) {
    register_post_type( 'testimonials',
        array(
            'labels' => array(
                'name' => 'Testimonials',
                'menu_name' => 'Testimonials',
                'singular_name' => 'Testimonial',
                'all_items' => 'All Testimonials'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'show_in_nav_menus' => true,
            'supports' => array( 'title', 'editor','excerpt', 'thumbnail'),
            'hierarchical' => false,
            'has_archive' => true,
            'menu_position' => 10,
            'show_in_nav_menus' => false,
            'rewrite' => array( 'slug' => 'testimonial', 'hierarchical' => true, 'with_front' => false )
        )
    );

    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );
}
}
/*== Popups == */
if(!function_exists('register_popups')){
function register_popups($init=NULL) {
    register_post_type( 'popups',
        array(
            'labels' => array(
                'name' => 'Popups',
                'menu_name' => 'Popups',
                'singular_name' => 'Popup',
                'all_items' => 'All Popups'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'show_in_nav_menus' => false,
            'supports' => array( 'title', 'editor','excerpt' ),
            'hierarchical' => false,
            'has_archive' => false,
            'menu_position' => 8,
            'show_in_nav_menus' => false,
            'rewrite' => array( 'slug' => 'popup', 'hierarchical' => true, 'with_front' => false )
        )
    );

    if(isset($init) && $init) // Run only once when the Plugin is activated
        flush_rewrite_rules( false );
}

}

add_action( 'init', 'register_lms' );
add_action( 'init', 'register_testimonials' );
add_action( 'init', 'register_popups' );

And I have this

register_activation_hook(__FILE__,'custom_init');
function custom_init() {
   register_lms(1);
   register_popups(1);
   register_testimonials(1);
}

I have tested this with Twentyfourteen and as soon as this code is active I start getting 404 on all the WooCommerce end-points

mikejolley commented 10 years ago

I don't know the exact reason, but you could really simplify the above by doing:

register_activation_hook(__FILE__,'register_lms'); register_activation_hook(__FILE__,'register_popups', 11); register_activation_hook(__FILE__,'register_testimonials', 12); register_activation_hook(__FILE__,'flush_rewrite_rules', 20);

and then removing all those inline flushes.

MrVibe commented 10 years ago

Bingo ! that fixed it.

GzusGo commented 10 years ago

I have the same issue with one os my site, After the user made the payment it send him to a 404 page. but the sell proceed without mayor problem. I were doing a lot of thing to get off this bug, but none of them solve the problem. The solution above probably works but is not clear to me; to in witch file i supposed to put this code in?

My Temporally solution to it was this: Like the issue it is seems to be just a cosmetically problem, I just make a 404.php file to capture the error and i add a script for re-direct the user to the home. them no more 404.

but it is necessary fix this bug. i were reading that it is very common.

dinethenation commented 10 years ago

I have the same issue, been trying to fix this for 5 days with NO LUCK.

This problem needs to be resolved or just do away with "endpoints". I can't believe all the issues without a FIX ????????

dinethenation commented 10 years ago

I have tried fresh installs on multiple themes it appears the endpoints just don't work, the only way they work is by setting "default permalinks" and them that breaks other parts of my site.

Way too long to wait for a FIX !

mikejolley commented 10 years ago

@dinethenation The only way endpoints would break is if another plugin (or theme) is preventing them from being created. It's completely down to your install.

dinethenation commented 10 years ago

I have tried fresh installs of multiple theme with no plugins and still have the same issue???

dinethenation commented 10 years ago

Why would it work with "default permalinks" and not with "page name permalink" ???

mikejolley commented 10 years ago

"default permalinks" don't use htaccess/rewrite rules.

ausworkshop commented 6 years ago

Well, I have the same problem in 2018 and have been reading for hours on the best way to fix, multiple work-arounds or reasons for it occurring but I'm reluctant to try any of them until I understand it better sorry.

I was excited to set up woocommerce at first, I thought it was all so easy to get up and running just the way I wanted, but my luck soon ran out. I got alerted to my first order through it by my very first customer telling me they had no idea if the order went through, it went to a 404 after the order was placed through Square. No thank you, no nothing. So disappointing! I think I might just leave it all for now and go back to my simple PayPal cart unless someone here can help me fix? At least I know this works and I can get paid, although a very amateur way to go.

What's worse is I was never even notified of the order through email, it wasn't until the customer emailed me reporting the problem. At first I thought I'd never got the order, then went in and saw it in my dashboard. Another problem that will probably take me hours to fix. Getting notified when I get an order! I just don't trust it now to ever work with my site, unless I have a few thousand to spend on a developer..

Sorry if this is the wrong place but I'm at a loss, I don't know what to do apart from stop using it all, and I've wasted all this time setting it up and connecting square etc, I was excited to finally bring my payment systems up to scratch and now I'm back to square one or do some kind of redirect to some kind of thank-you page, not even sure if that's what I should be doing. After reading all this I doubt i'll ever figure it out without help, and that seems impossible with the free plugins, until I get this working though I won't be getting any extensions.

mikejolley commented 6 years ago

At least I know this works and I can get paid, although a very amateur way to go.

Important to test the payment flow yourself before launching.

Use the helpdesk if it's Square related. This issue is old so I highly doubt you're having the exact same problem as the OP.