Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Stop users from adding product unless they add a payment gateway
- This topic has 1 reply, 2 voices, and was last updated 4 years, 11 months ago by Sushobhan.
- AuthorPosts
- January 12, 2020 at 3:49 pm #101763studiomonkrissParticipant
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. - January 23, 2020 at 6:25 pm #103444SushobhanKeymaster
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.
- AuthorPosts
- You must be logged in to reply to this topic.