• Resolved esupply

    (@esupply)


    Hello,

    I have a problem with the error messages right now. I have multiple vendors where available on the website but the user can’t buy from different vendors. When an user tries to do this, it’s shows an error message on the page, but first it redirects to the home page..

    I found a snippet to stop the redirection to the home page but then there is no error message coming up unless you refresh the page.

    So in short; Is there a snippet that lets you refresh to the same page the error message needs to be shown on? Now it redirects to the home page.. I can’t provide an URL, the snippet needs to check what page the error is coming from and redirect back to that page instead of the home page.

    Best,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @esupply – I’ve not seen a particular issue like this on in WooCommerce core, which makes me think something is causing the redirect.

    The best way to determine this is to:

    • Temporarily switch your theme to Storefront
    • Disable all plugins except for WooCommerce
    • Repeat the action that is causing the problem

    If you’re not seeing the same problem after completing the conflict test, then you know the problem was with the plugins and/or theme you deactivated. To figure out which plugin is causing the problem, reactivate your other plugins one by one, testing after each, until you find the one causing conflict. You can find a more detailed explanation on how to do a conflict test here.

    Thread Starter esupply

    (@esupply)

    Hello Joey,

    Thank you for your explination, I found what’s causing the redirect and its the following snippet:

    /* DISABLE SINGLE PRODUCT PAGE */
    	// remove single product page link
    	remove_action( 'woocommerce_before_shop_loop_item','woocommerce_template_loop_product_link_open', 10 );
    	remove_action( 'woocommerce_after_shop_loop_item','woocommerce_template_loop_product_link_close', 5 );
    
    	// hide single product page completely
    	add_filter( 'woocommerce_register_post_type_product','hide_product_page',12,1);
    	function hide_product_page($args){
    	  $args["publicly_queryable"]=false;
    	  $args["public"]=false;
    	  return $args;
    	}
    
    function e12_remove_product_image_link( $html, $post_id ) {
        return preg_replace( "!<(a|/a).*?>!", '', $html );
    }
    add_filter( 'woocommerce_single_product_image_thumbnail_html', 'e12_remove_product_image_link', 10, 2 );

    This snippet disables the single product page (which I want and need), but also puts a redirect so it seems..

    Can we edit this snippet so the redirect goes to the same page instead of the home page?

    Best,

    Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there again!

    I’d say that there is likely a way to redirect to the referrer URL, but we’re not really developers to write that.

    I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add to cart error message without reloading page.’ is closed to new replies.