Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Created April 14, 2020 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayemDevs/9398ea5ef310783933f85ebc38042686 to your computer and use it in GitHub Desktop.
Save nayemDevs/9398ea5ef310783933f85ebc38042686 to your computer and use it in GitHub Desktop.
Show wholesale migration button for vendor on my-account page
<?php
add_action( 'woocommerce_after_my_account', 'dokan_vendor_wholesale_btn' );
function dokan_vendor_wholesale_btn() {
$user_id = get_current_user_id();
$user = get_user_by( 'id', $user_id );
$wholesale_customer = metadata_exists( 'user', $user_id, '_is_dokan_wholesale_customer' );
?>
<?php if ( $wholesale_customer ): ?>
<?php if ( ! $user->has_cap( 'dokan_wholesale_customer' ) ): ?>
<li class="dokan-wholesale-migration-wrapper">
<div class="woocommerce-info" style="margin-bottom:0px"><?php _e( 'Your wholesale customer request send to the admin. Please wait for approval', 'dokan' ); ?></div>
</li>
<?php endif ?>
<?php else: ?>
<li class="dokan-wholesale-migration-wrapper">
<div class="dokan-w8 left-content">
<p><strong><?php _e( 'Become a Wholesale Customer', 'dokan' ) ?></strong></p>
<p><?php _e( 'Wholesale customers can purchase products wholesale from vendors.', 'dokan' ) ?></p>
</div>
<div class="dokan-w4 right-content">
<a href="#" class="btn btn-primary" id="dokan-become-wholesale-customer-btn" data-id="<?php echo get_current_user_id(); ?>"><?php _e( 'Become a wholesale customer', 'dokan' ); ?></a>
</div>
<div class="dokan-clearfix"></div>
</li>
<?php endif ?>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment