• Resolved applemango

    (@applemango)


    I’m having a problem with this plugin. I have a custom template for showing products which works great. It is located at /writing/shop

    However if I have the automatic redirection to checkout switched off and I press Add to Cart it redirects to the same page but the templating is all screwed up and shows the default template instead. Weird.

    So I stopped that by enabling redirect to checkout and now on clicking Add to cart it redirects fine to checkout (located at /checkout) which is another custom template using print_wp_shopping_cart(). However if I update quantity or delete an item then the same problem occurs, it redirects to the checkout page but the template shown is the default template again.

    Any idea what’s going on and how to fix it?

    https://www.ads-software.com/plugins/wordpress-simple-paypal-shopping-cart/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor mbrsolution

    (@mbrsolution)

    Hi read the following URL and especially the part that talks about Using in a template file.

    Let me know if that helps.

    Thread Starter applemango

    (@applemango)

    Yes, I’d already seen that page and that is exactly how I’ve got it set up:

    PRODUCTS:
    print_wp_cart_button_for_product($title, $price);

    CART:
    print_wp_shopping_cart();

    Both pages render the button and the full cart okay, it’s when the underlying form is submitted (not the paypal button) that the strange behaviour occurs, loading the default template regardless of the URL.

    Any ideas?

    Plugin Contributor mbrsolution

    (@mbrsolution)

    Have you tried the debug option to see the log files?

    Plugin Author mra13

    (@mra13)

    This seems like an issue with the way your theme is loading template files. Is this a theme you created?

    Thread Starter applemango

    (@applemango)

    The debug option was no help as that only appears to log errors post IPN response.

    Yes I created the theme myself but I solved the problem by adding a function:

    function checkout_page_template( $template ) {
    	$segments = explode('/', $_SERVER['REQUEST_URI']);
    	if(is_page('checkout')  || $segments[1] == 'checkout' ) {
    		$new_template = locate_template( array( 'content_checkout.php' ) );
    		if ( '' != $new_template ) {
    			return $new_template ;
    		}
    	}
    	return $template;
    }
    add_filter( 'template_include', 'checkout_page_template', 99 );

    This is probably not the best solution to this problem but it works and the client is happy. If there is another solution to this please let me know!

    The function you provided works fine. Fairly certain the issue is plugin related, as it happens to me too and the theme is just too simple to be a theme issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Checkout redirection loading default template instead of specified template’ is closed to new replies.