Support

Account

Home Forums Add-ons Repeater Field Woocommerce Order: get_sub_field array Reply To: Woocommerce Order: get_sub_field array

  • So the final solution for my project was a function looking like this

    function trackingNo($postID) {
        
        $field_rep = 'trackingNo';
        $field_sub = 'no';
        
        if (have_rows($field_rep, $postID)) {
            
                $trackingNo = array();
                    
            
            // loop through the rows of data
            while (have_rows($field_rep, $postID)):
                the_row();
                
                // Add to array
                $trackingNo[] = get_sub_field($field_sub);
             
            endwhile;
    
            
            $foo = implode('&consignmentId=', $trackingNo);
            $bar = 'http://url.com/tracktrace/TrackConsignments_do.jsp?&consignmentId=';
    
            $value = $bar . $foo;
    
            return $value;
     }
    }

    If there is any room for improvement in the function please let me know. am pretty weak in PHP.