Please replace the line in the patch
if($order->uc_gift_certificate_added...