Support

Account

Home Forums Add-ons Repeater Field Nested repeater fields and conditional statements Reply To: Nested repeater fields and conditional statements

  • Hi @eolis

    You need to modify it a little bit to make it like that. Something like this:

    $productURLsRow = get_field('product_urls');
    print_r($productURLsRow);
    
    foreach($productURLsRow as $productURLs){
        foreach($productURLs as $key => $productURL){
            if(!empty($productURL)){
                if($key == 'product_urls_us'){
                    $URLflag = 'us';
                } elseif ($key == 'product_urls_ca'){
                    $URLflag = 'ca';
                } elseif ($key == 'product_urls_eu'){
                    $URLflag = 'eu';
                } elseif ($key == 'product_urls_uk'){
                    $URLflag = 'uk';
                } elseif ($key == 'product_urls_au'){
                    $URLflag = 'au';
                } elseif ($key == 'product_urls_jp'){
                    $URLflag = 'jp';
                }
                
                foreach($productURL as $shopURL){
                    echo $URLflag . ' <a href="'. $shopURL["product_url"] .'">'. $shopURL["webshop_name"] .'</a>';
                }
            }
        }
    }

    Please learn more about Array and foreach function.

    I hope this helps.