This code can be used to add weight-based shipping options to the checkout process. The various shipping options are first defined in settings as a flat rate in the usual way. You will then need to find the ID for each method that you want to manage. Right-click on the method heading and choose inspect element. You should see something like:
This tells you the ID for that method is 4. Do this for every method you need to manage. You can then write php conditions to unset various methods based on the total weight in the cart. In the example below we are only offering methods 4 and 5 for weights below 2kg.