Do you want to offer free gifts for high-value customers? High-value customers are those who frequently make purchases and they are the major reason to drive your sales figure. Rewarding them with special BOGO offers makes them feel valued and also they will consider your store as their preferred shopping destination. Let’s see how this customization will offer BOGO gifts only to specific customers based on their purchase history or total amount spent in your shop.
Solution: Offer BOGO(Buy One Get One) Gifts to High-Value Customers in WooCommerce
This code automatically adds a free product to the WooCommerce cart for a logged-in user if their previous history of total amount spent exceeds $10000.
add_action('woocommerce_before_calculate_totals', 'ts_add_free_product_to_cart'); function ts_add_free_product_to_cart($cart) { // Check if the user is logged in $user_id = get_current_user_id(); if ($user_id > 0) { // Get the total amount spent by the customer $total_amount_spent = wc_get_customer_total_spent($user_id); // Check if the total amount spent is greater than $10,000 if ($total_amount_spent > 10000) { // Define the free product ID $free_product_id = 470; // Replace with the actual ID of your free product // Check if the free product is not already in the cart $free_product_in_cart = false; foreach ($cart->get_cart() as $cart_item) { if ($cart_item['product_id'] == $free_product_id) { $free_product_in_cart = true; break; } } // If the free product is not in the cart, add it if (!$free_product_in_cart) { $cart->add_to_cart($free_product_id); } } } }
Output
When a customer logs in, the code refers to the previous history of the total amount spent by the customer. If the total money spent by the customer goes above a certain limit and when they add something to the cart, a free product is added automatically.
You can create such powerful BOGO promotions also based on user role of the customers and apply bogo buy one get one for registered user in WooCommerce so that you can build an engaged customer base.