Home Forums Stripe Commissions & Gateway Support Check for Stripe Connection?

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #23912
    Anna
    Member

    Hello!
    I’d like to know if there is a way I can implement some kind of check to be sure that a vendor has enabled/connected with Stripe and set up their payment system before their listing(s) go live. As is, a mistake could occur or confusion, and a vendor could list an item for sale without their payment method being set up.

    I currently have it set so that the vendors can list without me having to approve the listings, so I was hoping there may be some way to check/verify for the Stripe connection automatically?

    I don’t know what kind of function I would need to look at creating for this to be possible, or if it is possible with this plugin.

    Any ideas?
    Thank you!

    #23913
    WC Vendors Support
    Participant

    Hi Anna,

    This would be rather easy, actually.

    You’d modify your add/edit product form, and wrap the entire thing in this:

    <?php
    $access_token = get_user_meta( $vendor_id, '_stripe_connect_access_key', true );
    if ( empty( $access_token ) ) {
       // BEGIN PRODUCT FORM
    
       // Put the ENTIRE add/edit product form here.  Keep in mind if you need to close/open PHP tags at the beginning or end of the product form.
    
      // END PRODUCT FORM
    
    } else {
    
    echo 'Before you can add or edit products, you must connect to Stripe, so you can receive your commissions.  To connect to Stripe, <a href="/dashboard/settings/">visit the dashboard</a> and click the Payments tab.';
    }
    ?>
    #23966
    Anna
    Member

    Glad to know this can be done without too much hassle. I appreciate the help, Ben.
    However… I have tried this in several different places and looked for php tags that needed tending… I cannot get this to work.
    I just keep getting the white screen.

    I edit the relocated /dashboard/product-edit.php template, correct?

    It seems like there is one too many or one too few <?php and/or ?> but I cannot tell where….

    Here is what I have done:

    <?php
    /**
     * The template for displaying the Product edit form  
     *
     * Override this template by copying it to yourtheme/wc-vendors/dashboard/
     *
     * @package    WCVendors_Pro
     * @version    1.2.0
     */
    /**
     *   DO NOT EDIT ANY OF THE LINES BELOW UNLESS YOU KNOW WHAT YOU'RE DOING 
     *   
    */
    
    $title = 	( is_numeric( $object_id ) ) ? __('Save Changes', 'wcvendors-pro') : __('Add Product', 'wcvendors-pro'); 
    $product = 	( is_numeric( $object_id ) ) ? wc_get_product( $object_id ) : null;
    
    // Get basic information for the product 
    $product_title     			= ( isset($product) && null !== $product ) ? $product->post->post_title    : ''; 
    $product_description        = ( isset($product) && null !== $product ) ? $product->post->post_content  : ''; 
    $product_short_description  = ( isset($product) && null !== $product ) ? $product->post->post_excerpt  : ''; 
    
    /**
     *  Ok, You can edit the template below but be careful!
    */
    ?>
    <?php
    $access_token = get_user_meta( $vendor_id, '_stripe_connect_access_key', true );
    if ( empty( $access_token ) ) {
       // BEGIN PRODUCT FORM
    
       // Put the ENTIRE add/edit product form here.  Keep in mind if you need to close/open PHP tags at the beginning or end of the product form.
    
    <h2><?php echo $title; ?></h2>
    
       
    <!-- Product Edit Form -->
    <form method="post" action="" id="wcv-product-edit" class="wcv-form wcv-formvalidator"> 
    
    	<!-- Basic Product Details -->
    	<div class="wcv-product-basic wcv-product"> 
    		<!-- Product Title -->
    		<?php WCVendors_Pro_Product_Form::title( $object_id, $product_title ); ?>
    		<!-- Product Description -->
    		<?php WCVendors_Pro_Product_Form::description( $object_id, $product_description );  ?>
    		<!-- Product Short Description -->
    		<?php WCVendors_Pro_Product_Form::short_description( $object_id, $product_short_description );  ?>
    		<!-- Product Categories -->
    	    <?php WCVendors_Pro_Product_Form::categories( $object_id, true ); ?>
    	    <!-- Product Tags -->
    	    <?php WCVendors_Pro_Product_Form::tags( $object_id ); ?>
    	    <!-- Product Attributes (if any) -->
    	    <?php WCVendors_Pro_Product_Form::attributes( $object_id, true ); ?>
    	</div>
    
    	<div class="all-100"> 
        	<!-- Media uploader -->
    		<div class="wcv-product-media">
    			<?php WCVendors_Pro_Form_helper::product_media_uploader( $object_id ); ?>
    		</div>
    	</div>
    
    	<hr />
    	
    	<div class="all-100">
    		<!-- Product Type -->
    		<div class="wcv-product-type"> 
    			<?php WCVendors_Pro_Product_Form::product_type( $object_id ); ?>
    		</div>
    	</div>
    
    	<div class="all-100">
    		<div class="wcv-tabs top" data-prevent-url-change="true">
    
    			<?php WCVendors_Pro_Product_Form::product_meta_tabs( ); ?>
    
    			<?php do_action( 'wcv_before_general_tab' ); ?>
    	
    			<!-- General Product Options -->
    			<div class="wcv-product-general tabs-content" id="general">
    			
    				<div class="hide_if_grouped">
    					<!-- SKU  -->
    					<?php WCVendors_Pro_Product_Form::sku( $object_id ); ?>
    					<!-- Private listing  -->
    					<?php WCVendors_Pro_Product_Form::private_listing( $object_id ); ?>
    				</div>
    
    				<div class="options_group show_if_external">
    					<?php WCVendors_Pro_Product_Form::external_url( $object_id ); ?>
    					<?php WCVendors_Pro_Product_Form::button_text( $object_id ); ?>
    				</div>
    
    				<div class="show_if_simple show_if_external">
    					<!-- Price and Sale Price -->
    					<?php WCVendors_Pro_Product_Form::prices( $object_id ); ?>
    				</div>
    
    				<div class="show_if_simple show_if_external"> 
    					<!-- Tax -->
    					<?php WCVendors_Pro_Product_Form::tax( $object_id ); ?>
    				</div>
    
    				<div class="show_if_downloadable" id="files_download">
    					<!-- Downloadable files -->
    					<?php WCVendors_Pro_Product_Form::download_files( $object_id ); ?>
    					<!-- Download Limit -->
    					<?php WCVendors_Pro_Product_Form::download_limit( $object_id ); ?>
    					<!-- Download Expiry -->
    					<?php WCVendors_Pro_Product_Form::download_expiry( $object_id ); ?>
    					<!-- Download Type -->
    					<?php WCVendors_Pro_Product_Form::download_type( $object_id ); ?>
    				</div>
    			</div>
    
    			<?php do_action( 'wcv_after_general_tab' ); ?>
    
    			<?php do_action( 'wcv_before_inventory_tab' ); ?>
    
    			<!-- Inventory -->
    			<div class="wcv-product-inventory inventory_product_data tabs-content" id="inventory">
    				
    				<?php WCVendors_Pro_Product_Form::manage_stock( $object_id ); ?>
    				
    				<?php do_action( 'woocommerce_product_options_stock' ); ?>
    				
    				<div class="stock_fields show_if_simple show_if_variable">
    					<?php WCVendors_Pro_Product_Form::stock_qty( $object_id ); ?>
    					<?php WCVendors_Pro_Product_Form::backorders( $object_id ); ?>
    				</div>
    
    				<?php WCVendors_Pro_Product_Form::stock_status( $object_id ); ?>
    				<div class="options_group show_if_simple show_if_variable">
    					<?php WCVendors_Pro_Product_Form::sold_individually( $object_id ); ?>
    				</div>
    
    				<?php do_action( 'woocommerce_product_options_sold_individually' ); ?>
    
    				<?php do_action( 'woocommerce_product_options_inventory_product_data' ); ?>
    
    			</div>
    
    			<?php do_action( 'wcv_after_inventory_tab' ); ?>
    
    			<?php do_action( 'wcv_before_shipping_tab' ); ?>
    
    			<!-- Shipping  -->
    			<div class="wcv-product-shipping shipping_product_data tabs-content" id="shipping">
    
    				<div class="hide_if_grouped">
    
    					<!-- Shipping rates  -->
    					<?php WCVendors_Pro_Product_Form::shipping_rates( $object_id ); ?>	
    					<!-- weight  -->
    					<?php WCVendors_Pro_Product_Form::weight( $object_id ); ?>
    					<!-- Dimensions -->
    					<?php WCVendors_Pro_Product_Form::dimensions( $object_id ); ?>
    					<?php do_action( 'woocommerce_product_options_dimensions' ); ?>
    					<!-- shipping class -->
    					<?php WCVendors_Pro_Product_Form::shipping_class( $object_id ); ?>
    					<?php do_action( 'woocommerce_product_options_shipping' ); ?>
    				</div>
    			
    			</div>
    
    			<?php do_action( 'wcv_after_shipping_tab' ); ?>
    
    			<?php do_action( 'wcv_before_linked_tab' ); ?>
    
    			<!-- Upsells and grouping -->
    			<div class="wcv-product-upsells tabs-content" id="linked_product"> 
    				<?php WCVendors_Pro_Product_Form::up_sells( $object_id ); ?>
    				
    				<?php WCVendors_Pro_Product_Form::crosssells( $object_id ); ?>
    			</div>
    
    			<?php do_action( 'wcv_after_linked_tab' ); ?>
    
    			<?php WCVendors_Pro_Product_Form::form_data( $object_id ); ?>
    			<?php WCVendors_Pro_Product_Form::save_button( $title ); ?>
    			<?php WCVendors_Pro_Product_Form::draft_button( __('Save Draft',' wcvendors-pro') ); ?>
    
    			</div>
    		</div>
    </form>
     // END PRODUCT FORM
    
    } else {
    
    echo 'Before you can add or edit products, you must connect to STRIPE, so you can receive the funds from your sales.  To connect to Stripe, <a href="/dashboard/settings/">visit the seller dashboard</a> and click the PAYMENTS tab.';
    }
    ?>
    

    I’ve tried moving both ends of the code around, and I just can’t get it to work. I’m probably doing something wrong with the <?php and ?> but I cannot figure out where.

    #23967
    WC Vendors Support
    Participant

    Here’s a great way to test if you’re screwing up the syntax.

    1.) Copy your code via ctrl+c

    2.) go to http://www.phpcodechecker.com

    3.) paste your code, click Analyze! If it says “no issues found” your syntax is correct! Easy as that. 🙂

    I’ve fixed it for you, but try yourself first just for fun. I bet you’ll fix it in just a quick minute.

    <?php
    /**
     * The template for displaying the Product edit form  
     *
     * Override this template by copying it to yourtheme/wc-vendors/dashboard/
     *
     * @package    WCVendors_Pro
     * @version    1.2.0
     */
    /**
     *   DO NOT EDIT ANY OF THE LINES BELOW UNLESS YOU KNOW WHAT YOU'RE DOING 
     *   
    */
    
    $title = 	( is_numeric( $object_id ) ) ? __('Save Changes', 'wcvendors-pro') : __('Add Product', 'wcvendors-pro'); 
    $product = 	( is_numeric( $object_id ) ) ? wc_get_product( $object_id ) : null;
    
    // Get basic information for the product 
    $product_title     			= ( isset($product) && null !== $product ) ? $product->post->post_title    : ''; 
    $product_description        = ( isset($product) && null !== $product ) ? $product->post->post_content  : ''; 
    $product_short_description  = ( isset($product) && null !== $product ) ? $product->post->post_excerpt  : ''; 
    
    /**
     *  Ok, You can edit the template below but be careful!
    */
    
    $access_token = get_user_meta( $vendor_id, '_stripe_connect_access_key', true );
    if ( empty( $access_token ) ) {
       // BEGIN PRODUCT FORM
    
       // Put the ENTIRE add/edit product form here.  Keep in mind if you need to close/open PHP tags at the beginning or end of the product form.
    ?>
    
    <h2><?php echo $title; ?></h2>
    
       
    <!-- Product Edit Form -->
    <form method="post" action="" id="wcv-product-edit" class="wcv-form wcv-formvalidator"> 
    
    	<!-- Basic Product Details -->
    	<div class="wcv-product-basic wcv-product"> 
    		<!-- Product Title -->
    		<?php WCVendors_Pro_Product_Form::title( $object_id, $product_title ); ?>
    		<!-- Product Description -->
    		<?php WCVendors_Pro_Product_Form::description( $object_id, $product_description );  ?>
    		<!-- Product Short Description -->
    		<?php WCVendors_Pro_Product_Form::short_description( $object_id, $product_short_description );  ?>
    		<!-- Product Categories -->
    	    <?php WCVendors_Pro_Product_Form::categories( $object_id, true ); ?>
    	    <!-- Product Tags -->
    	    <?php WCVendors_Pro_Product_Form::tags( $object_id ); ?>
    	    <!-- Product Attributes (if any) -->
    	    <?php WCVendors_Pro_Product_Form::attributes( $object_id, true ); ?>
    	</div>
    
    	<div class="all-100"> 
        	<!-- Media uploader -->
    		<div class="wcv-product-media">
    			<?php WCVendors_Pro_Form_helper::product_media_uploader( $object_id ); ?>
    		</div>
    	</div>
    
    	<hr />
    	
    	<div class="all-100">
    		<!-- Product Type -->
    		<div class="wcv-product-type"> 
    			<?php WCVendors_Pro_Product_Form::product_type( $object_id ); ?>
    		</div>
    	</div>
    
    	<div class="all-100">
    		<div class="wcv-tabs top" data-prevent-url-change="true">
    
    			<?php WCVendors_Pro_Product_Form::product_meta_tabs( ); ?>
    
    			<?php do_action( 'wcv_before_general_tab' ); ?>
    	
    			<!-- General Product Options -->
    			<div class="wcv-product-general tabs-content" id="general">
    			
    				<div class="hide_if_grouped">
    					<!-- SKU  -->
    					<?php WCVendors_Pro_Product_Form::sku( $object_id ); ?>
    					<!-- Private listing  -->
    					<?php WCVendors_Pro_Product_Form::private_listing( $object_id ); ?>
    				</div>
    
    				<div class="options_group show_if_external">
    					<?php WCVendors_Pro_Product_Form::external_url( $object_id ); ?>
    					<?php WCVendors_Pro_Product_Form::button_text( $object_id ); ?>
    				</div>
    
    				<div class="show_if_simple show_if_external">
    					<!-- Price and Sale Price -->
    					<?php WCVendors_Pro_Product_Form::prices( $object_id ); ?>
    				</div>
    
    				<div class="show_if_simple show_if_external"> 
    					<!-- Tax -->
    					<?php WCVendors_Pro_Product_Form::tax( $object_id ); ?>
    				</div>
    
    				<div class="show_if_downloadable" id="files_download">
    					<!-- Downloadable files -->
    					<?php WCVendors_Pro_Product_Form::download_files( $object_id ); ?>
    					<!-- Download Limit -->
    					<?php WCVendors_Pro_Product_Form::download_limit( $object_id ); ?>
    					<!-- Download Expiry -->
    					<?php WCVendors_Pro_Product_Form::download_expiry( $object_id ); ?>
    					<!-- Download Type -->
    					<?php WCVendors_Pro_Product_Form::download_type( $object_id ); ?>
    				</div>
    			</div>
    
    			<?php do_action( 'wcv_after_general_tab' ); ?>
    
    			<?php do_action( 'wcv_before_inventory_tab' ); ?>
    
    			<!-- Inventory -->
    			<div class="wcv-product-inventory inventory_product_data tabs-content" id="inventory">
    				
    				<?php WCVendors_Pro_Product_Form::manage_stock( $object_id ); ?>
    				
    				<?php do_action( 'woocommerce_product_options_stock' ); ?>
    				
    				<div class="stock_fields show_if_simple show_if_variable">
    					<?php WCVendors_Pro_Product_Form::stock_qty( $object_id ); ?>
    					<?php WCVendors_Pro_Product_Form::backorders( $object_id ); ?>
    				</div>
    
    				<?php WCVendors_Pro_Product_Form::stock_status( $object_id ); ?>
    				<div class="options_group show_if_simple show_if_variable">
    					<?php WCVendors_Pro_Product_Form::sold_individually( $object_id ); ?>
    				</div>
    
    				<?php do_action( 'woocommerce_product_options_sold_individually' ); ?>
    
    				<?php do_action( 'woocommerce_product_options_inventory_product_data' ); ?>
    
    			</div>
    
    			<?php do_action( 'wcv_after_inventory_tab' ); ?>
    
    			<?php do_action( 'wcv_before_shipping_tab' ); ?>
    
    			<!-- Shipping  -->
    			<div class="wcv-product-shipping shipping_product_data tabs-content" id="shipping">
    
    				<div class="hide_if_grouped">
    
    					<!-- Shipping rates  -->
    					<?php WCVendors_Pro_Product_Form::shipping_rates( $object_id ); ?>	
    					<!-- weight  -->
    					<?php WCVendors_Pro_Product_Form::weight( $object_id ); ?>
    					<!-- Dimensions -->
    					<?php WCVendors_Pro_Product_Form::dimensions( $object_id ); ?>
    					<?php do_action( 'woocommerce_product_options_dimensions' ); ?>
    					<!-- shipping class -->
    					<?php WCVendors_Pro_Product_Form::shipping_class( $object_id ); ?>
    					<?php do_action( 'woocommerce_product_options_shipping' ); ?>
    				</div>
    			
    			</div>
    
    			<?php do_action( 'wcv_after_shipping_tab' ); ?>
    
    			<?php do_action( 'wcv_before_linked_tab' ); ?>
    
    			<!-- Upsells and grouping -->
    			<div class="wcv-product-upsells tabs-content" id="linked_product"> 
    				<?php WCVendors_Pro_Product_Form::up_sells( $object_id ); ?>
    				
    				<?php WCVendors_Pro_Product_Form::crosssells( $object_id ); ?>
    			</div>
    
    			<?php do_action( 'wcv_after_linked_tab' ); ?>
    
    			<?php WCVendors_Pro_Product_Form::form_data( $object_id ); ?>
    			<?php WCVendors_Pro_Product_Form::save_button( $title ); ?>
    			<?php WCVendors_Pro_Product_Form::draft_button( __('Save Draft',' wcvendors-pro') ); ?>
    
    			</div>
    		</div>
    </form>
    
    <?php
    // END PRODUCT FORM
    } else {
    
    echo 'Before you can add or edit products, you must connect to STRIPE, so you can receive the funds from your sales.  To connect to Stripe, <a href="/dashboard/settings/">visit the seller dashboard</a> and click the PAYMENTS tab.';
    }
    ?>
    #23971
    Anna
    Member

    Thanks, Ben!
    That’s a nifty tool- thanks for sharing that site. It will help me in the future.

    I definitely see what I did. I danced around the right opening/closing tags … didn’t quite get it.

    HOWEVER… so far in my testing, a vendor that has not yet connected with Stripe is still able to add products. ? I’ll keep testing, but this code does not seem to be working at this point.

    #23982
    WC Vendors Support
    Participant

    Change:

    $access_token = get_user_meta( $vendor_id, '_stripe_connect_access_key', true );

    to:

    $access_token = get_user_meta( get_current_user_id(), '_stripe_connect_access_key', true );

    #23983
    Anna
    Member

    Thanks, Ben.

    I followed your directions, and there are no access token numbers showing.
    I logged in as both a vendor with and then a vendor without a stripe account connected.

    #23985
    Anna
    Member

    The new code shows the access token for a connected account. Strangely, though, it tells the vendor with a connected account that they cannot add a product, and directs them to the settings page.

    For a vendor with an unconnected account, it shows the empty access token area, and then it allows the vendor WITHOUT the connected account to add a product. Exactly the opposite of what we were trying to do. 😛

    #23986
    WC Vendors Support
    Participant

    See? This is why Jamie’s lead developer. 🙂

    So, we got the logic goofed. Let’s reverse it! ! = not, so let’s do the not check.

    Change:

    if ( empty( $access_token ) ) {

    to:

    if ( !empty( $access_token ) ) {

    Voila!

    #23987
    Anna
    Member

    That’s it!
    Thanks for your help, Ben.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Stripe Commissions & Gateway Support’ is closed to new topics and replies.