Linking BOGO offers to specific payment gateways that are most popular in trend gives a chance for store owners to potentially increase conversion rates. By aligning these promotions with preferred payment methods, you not only make the checkout process smoother for customers but also gain valuable insights into their preferences. This will help you to refine your marketing strategies. Let’s see how using BOGO offers with specific payment methods can help grow your online store.
Solution: Add BOGO (Buy One Get One)Offer for the Chosen Payment Method in WooCommerce
The code dynamically adds a free product when a specific payment method is selected. You need to get the id of the payment method in WooCommerce and define that specific payment method ID as specified in the code given below.
add_action('woocommerce_cart_calculate_fees', 'ts_add_free_product_fee', 20, 1); function ts_add_free_product_fee($cart_object) { if (is_admin() && !defined('DOING_AJAX')) return; // Define your targeted payment method $targeted_payment_method = 'cheque'; // Define the free product ID $free_product_id = 470; // Replace with your actual free product ID $chosen_payment_method = WC()->session->get('chosen_payment_method'); // Check if the chosen payment method is the targeted one if ($targeted_payment_method === $chosen_payment_method) { // Check if the free product is not already in the cart if (!wc_find_product_in_cart($free_product_id)) { // Add the free product to the cart WC()->cart->add_to_cart($free_product_id, 1); } } else { // Check if the free product is in the cart $cart_item_key = wc_find_product_in_cart($free_product_id); if ($cart_item_key) { // Remove the free product from the cart WC()->cart->remove_cart_item($cart_item_key); } } } // Helper function to find a product in the cart function wc_find_product_in_cart($product_id) { foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { if ($product_id == $cart_item['product_id']) { return $cart_item_key; } } return false; } // Add jQuery to refresh payment methods on the checkout page add_action('woocommerce_review_order_before_payment', 'ts_refresh_payment_methods'); function ts_refresh_payment_methods() { ?> <script type="text/javascript"> (function ($) { $(document.body).on('change', 'input[name^="payment_method"]', function () { $('body').trigger('update_checkout'); }); })(jQuery); </script> <?php }
This to the shop owners who are running or planning to run BOGO offers on their WooCommerce store…
BOGO deals are great for increasing your sales, but have you thought about which offers are bringing you more revenue and which offers are not performing that great?
Don’t just set a BOGO deal, track the revenue generated by your deals in real-time with the Flexi BOGO for WooCommerce plugin.
Output
In this output, when the particular payment method “cheque” is selected, the free gift gets added to the checkout page.
We have seen how to enhance customer experience just by strategically applying BOGO offers based on payment methods. Similarly, you can also automatically add a product to your WooCommerce cart based on 6 different conditions covering cart total, categories, on website visit, and many more.