Adjust the Quantity Input Values (Min/Max)

function g9_woocommerce_quantity_input_args($args, $product) { if (is_singular(‘product’)) { $args[‘input_value’] = 2; // Starting value (we only want to affect product pages, not cart) } $args[‘max_value’] = 80; // Maximum value $args[‘min_value’] = 2; // Minimum value $args[‘step’] = 2; // Quantity…Continue reading

Show Product Weight on Archive Pages

function g9_show_weights() { global $product; $weight = $product->get_weight(); if ($product->has_weight()) { echo ‘ Weight: ‘ . $weight . get_option(‘woocommerce_weight_unit’) . ‘ ‘; } } add_action(‘woocommerce_after_shop_loop_item’, ‘g9_show_weights’, 9);Continue reading

Apply a Coupon for Minimum Cart Total

function g9_add_coupon_notice() { $cart_total = WC()->cart->get_subtotal(); $minimum_amount = 50; $currency_code = get_woocommerce_currency(); wc_clear_notices(); if ($cart_total < $minimum_amount) { WC()->cart->remove_coupon(‘COUPON’); wc_print_notice(“Get 50% off if you spend more than $minimum_amount $currency_code!”, ‘notice’); } else { WC()->cart->apply_coupon(‘COUPON’); wc_print_notice(‘You just got 50% off your…Continue reading

Support for WebP Images

function g9_mime_types($mime_types) { $mime_types[‘webp’] = ‘image/webp’; //Adding webp extension return $mime_types; } add_filter(‘woocommerce_rest_allowed_image_mime_types’, ‘g9_mime_types’, 1, 1);Continue reading

Page Slug Body Class

function g9_add_slug_body_class($classes) { global $post; if (isset($post)) { $classes[] = $post->post_type . ‘-‘ . $post->post_name; } return $classes; } add_filter(‘body_class’, ‘g9_add_slug_body_class’);Continue reading

Add Only Product Description Tab on the Single Product Page

remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_product_data_tabs’, 10 ); function g9_woocommerce_template_product_description() { woocommerce_get_template( ‘single-product/tabs/description.php’ ); } add_action( ‘woocommerce_after_single_product_summary’, ‘g9_woocommerce_template_product_description’, 20 );Continue reading