Set WooCommerce cart product count total to be divisible by number

Number Of Products Woocommerce

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 More

Stop WooCommerce checkout fields auto-filling – leave blank

Woocommerce Empty Checkout

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 More

Change WooCommerce SKU text to another label

Woocommerce Sku Label.peg

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 More

Show only free shipping option on WooCommerce cart and checkout pages

Woocommerce Free Shipping Option

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 More

Hide the Description and Reviews Tabs in WooCommerce Products

hide-woocommerce-tabs

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 More

Add qty inputs next to add to cart button with and without Ajax reload on WooCommerce archives

Ajax Reload Woocommerce Qty Cart

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 More

Add 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 More

Add WooCommerce add to cart button and quantity field to Shop archive page

Add Products To Cart Archive

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 More

Stop WooCommerce taking over lost password URL

Wordpress Lost Password

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