Enable ACF Theme Options Page

if (function_exists(‘acf_add_options_page’)) { acf_add_options_page(array( ‘page_title’ => ‘Theme General Settings’, ‘menu_title’ => ‘Theme Settings’, ‘menu_slug’ => ‘theme-general-settings’, ‘capability’ => ‘edit_posts’, ‘redirect’ => false )); }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

Add New Product Badge

function g9_new_product_badge_shop_page() { global $product; $newness_days = 120; $created = strtotime($product->get_date_created()); if ((time() – (60 * 60 * 24 * $newness_days)) < $created) { echo '‘ . esc_html__(‘New!’, ‘woocommerce’) . ‘‘; } } add_action(‘woocommerce_before_shop_loop_item_title’, ‘g9_new_product_badge_shop_page’, 3);Continue reading

Display Related Products on 3 Columns

function g9_change_number_related_products($args) { $args[‘posts_per_page’] = 3; $args[‘columns’] = 3; return $args; } add_filter(‘woocommerce_output_related_products_args’, ‘g9_change_number_related_products’, 9999);Continue reading