Add product to cart from functions.php

I’ve figured it out

function my_custom_function() {
    global $woocommerce;
  if ( $_SERVER['REQUEST_URI'] == '/checkout/?a=b' ) {
    $woocommerce->cart->add_to_cart( 90759, 1 );
    // exit;
  }
}
add_action( 'init', 'my_custom_function', 7 );