You are exactly rite about how you would make use of this variable in your add to cart server behavior, just use the echo for it in the php blocks.
As for the shipping this is a two part approach to calculating shipping for the cart. In a regular cart the shipping is calculated as either a flat rate or a shipping quote value based on the entire cart contents.
In your scenario where you would like to apply shipping on a per item basis you will have the two parts. The first part will be what you are currently working on where you get the shipping for the item into the cart. You will need to have another column in your cart to hold this value. Finishing this part of it will require you to create a new calculated column for the total shipping per line item. This total shipping calculated column will multiply the quantity times the shipping value.
The second part of this is to craft your shipping charge rule. This is how you see the shipping charge in the cart on the checkout pages. Your rule will be very simple, it will use the subtotal of the total shipping calculated column.
Please post back with any questions that you have about any part of this and we will be glad to help you out with any part of it that we can.