Syntax for referenced variables in hook_commerce_physical_order_weight_alter? I'm trying to add a fixed weight to all cart order for shipping. I know I need to implement hook_commerce_physical_order_weight_alter() but I'm unsure of how to implement the function in a custom module. I have been testing this code in the devel php exectute window

global $user;
$order = commerce_cart_order_load($user-&gt;uid);
$weight = commerce_physical_order_weight($order, $unit = 'oz');
function commerce_physical_order_weight_alter(&amp;$weight, $order, $unit){
if ($weight['weight'] &gt;0)
{$weight = $weight + 6;}
}
dpm($weight);


Where I am confused, is passing the variable by reference. From what I understand, this should be enough to increment the weight but it returns the unadjusted weight

I can grab all of the stuff I need outside the function, but I'm unclear about passing the variable by reference and how to use that syntax for my purpose. I know that this means that the function returns a modified variable. It doesn't look like the function is called since I've tried to put the dpm in a condition inside the _alter function and it doesn't run. 

Thanks the help so far, and I appreciate the earlier answers.
If your hook_commerce_physical_order_weight_alter is not fired (remove if to double check that it's not), check if commerce_physical_order_weight() is fired as alter hook is right at the end (so add dpm() or die() at start of the function):

    function commerce_physical_order_weight($order, $unit = 'lb') {
      // ...
      // Allow other modules to alter the weight if necessary.
      drupal_alter('commerce_physical_order_weight', $weight, $order, $unit);



if it is not fired, that means the problem is somewhere else, so check if commerce_physical module is enabled and configured properly and you've the right dependency to it,
if it is fired, then check that:


your module is exactly called add_shipping_weight,
the module file included (add hook_init() or die() to check)
clear your caches (Drupal caches, memcached/redis if used, etc.), so list of hooks can be updated (it's a common mistake)