Using WooCommerce promotional discount: Buy 10 Get 1 Free answer, is exactly what I was looking for. Except I need this to work for every tenth added product. So, when someone puts in a total of 10 products from $targeted_product_ids, every tenth added product should give a free gift. For example; When someone orders 10 products = 1 free gift. When someone orders 20 products = 2 free gifts. When someone orders 30 products = 3 free gifts etc. Just can't seem to adapt the code and get it to work.
Any help?
Does the code enter the modulo part?
if ( ( $key + 1 ) % $each_n_items == 0 )
Should bring up every 10th item as true. (docs)
2.1m questions
2.1m answers
60 comments
57.0k users