I need a way to disable and then enable internet access via command line while still remaining connected to wifi.
Removing your default gateway should do the trick, you'll still be able to reach everything in your subnet, but not outside of it. IIRC this should work, cannot try it atm, replace the IP with your routers IP (in the same subnet):
sudo route del default gw 192.168.1.1
Edit: To undo it, this should work:
sudo route add default gw 192.168.1.1
To find your default gateways IP:
route -n|grep "^0.0.0.0"
What you can try is rejecting all packets using firewall rule accept all packets within your network, when you want things normal just remove this firewall rule, make a script and run with cron. For more refer https://help.ubuntu.com/lts/serverguide/firewall.html, I have not tried this yet but will try it later. Let me know if you try it before me.