Skip to content

Instantly share code, notes, and snippets.

@fervous
Created March 29, 2018 03:01
Show Gist options
  • Save fervous/ffc6f8d1ea14aee9e4a29fab35ec3f6e to your computer and use it in GitHub Desktop.
Save fervous/ffc6f8d1ea14aee9e4a29fab35ec3f6e to your computer and use it in GitHub Desktop.
Disable Add Products in WC Vendors Pro if vendor hasn't connected stripe account
<?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