how you could override the Cart total, no matter how many products are in the Cart?

function bbloomer_force_cart_to_100() {     $total_disc = WC()->cart->cart_contents_total - 100;     WC()->cart->add_fee( 'force', -$total_disc ); } add_action( 'woocommerce_cart_calculate_fees','bbloomer_force_cart_to_100' );

Read More

Edit Product Loop Items Display WooCommerce

add_filter('storefront_loop_columns', 'loop_columns'); function loop_columns() { return 1; } // ------------------------- // 2. Remove default image, price, rating, add to cart remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); // ------------------------- // 3. Remove sale flash (Storefront) add_action( 'init', 'bbloomer_hide_storefront_sale_flash' ); function bbloomer_hide_storefront_sale_flash() { remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6 );…

Read More

Thumbnails per Row Product Gallery WooCommerce

add_filter( 'woocommerce_single_product_image_gallery_classes', 'bbloomer_5_columns_product_gallery' ); function bbloomer_5_columns_product_gallery( $wrapper_classes ) { $columns = 5; // change this to 2, 3, 5, etc. Default is 4. $wrapper_classes[2] = 'woocommerce-product-gallery--columns-' . absint( $columns ); return $wrapper_classes; }

Read More

Add Min, Max Single Product Page WooCommerce

add_filter( 'woocommerce_quantity_input_args', 'bloomer_woocommerce_quantity_changes', 10, 2 ); function bloomer_woocommerce_quantity_changes( $args, $product ) { $args['input_value'] = 4; // Start from this value (default = 1) $args['max_value'] = 10; // Max quantity (default = n/a) $args['min_value'] = 2; // Min quantity (default = 1) $args['step'] = 2; // Increment/decrement by this value (default = 1) return $args; }

Read More

Calculate Sales by Coupon Code

function bbloomer_get_sales_by_coupon($coupon_id) {     $args = [         'post_type' => 'shop_order',         'posts_per_page' => '-1',         'post_status' => ['wc-processing', 'wc-completed', 'wc-on-hold']     ];     $my_query = new WP_Query($args);     $orders = $my_query->posts;     $total = 0;     foreach ($orders as $key => $value) {         $order_id = $value->ID;     $order = wc_get_order($order_id);     $items = $order->get_items('coupon');     foreach ( $items as $item ) {     if( $item['code'] == $coupon_id ) {                 $total +=…

Read More

WooCommerce Deny Checkout if User Has Pending Orders

add_action('woocommerce_after_checkout_validation', 'bbloomer_deny_checkout_user_pending_orders'); function bbloomer_deny_checkout_user_pending_orders( $posted ) { global $woocommerce; $checkout_email = $posted['billing_email']; $user = get_user_by( 'email', $checkout_email ); if ( ! empty( $user ) ) { $customer_orders = get_posts( array(         'numberposts' => -1,         'meta_key'    => '_customer_user',         'meta_value'  => $user->ID,         'post_type'   => 'shop_order', // WC orders post type         'post_status' => 'wc-pending' // Only orders with status "completed" ) ); foreach (…

Read More

My Account Register Form woocommerce

add_action( 'woocommerce_register_form', 'bbloomer_extra_register_select_field' ); function bbloomer_extra_register_select_field() {        ?> <p class="form-row form-row-wide"> <label for="find_where"><?php _e( 'Where did you find us?', 'woocommerce' ); ?>  <span class="required">*</span></label> <select name="find_where" id="find_where" />     <option value="goo">Google</option>     <option value="fcb">Facebook</option>     <option value="twt">Twitter</option> </select> </p> <?php    } // ------------------- // 2. Save field on Customer Created action add_action( 'woocommerce_created_customer', 'bbloomer_save_extra_register_select_field' );   function bbloomer_save_extra_register_select_field( $customer_id ) {…

Read More

Cart Items for Product Quantity

function bbloomer_split_product_individual_cart_items( $cart_item_data, $product_id ){   $unique_cart_item_key = uniqid();   $cart_item_data['unique_key'] = $unique_cart_item_key;   return $cart_item_data; } add_filter( 'woocommerce_add_cart_item_data','bbloomer_split_product_individual_cart_items', 10, 2 ); // ------------------- // 2. Force add to cart quantity to 1 and disable +- quantity input add_filter( 'woocommerce_is_sold_individually', '__return_true' );

Read More

Confirm Email Address -WooCommerce

/** * @snippet Add "Confirm Email Address" Field @ WooCommerce Checkout * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72602 * @author Rodolfo Melogli * @testedwith WooCommerce 3.0.7 */ // --------------------------------- // 1) Make original email field half width // 2) Add new confirm email field add_filter( 'woocommerce_checkout_fields' , 'bbloomer_add_email_verification_field_checkout' );   function bbloomer_add_email_verification_field_checkout( $fields ) { $fields['billing']['billing_email']['class'] = array('form-row-first');…

Read More

Add Min, Max, Increment & Start Value @ Add to Cart Quantity | WooCommerce Single Product Page

add_filter( 'woocommerce_quantity_input_args', 'bloomer_woocommerce_quantity_changes', 10, 2 );   function bloomer_woocommerce_quantity_changes( $args, $product ) {      $args['input_value'] = 4; // Start from this value (default = 1)    $args['max_value'] = 10; // Max quantity (default = n/a)    $args['min_value'] = 2; // Min quantity (default = 1)    $args['step'] = 2; // Increment/decrement by this value (default = 1)      return $args;   }

Read More

WooCommerce: How to define Min, Max & Incremental Add to Cart Quantities

I'm doing good, pretty busy with WooCommerce clients at the moment. Most importantly though, I'm feeling great - here in Ireland a beautiful heat wave has finally raised the temperature! Speaking of WooCommerce, this week I worked on 1 snippet for you, and I'm sure you will enjoy that a lot. I wrote a brand new tutorial on how to…

Read More