Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////checkbox ellenorzes
- add_filter( 'woocommerce_add_cart_item_data', 'bbloomer_store_gift', 10, 2 );
- function bbloomer_store_gift( $cart_item, $product_id ) {
- if( isset( $_POST['is-gift'] ) && $_POST['is-gift'] == "igen" ) {
- add_action( 'woocommerce_add_to_cart', 'aaptc_add_product_to_cart', 10, 2 );
- }
- return $cart_item;
- }
- ////maga a funkcio
- function aaptc_add_product_to_cart( $item_key, $product_id ) {
- global $woocommerce;
- $free_product_id = 8692;
- $found = false;
- $quantity = 1;
- remove_action( 'woocommerce_add_to_cart', 'aaptc_add_product_to_cart', 10, 2 );
- WC()->cart->add_to_cart( $free_product_id, $quantity );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement