Show SKU in Cart

function g9_sku_cart_page($item_name, $cart_item, $cart_item_key) { // The WC_Product object $product = $cart_item[‘data’]; // Get the SKU $sku = $product->get_sku(); // When sku doesn’t exist if (empty($sku)) return $item_name; // Add the sku $item_name .= ‘‘ . __(“SKU: “, “woocommerce”) .…Continue reading

Hide Shipping Rates When Free Shipping is Available

function g9_hide_shipping_when_free_is_available($rates) { $free = array(); foreach ($rates as $rate_id => $rate) { if (‘free_shipping:1’ === $rate->id) { $free[$rate_id] = $rate; break; } } return !empty($free) ? $free : $rates; } add_filter(‘woocommerce_package_rates’, ‘g9_hide_shipping_when_free_is_available’, 100);Continue reading

Add Icon to the Left Side of the Order Number (Admin Order Page)

function g9_user_role_order_icon($column_name, $post_id) { if ($column_name == ‘order_number’) { $order = wc_get_order($post_id); // Get user id from order $user_id = $order->get_user_id(); if ($user_id > 0) { $user_meta = get_userdata($user_id); $user_roles = $user_meta->roles; // Check if user role my-custom-user-role is in…Continue reading