View difference between Paste ID: UaDmzH7C and 7PKqz9Sm
SHOW: | | - or go back to the newest paste.
1
////checkbox ellenorzes
2-
add_filter( 'woocommerce_add_cart_item_data', 'bbloomer_store_gift', 10, 2 );  
2+
add_action( 'woocommerce_add_to_cart', 'bbloomer_store_gift', 10, 3 );  
3-
function bbloomer_store_gift( $cart_item, $product_id ) {
3+
function bbloomer_store_gift( $cart_item_key, $product_id, $quantity ) {
4
	  $free_product_id = 8692;
5-
	  $quantity = 1;
5+
6
      if( isset( $_POST['is-gift'] ) && $_POST['is-gift'] == "igen" && $product_id != $free_product_id ) {
7
          WC()->cart->add_to_cart( $free_product_id, $quantity );
8
      }
9
}