• Resolved flannelgraphs

    (@flannelgraphs)


    We currently are charging a flat rate of $5 to our retail customers. We need to charge more to our wholesale customers because their orders are obviously much greater in size. How do I A. prevent wholesalers from purchasing less that $300 of product and B. charge them a flat rate of $50. All of our products are the same (except for a few subscriptions that are retail only) and I don’t see an option to choose more than one shipping class per product. We’re currently using a wholesale plugin from Barn2, but that doesn’t have a way to customize this. I’m hoping WooCommerce has a workaround OR someone can suggest a great plugin to accomodate our needs. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Ahir Hemant

    (@hemant-ahir)

    Hi @flannelgraphs

    How do I A.

    So you must have user role like wholesalersetc. I don’t think you need plugin but by below code might be you will achive that what you want..

    Go to wp-content/plugins/WooCommerce/templates/cart directory and look up for cart-totals.php file
    Copy this file and go to your theme/child theme, create a folder WooCommerce/cart and paste cart-total.php file here.
    The structure will be something like /wp-content/themes/{Your-theme-name}/woocommerce/cart/cart-totals.php
    After copy pasting the file, open the file in the editor and look for the code line:

    <div class="wc-proceed-to-checkout">
          <?php do_action( 'woocommerce_proceed_to_checkout' ); ?>
     </div>
     
     Replace the above code with the lines below.
    
    <div class="wc-proceed-to-checkout">
    <?php
       //Get current user and check the user role.
    
       $current_screen_user = wp_get_current_user();
    
    // In my scenario “wholesale_buyer” is the user role for which I want this validation. You can add your user roles.
    
        if( in_array( 'wholesale_buyer', $current_screen_user->roles ) ) {
    
          $minimum = 300; // Set the minimum amt.
          $cart_amt = WC()->cart->subtotal; // cart sub_total, this is actual total excluding discounts and shipping.
    
                    if ( $cart_amt < $minimum ) {
              if( is_cart() ) {
            //Added notices for cart page.
                  wc_print_notice(
                      sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
                          wc_price( $minimum ),
                          wc_price( $cart_amt )
                      ), 'error'
                  );
              } else {
            //Added notice msg for checkout page.
    
                  wc_add_notice(
                      sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
                          wc_price( $minimum ),
                          wc_price( $cart_amt)
                      ), 'error'
                  );
              }
          } else {
              do_action( 'woocommerce_proceed_to_checkout' );
          }
        } else {
          do_action( 'woocommerce_proceed_to_checkout' );
        }
        ?>
       </div>

    Note: Please note that you need to change ROLE in above code as per your current setup.

    From the above code snippet, we hide the Proceed To Checkout button on cart page and add validations on cart page.

    Thanks
    Ahir Hemant

    Thread Starter flannelgraphs

    (@flannelgraphs)

    Ok, so this will set a minimum order total it looks like…how do I set a flat fee for shipping for my wholesalers along with this? Also, is there a plugin that will accomplish this rather than code? I’m afraid I’m going to seriously mess something up if I start editing that much code on the site.

    Thanks!

    Hey @flannelgraphs,

    Have you taken a look at the Conditional Shipping and Payments plugin? It lets you make certain shipping methods (and their costs) only available when certain conditions are met. If you have a wholesale user role, you could use that to restrict access to the $50 shipping rate.

    https://woocommerce.com/products/conditional-shipping-and-payments/

    There is a 30 day refund window so you can try it out and see if it meets your needs. If it doesn’t, let us know and we can get your money back for you.

    Let me know if you have any questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Wholesale flat rate’ is closed to new replies.