Woocommerce custom Plugin in wordpress [closed]

Specify the number of args you want to pass to hook function…

add_action('woocommerce_add_to_cart', array( &$this, 'add'), 10, 2);

in this case I am passing a 2…the second arg is the product_id…

Now pick up the product_id here like this…

public function add($instance, $product_id){
                GLOBAL $somevar;