• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WordPress Tips, Code Snippets, and How To Tutorials

  • Home
  • Blog
  • Tips
  • Snippets
  • Tutorials
  • Contact

Payments

How to add a minimum order amount to WooCommerce on WordPress without a plugin

November 9, 2019 by admin Leave a Comment

If you are using WordPress for your website with WooCommerce for ecommerce you may want to have a minimum order amount for product orders on there. If you want to do that without a plugin you can then add this code to your functions.php file. You may want to backup your WordPress website before you make updates the file on there.

New minimum order amount for WooCommerce

/**
 * New minimum order amount
 *
 * @author WPSnacks.com
 * @link https://www.wpsnacks.com
 */
function new_minimum_order_amount() {
    $minimum = #;

    if ( WC()->cart->total < $minimum ) {

        if( is_cart() ) {

            wc_print_notice( 
                sprintf( 'Your order total is %s — you need an order with a minimum of %s to place your order ' , 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );

        } else {

            wc_add_notice( 
                sprintf( 'Your order total is %s — you need an order with a minimum of %s to place your order' , 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );

        }
    }
}
add_action( 'woocommerce_checkout_process', 'new_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'new_minimum_order_amount' );

Then you can replace the # for the minimum. Now if that works for you it would add a minimum order amount to WooCommerce orders on your WordPress website on there.

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Functions.php, Orders, Payments, WooCommerce

How to add the payment type to WooCommerce admin email on WordPress

November 9, 2019 by admin Leave a Comment

If you are using a WooCommerce store on your WordPress website you may want to add the payment type or method to your admin email for new orders on there. If you want to do that without a plugin you can then add this code to your functions.php file. You may want to backup your WordPress website before you make updates to it.

Payment type in WooCommerce admin new order email

/**
 * Update WooCommerce payment type to email
 *
 * @author WPSnacks.com
 * @link https://www.wpsnacks.com
 */
function payment_type_in_admin_email( $order, $is_admin_email ) {
  if ( $is_admin_email ) {
    echo '<p><strong>Your Payment Method:</strong> ' . $order->payment_method_title . '</p>';
  }
}
add_action( 'woocommerce_email_after_order_table', 'payment_type_in_admin_email', 15, 2 );

Now if that works for you it would add the payment type to WooCommerce admin email on there.

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Email, Functions.php, Orders, Payments, WooCommerce, WordPress Admin

Primary Sidebar

Hey, We Deliver... Anywhere!

Enter Email Address below to receive our snacks via email:

Join Over 1200 Readers!

Jump To A Random WordPress Tip

Copyright © 2019 • wpsnacks.com