Do not discount identical Products or Variations
Note: this requires the PW WooCommerce BOGO Pro version.
To prevent identical Products or Variations from triggering a BOGO, follow these steps.
Note: If you are more comfortable with editing your functions.php you can do that instead of Code Snippets.
1. Download the free Code Snippets plugin: https://wordpress.org/plugins/code-snippets/
2. Create a Snippet with the following code:
function pw_bogo_do_not_discount_identical_items( $cart_items ) { $cart_items_filtered = array(); $products_in_cart = array(); foreach ( $cart_items as $i ) { // // You can use 'variation_id' to only prevent identical Variations. // $id = $i['cart_item']['product_id']; if ( !in_array( $id, $products_in_cart ) ) { $cart_items_filtered[] = $i; } $products_in_cart[] = $id; } return $cart_items_filtered; } add_filter( 'pw_bogo_cart_items', 'pw_bogo_do_not_discount_identical_items' );
You can change ‘product_id’ in the code above to ‘variation_id’ to prevent identical Variations instead.