Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

How to set a redirect rule for vendor pages?

MultivendorX

Open
Viewing 6 reply threads
  • Author
    Posts
    • #219465
      l.gan
      Participant

      Please help me with redirects.
      I’m using the old vendor page with the code:

      add_filter('mvx_load_default_vendor_store', '__return_true');
      Copy

      The vendor’s store page is located at
      https://.com/seller/nike/

      But there are also child pages there, as I understand they are generated by the plugin
      https://.com/seller/nike/reviews/
      https://.com/seller/nike/policies/

      Do I need to redirect from these two pages reviews/ and policies/ to the vendor page? those. at https://.com/seller/nike/?

      I’m not good at PHP, but the code does not redirect the URL. Could you help me with this?

      function custom_taxonomy_redirects() {
          add_rewrite_rule(
              '^seller/([^/]+)/reviews/?$',
              'index.php?dc_vendor_shop=$matches[1]&redirect=1', 
              'top'
          );
          add_rewrite_rule(
              '^seller/([^/]+)/policies/?$',
              'index.php?dc_vendor_shop=$matches[1]&redirect=1', 
              'top'
          );
      }
      add_action('init', 'custom_taxonomy_redirects');
      
      function do_custom_taxonomy_redirect() {
          if ( get_query_var( 'redirect' ) == 1 ) {
              $term_slug = get_query_var( 'dc_vendor_shop' );
              $term_link = get_term_link( $term_slug, 'dc_vendor_shop' );
              wp_redirect( $term_link, 301 ); 
              exit;
          }
      }
      add_action( 'template_redirect', 'do_custom_taxonomy_redirect' );
      Copy
    • #219483

      Hello @l.gan, Presently, users have seamless access to reviews, policies, and product pages directly from the vendor store page.
      Could you specify the desired workflow on your end? This will help us to assist you accordingly.

      • #219510
        l.gan
        Participant
        This reply has been marked as private.
    • #219526

      Hello There, Thanks for explaining your requirements to us. Our replies are inline –
      1)For your required flow, you will have to add custom code on your end to redirect the users from the vendor review or the policy page to the vendor store page.
      2) We have checked this on our end but did not face any such issue mentioned by you. Kindly check the video here https://www.awesomescreenshot.com/video/27313237?key=5a8953f498a0169a6f81e6ae696c7ce5.
      It seems there might be some plugin conflict on your end. Just to be sure, deactivate all plugins except WooCommerce and MultiVendorX and check the flow again.
      Let us know if you need any further assistance from our end.

      • #219547
        l.gan
        Participant
        This reply has been marked as private.
    • #219548

      Hi there, thanks for getting back to us. Our replies are inline –
      2) We will check the issue on your shared site and get back to you accordingly.
      1) To be very honest currently we do not have any readymade code on our end for the customisation that you are looking for on your end. However, our team will check this and assist you accordingly to achieve your required flow.
      But please note, the replies might get delayed as we are closed during the weekends.

      • #219549
        l.gan
        Participant

        Thank you Sangita

        1. I think this code helped me, but I’m not sure if it’s correct.

        
        add_action( 'template_redirect', function() {
            if ( preg_match( '#^/seller/([^/]+)/(reviews|policies)/?$#i', $_SERVER['REQUEST_URI'], $matches ) ) {
                $term_slug = $matches[1]; 
                $redirect_url = home_url( '/seller/' . $term_slug ); 
                wp_redirect( $redirect_url, 301 ); 
                exit;
            }
        } );
        Copy
        • #219731
          l.gan
          Participant

          This code creates redirects, but leads to errors in the dashboard and when adding to cart.

    • #219550

      Kindly give us some time to check this and get back to you accordingly.

    • #219735

      Can you please share in detail what errors are you getting on your end so that we can assist you accordingly.

    • #220037
      l.gan
      Participant
      This reply has been marked as private.
Viewing 6 reply threads

Please LOGIN to reply to this topic