Where is the bash shell in macos Monterey and Big Sur?
The bash shell in macos Monterey, Big Sur and Catalina has been demoted to the subs bench with the newer zsh shell is now the default shell in use by the new operating system. Also known as the Z shell, it has been around a while, since 1990 (bash was 1988), it is still a…
Read MoreAdd a CSS class to WooCommerce Shop Page
Using the filter body_class with the is_shop conditional you can target the main WooCommerce shop page by adding a CSS class. add_filter( ‘body_class’, ‘woo_shop_class’ ); // Add WooCommerce Shop Page CSS Class function woo_shop_class( $classes ) { if ( is_shop() ) // Set conditional $classes[] = ‘woo-shop’; // Add Class return $classes; } The above…
Read MoreRemoving the Product Meta ‘Categories’ on a Product Page – WooCommerce
WooCommerce product categories are displayed at the bottom of a product page just under the add to cart button. You can remove these from the layout by removing the woocommerce_template_single_meta action from the product summary, in your themes functions.php add in … remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_meta’, 40 ); This will remove the categories aka product meta from…
Read MoreUpgrade/Downgrade website versions of WordPress with wp-cli
You can use wp-cli to upgrade or downgrade to particular versions or releases of WordPress. See the installed version of current WordPress wp core version or with more info: wp core version –extra Update to latest version of WordPress wp core update Update to specific version of WordPress wp core update –version=5.5.3 Install or downgrade…
Read MoreSort WooCommerce products in cart order by price
By default the WooCommerce cart is ordered by when products are ordered in sequence, this can be manipulated with the woocommerce_cart_loaded_from_session hook. A new array is created $products_in_cart and the carts content is looped with the key of the array being the price $product->get_price(), the array is then sorted with asort or arsort before being…
Read MoreSort WooCommerce products from product category to be last in cart order
From a selected WooCommerce product category sort products to be at the end of a carts order. add_action( ‘woocommerce_cart_loaded_from_session’, ‘product_category_cart_items_sorted_end’ ); /** * WooCommerce – sort some Prod Cat items to be last order in cart * @link https://stackoverflow.com/questions/65800801/sort-specific-product-category-cart-items-at-the-end-in-woocommerce */ function product_category_cart_items_sorted_end() { $category_terms = __(‘box’); // Here set your category terms (can be names,…
Read MoreWooCommerce cart total count minus certain product category
I have a client that sells boxes and units of a product – for the units they need to be sold in multiples of 6, for the boxes it doesn’t matter, so I need the cart total to be less the boxes total and checked to see if it is divisible by 6 – if…
Read MoreSet 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 MoreAdd a menu to WordPress page with PHP action hooks
Adding a menu to WordPress via PHP and action hooks requires three steps, registering the menu location, assigning a menu to it and then placing the menu with an action hook. Register WordPress Menu Registering a menu is done with register_nav_menu, below is an example to register a ‘Store Menu’ menu. add_action( ‘init’, ‘wpb_custom_new_menu’ );…
Read More