Home Forums Add-ons Repeater Field Print different text based on the number of lines


Print different text based on the number of lines

  • I created a ‘measures and prices’ repeater
    Sub field |height| |width| |depth| |diameter| |price|
    on the product categories front end I would like to display the price with two variables,
    if sub field |price| has multiple lines = Price starting from € |price line 1|
    if sub field | price | has only one line = Price € |price line 1|
    Could you kindly tell me the code to enter?

  • What type of field is “price”?
    What is the return format of this field?

  • i don’t know if i did it right, this is the code i managed to do and it works

      if( have_rows('misure_e_prezzi')):
        $rows = get_field('misure_e_prezzi' );
    	$my_fields = get_field_object('misure_e_prezzi');
        $specific_row = $rows[0];
        $first_row_price = $specific_row['prezzo' ];
    	$count = (count($my_fields['value']));
        $valuta = '€ ';
    <div class='prezzo'>
    if ($count ==1)
      echo $valuta .number_format( $first_row_price, 2, ',', ' ');?></div>
    if ($count >1)    
    echo 'A partire da: '?>
    <div class='prezzo'>
     if ($count >1)    
    echo  $valuta  .number_format( $first_row_price, 2, ',', ' ');?></div>
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.