Stop users from adding product unless they add a payment gateway

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Marketplace (WooCommerce Multivendor Marketplace) Stop users from adding product unless they add a payment gateway

Viewing 1 reply thread
  • Author
    Posts
    • #101763
      studiomonkriss
      Participant

      Hi,

      I found this code which shows a message when users have not added Stripe as a payment gateway. This is great!
      However, is it possible to make it work with Stripe and Paypal? Users can choose between Stripe or PayPal so it would be cool if it says “You have not set up a payment method yet” – because I can see this works for just Stripe at the moment?

      add_filter( ‘wcfm_is_allow_pm_add_products’, function( $is_allow ) {
      if( wcfm_is_vendor() ) {
      $vendor_id = apply_filters( ‘wcfm_current_vendor_id’, get_current_user_id() );
      $vendor_data = get_user_meta( $vendor_id, ‘wcfmmp_profile_settings’, true );
      $payment_mode = isset( $vendor_data[‘payment’][‘method’] ) ? esc_attr( $vendor_data[‘payment’][‘method’] ) : ” ;
      $stripe_user_id = get_user_meta( $vendor_id, ‘stripe_user_id’, true );
      if( !$payment_mode || !$stripe_user_id ) {
      wcfm_restriction_message_show( “Stripe account not yet setup!” );
      $is_allow = false;
      }
      }
      return $is_allow;
      }, 750 );

      Also, the beginning of the message is fine, but can we remove the “Your Free Store membership level doesn’t give you……” section? They don’t need to upgrade to add a payment method so that part of the message is unimportant (attached image of it)

      Thanks :))))

      Attachments:
      You must be logged in to view attached files.
    • #103444
      Sushobhan
      Keymaster

      Hello,
      Thanks for getting in touch as sorry for any inconvenience caused.

      add_filter( 'wcfm_is_allow_pm_add_products', function( $is_allow ) {
          if ( wcfm_is_vendor() ) {
              $vendor_id = apply_filters( 'wcfm_current_vendor_id', get_current_user_id() );
              $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
              $payment_mode = isset( $vendor_data['payment']['method'] ) ? esc_attr( $vendor_data['payment']['method'] ) : '';
              if ( ! $payment_mode ) {
                  wcfm_restriction_message_show( 'You have not set up a payment method yet!' );
                  return false;
              }
          }
          return $is_allow;
      }, 750 );
      
      add_filter('gettext', 'change_text_fn', 10, 3);
      function change_text_fn($translation, $text, $domain) {
          if($domain=='wc-frontend-manager' && strpos($text, '%s: Your %s membership level doesn\'t give you permission to access this page. Please upgrade your membership, or contact the %sWebsite Manager%s for assistance.')) {
              return str_replace('%s: Your %s membership level doesn\'t give you permission to access this page. Please upgrade your membership, or contact the %sWebsite Manager%s for assistance.', '%s', $text);
          }
          return $translation;
      }

      Add this code to your child theme’s functions.php, In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
      Let me know how this goes.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.