I have an order with 3 different line items.
I need to refund 1 of those items (which is heavy and adds to the shipping price). Without this item I can reduce the price of the shipping by X.
How can I refund X? How can I automatically calculate how much I have to refund from the shipping?
The example here doesn't go too much in depth
Shopify doesn't have any concept of how much each line item contributes to a certain shipping rate's price, because there's really no way for us to know for sure. We just take the total weight or total price of an order and surface any applicable shipping rates that have been configured. Because of that, there's no way to automatically do this - you'd just have to specify a shipping refund amount manually.