Set WooCommerce cart product count total to be divisible by number
You can set WooCommerce cart total product count to be divisible by a certain number, if it is not divisible by that number then do not allow the user to checkout. add_action( ‘woocommerce_check_cart_items’, ‘check_cart_items_conditionally’ ); /** * Check cart items conditionally displaying an error notice and avoiding checkout * @link https://stackoverflow.com/questions/65767078/disable-woocommerce-checkout-if-cart-items-count-is-not-a-multiple-of-n */ function check_cart_items_conditionally() {…
Read MoreStop WooCommerce checkout fields auto-filling – leave blank
You can stop WooCommerce checkout fields from auto filling by using a Woo filter woocommerce_checkout_get_value, this could be useful in a situation when a logged in user is ordering on behalf of multiple customers. add_filter( ‘woocommerce_checkout_get_value’,’prefix_return_empty_checkout’, 1, 1 ); function prefix_return_empty_checkout(){ $user = wp_get_current_user(); //The user has the “shop_manager” role if ( in_array( ‘shop_manager’, (array)…
Read MoreChange WooCommerce SKU text to another label
You can change WooCommerce SKU text to another label using the gettext filter add_filter(‘gettext’, ‘translate_woocommerce’, 10, 3); /** * Change SKU Label * @link https://gist.github.com/dannyconnolly/da6f1a2d95dc826ccdcd * @since 1.0.0 */ function translate_woocommerce($translation, $text, $domain) { if ($domain == ‘woocommerce’) { switch ($text) { case ‘SKU’: $translation = ‘Catalogue No:’; break; case ‘SKU:’: $translation = ‘Catalogue No:’;…
Read MoreShow only free shipping option on WooCommerce cart and checkout pages
By default WooCommerce will show all available shipping options on cart and checkout pages, if you have free shipping as an option you may just want that displayed by itself. The code snippet below which needs to be added to your functions.php theme file will do just that… add_filter( ‘woocommerce_package_rates’, ‘prefix_hide_shipping_when_free_is_available’, 100 ); /** *…
Read MoreFilter WooCommerce orders by payment gateway
Here is how you can filter WooCommerce orders by payment gateway in the WordPress dashboard orders screen using a plugin from SkyVerge. Add the php file directly or in a folder in the /wp-content/plugins/ directory and then activate the plugin from the WordPress dashboard. Now you will see a column that allows you to choose…
Read MoreHide the Description and Reviews Tabs in WooCommerce Products
WooCommerce products by default show ‘description‘ and ‘reviews‘ tabs below the product on a WordPress product page, you can hide these tabs from view as well as a third tab ‘additional information‘ with a snippet of code that goes in your themes functions.php file As well as remove the tabs you can rename the heading…
Read MoreAdd qty inputs next to add to cart button with and without Ajax reload on WooCommerce archives
Here is how you can add qty inputs next to add to cart with Ajax reload on WooCommerce archives. Without Ajax Reload add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘quantity_inputs_for_woocommerce_loop_add_to_cart_link’, 10, 2 ); /** * Override loop template and show quantities next to add to cart buttons * @link https://gist.github.com/mikejolley/2793710 */ function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) { if ( is_user_logged_in()…
Read MoreAdd a ‘Continue Shopping’ Button to Woo Commerce Checkout and Cart Page
By default WooCommerce Cart page does not have a ‘Continue Shopping’ or ‘Return to Store’ button. However if you go to the cart page when the cart is empty, there is a ‘Return to Store’ button. We just need to add this button code to the cart page when the cart has items. This can be…
Read MoreAdd WooCommerce add to cart button and quantity field to Shop archive page
Here is how you can add WooCommerce add to cart button and quantity field/form to Shop archive page. You may have just a bunch of linked products on the shop page but want to add a quicker way for a customer to add products to cart. Depending on your WordPress theme the add to…
Read MoreStop WooCommerce taking over lost password URL
When you have WooCommerce installed, it hijacks the lost password URL with /my-account/lost-password/ you can revert to the original WordPress lost password URL by removing a filter to your themes functions.php file /** * Remove WooCommerce /my-account/lost-password so default WordPress one can be used */ remove_filter( ‘lostpassword_url’, ‘wc_lostpassword_url’, 10 ); Now the default lost password…
Read More