WooCommerce discount: buy one get one 50% off

Viewed 3782

I wish to set up a specific discount on a particular variable products, if customer buys one product they get the another(same) on 50% discount(Buy one get another for 50% off). I've tried many discount plugins buy the closest that I have found are:

  • Pricing Deals for WooCommerce

  • WooCommerce All Discounts Lite

  • WooCommerce Extended Coupon Features

By using these plugins I was able to setup discount on subtotal or discount on a each product but not exactly what I am looking for(Buy 1 get 1 off). There are other pro plugins I don't want to go for it.

Is it possible to achieve without purchasing a plugin?

Thanks

Found something similar https://www.fldtrace.com/buy-3-get-1-free-coupon-woocommerce

2 Answers

to run with several items;

first make variable an array

$targeted_product_id = array(1,2,3,4) 

then we need to change if statement like below

if( $cart_item['product_id'] == $targeted_product_id ){

with

if( in_array($cart_item['product_id'],$targeted_product_id)){

thats it it work perfectly..

Related