-
-
Save fervous/e8ca52ebc60a6c59dd3b73ebdfe1f3a8 to your computer and use it in GitHub Desktop.
Disable Add Products in WC Vendors Pro if vendor hasn't connected stripe account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This code will disable add product functionality until the stripe connected account is active for the vendor. This will also disable quick links on the main dashboard page. | |
* | |
*/ | |
// Only enable if the Stripe gateway is actually active | |
if ( class_exists('WC_Gateway_Stripe_Connect') ) { | |
// Hook into the dashboard | |
add_action( 'wcv_pro_before_dashboard', 'add_stripe_notice' ); | |
function add_stripe_notice( ){ | |
$settings_page = WCVendors_Pro_Dashboard::get_dashboard_page_url( 'settings/#payment' ); | |
$stripe_token = get_user_meta( get_current_user_id(), '_stripe_connect_access_key' , true ); | |
WC_Vendors::log( $stripe_token ); | |
// WC_Vendors::log( $stripe_token ); | |
if ( empty( $stripe_token ) ){ | |
echo '<div class="woocommerce-error">'; | |
echo '<strong>WAIT!</strong> Before you can add products, you must connect to STRIPE, so you can receive the funds from your sales. <br /><br /> To connect to Stripe, <a href="' . $settings_page .'"><strong>VISIT YOUR STORE DASHBOARD SETTINGS</strong></a> and click the <strong>PAYMENTS</strong> tab.'; | |
echo '</div>'; | |
// disable quicklinks | |
add_filter( 'wcv_dashboard_quick_links', 'disable_quick_links' ); | |
// Lock add new products | |
add_filter( 'wcv_product_table_lock_new_products', 'lock_products' ); | |
} | |
} // add_stripe_notice() | |
// Disable quick links | |
function disable_quick_links( $links ){ | |
return array(); | |
} | |
// Disable add product | |
function locK_products(){ | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment