Advertisement
swte

Untitled

May 24th, 2019
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  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" ) {
  5.             add_action( 'woocommerce_add_to_cart', 'aaptc_add_product_to_cart', 10, 2 );
  6.       }
  7. return $cart_item;
  8. }
  9.  
  10. ////maga a funkcio
  11. function aaptc_add_product_to_cart( $item_key, $product_id ) {
  12.       global $woocommerce;
  13.       $free_product_id = 8692;
  14.       $found = false;
  15.       $quantity = 1;
  16.  
  17.       remove_action( 'woocommerce_add_to_cart', 'aaptc_add_product_to_cart', 10, 2 );
  18.       WC()->cart->add_to_cart( $free_product_id, $quantity );
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement