0

I have a view with a regular commerce price and a discounted one. When using the Raw amounts everything works fine but when I use the formatted ones the hide if empty, Count the number 0 as empty and Hide rewrite if empty even though they are checked the amount of 0,00€ is shown!

What can I do to hide it?

2
  • 1
    Are you using this module to display the discounted price? drupal.org/project/commerce_extra_price_formatters
    – chrisjlee
    Commented Feb 7, 2012 at 13:58
  • Thanks a lot for posting this question, I'm having the same issue right now. Would you possibly know if this would correspond to any issue/ticket already tracked in the Commerce project? Thanks in advance.
    – DYdave
    Commented Jul 24, 2013 at 7:34

2 Answers 2

2

This should be fixed in Drupal commerce, but until it gets fixed you could add a custom template file to your theme. Copy /sites/all/modules/views/theme/views-view-fields.tpl.php to /sites/all/themes/[YOUR_THEME]/templates/views-view-fields--[YOUR_PRODUCT_TYPE].tpl.php and edit it. Add something like: <?php if($id == 'commerce_price' && empty($row->commerce_price)) continue; ?> to your template file.

<?php foreach ($fields as $id => $field): ?>
  <?php if($id == 'commerce_price' && empty($row->commerce_price)) continue; ?>
  <?php if (!empty($field->separator)): ?>

...

0
function MODULENAME_field_attach_view_alter(&$output, $context) {
 /*Remove price if null or has value 0.00*/
    if($context['display']['module'] == 'commerce_price'){
     $field_name = array_keys($output);
       if(!empty($field_name[0])){
            $field_name = $field_name[0];
            if(empty($output[$field_name]['#items'][0]['amount']))
                $output = array();
        }


    }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.