How to get the number of items in a user's cart from commerce?
you will have to use hook_preprocess_hook to achieve this by passing the variable to the template. 

function template_preprocess_TEMPLATE_NAME(&amp;$variables) {
    $variables['YOUR_VAR_NAME'] = $YOUR_VAR;
}


Then you can access your var in the template like so:

{{ YOUR_VAR_NAME }}