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