Trying to add custom data to a plugin template that uses JS data in WordPress

I’m trying to add some custom data to a template that is causing some problems to me because is different to what I’m used to it on my project. The plugin name is Peepso, and I have customized a lot of templates and archives but there are some that are quite differente and render the data like this:

<script type="text/template" class="ps-js-member-item">
    <div class="ps-member">
        <div class="ps-member__inner">
            <div class="ps-member__header">
                <a href="{{= data.profileurl }}" class="ps-avatar ps-avatar--member">
                    <img src="{{= data.avatar }}" title="{{= data.fullname }}" alt="{{= data.fullname }} avatar">
                </a>
            </div>

            <div class="ps-member__body">
                <div class="ps-member__name">
                    <a href="{{= data.profileurl }}" class="ps-members-item-title" title="{{= data.fullname }}">
                        {{= data.fullname_with_addons }}
                    </a>
                </div>
            </div>

            <div class="ps-member__actions">
                <a class="ps-member__action ps-js-invite" data-id="{{= data.id }}" href="javascript:">
                    <span data-invited="<?php echo $force_add ? __('Added', 'groupso') : __('Invited', 'groupso'); ?>"><?php echo $force_add ? __('Add to group', 'groupso') : __('Invite to Group', 'groupso'); ?></span>
                    <img src="<?php echo PeepSo::get_asset('images/ajax-loader.gif'); ?>" alt="loading" style="display:none" />
                </a>
            </div>
        </div>
    </div>
</script>

I have found the AJAX call that handles and render the user data and the PHP function that sends the JSON data, but since this is a plugin this is not direct customizable as you already know. All I need is some way to send extra data inside the JSON in order to be able to render that specific new data since I already have my function that retrieves this data and I use it in “normal” templates with all data being handled in PHP, but this one is different since there is no “backend” data inside the archive, so for example I can’t use the User ID to retrieve any data because this is handled with the JSON and AJAX call. Thanks for your help in advance!

What is the PHP equivalent for Node Version Manager

How do you maintain code that requires an older PHP version? I have multiple PHP projects written in different versions of PHP, including old Laravel projects that I want to maintain.

I’m using Windows and XAMPP.

I just uninstall the new XAMPP version and install an older one.

Deploying a laravel app from another laravel app

Using the master laravel apl I have successfully created directory. Unzipped the project using Process into the newly created directory. Wrote .env file dynamically from the code. And created a migration file for adding base user. Created database on the server for this new projet. Username and password are same for master app and deployed app. My problem is with running artisan commands.

When I use

Process::path($deploymentPath)->run("php artisan migrate --force");

or

Process->run("php " . $deploymentPath . "/artisan migrate --force");

It fails. It says client table already exists. This is not true as the database is empty. If I migrate manually to the deployed project folder, and run the migrate command. It works without any issues.

My theory is that the artisan command is migrating my master program and not the one being deployed. Even though everything else works alright. Gow do I fix this.

And yes, I am on Ubuntu 24.04 and laravel 11, using mysql 8.

APCu being unreliable, how to fix it?

APCu is not working properly and I’m hoping to get help to understand what the problem might be, and hopefully how to fix it.

apcu_store(‘x’) stores an entry and a value just fine. But when the entry is deleted and created again with a new value it starts switching back and forth between the old and the new value. I’ve tried both apcu_add(‘x’) and apcu_store(‘x’) but they are equally unreliable.

Also there is issue with that apcu_exists(‘x’) doesn’t find the entry at all, sometimes! When I run apcu_cache_info() there is an entry stored, but apcu_exists() doesn’t always find it. Sometimes it does, but sometimes it doesn’t…

Eventually the data is lost completely from the cache even though the ttl of the entry is set to several hours (21600).

Can anyone please tell me what the issue might be and if I can fix it?

I want to store a few lines of ID’s in an array from the database, not much data to be talking about at all!

Windows 11
x64-system
PHP 8.1.23
APCu version 5.1.23 (NTS for x64, PHP 8.1) (also tried 5.1.24)
LocalWP running a WordPress site.

SUMMARY:
I tried apcu_fetch(‘x’) and expect correct value in return.
After apcu_delete(‘x’) and apcu_store(‘x’) with new value I get sometimes the new value and sometimes the old value with apcu_fetch(‘x’).

I tried to check for the entry with apcu_exists(‘x’) but this also give unreliable returns. Sometimes it finds the entry, sometimes it doesn’t.

I use apcu_cache_info() to see that there is a stored value, but eventually the cache is cleared even though not close to have ttl run out.

How do i paginate a table which has dynamically generated table rows and columns in the tbody

I have a table in php, which has rows being generated dynamically. Multiple rows in one row. This is the structure that is needed and cannot be changed. This is a sample table structure(image attached). Now, i have code written that table in a simmilar structure. But i cannot apply pagination and search functionalities of DATATABLES on this, as there are dynamic rows. What should i do?
Expected table structure with this code

                     <table class="table table-striped table-hover table-bordered" id="myTable" style="margin-bottom: 5rem; width:100%;">
                                <thead>
                                    <tr>
                                        <th rowspan="2" class="tHeader">S.No.</th>
                                        <th rowspan="2" class="tHeader">Name & Designation</th>
                                        <th colspan="5" class="tHeader">Year 2023</th>
                                        <th colspan="5" class="tHeader">Year2024</th>
                                    </tr>
                                    <tr>
                                        <th class="tHeader">Details of property  2023</th>
                                        <th class="tHeader">Present Value  2023 </th>
                                        <th class="tHeader">How acquire  2023</th>
                                        <th class="tHeader">Annual Income  2023</th>
                                        <th class="tHeader">Remarks 2023</th>
                                        <th class="tHeader">Details of property 2024</th>
                                        <th class="tHeader">Present Value 2024 </th>
                                        <th class="tHeader">How acquire  2024</th>
                                        <th class="tHeader">Annual Income  2024</th>
                                        <th class="tHeader">Remarks 2024</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if (!empty($infoData)) {
                                        $i = 1;
                                        foreach ($infoData as $row) {
                                            $prev_types = explode("<br>", $row['prop_type_prev']);
                                            $prev_addresses = explode("<br>", $row['prev_address']);
                                            $prev_values = explode("<br>", $row['value_prev']);
                                            $annual_prev = explode("<br>", $row['annual_prev']);
                                            $remarks_prev = explode("<br>", $row['remarks_prev']);
                                            $on_name_prev = explode("<br>", $row['on_name_prev']);
                                            $person_prev = explode("<br>", $row['person_prev']);
                                            $rrt_name_prev = explode("<br>", $row['rrt_name_prev']);
                                            $prop_acq_type_name_prev = explode("<br>", $row['prop_acq_type_name_prev']);
                                            $acq_date_prev = explode("<br>", $row['acq_date_prev']);
                                            $share_prev = explode("<br>", $row['share_prev']);

                                            $prop_type_name_curr = explode("<br>", $row['prop_type_name_curr']);
                                            $current_address = explode("<br>", $row['current_address']);
                                            $present_value_curr = explode("<br>", $row['present_value_curr']);
                                            $annual_income_curr = explode("<br>", $row['annual_income_curr']);
                                            $remarks_curr = explode("<br>", $row['remarks_curr']);
                                            $string_agg = explode("<br>", $row['string_agg']);
                                            $person_current = explode("<br>", $row['person_current']);
                                            $rrt_name_curr = explode("<br>", $row['rrt_name_curr']);
                                            $prop_acq_type_name_curr = explode("<br>", $row['prop_acq_type_name_curr']);
                                            $acq_date_curr = explode("<br>", $row['acq_date_curr']);
                                            $share_curr = explode("<br>", $row['share_curr']);


                                            $rowspan = max(count($prev_types), count($prev_addresses), count($prev_values));

                                            for ($j = 0; $j < $rowspan; $j++) { ?>
                                                <tr>
                                                    <?php if ($j == 0) { ?>
                                                        <td rowspan="<?= $rowspan; ?>"><?= $i++; ?></td>
                                                        <td rowspan="<?= $rowspan; ?>"><?= $row['emp_code'] . " " . $row['emp_name'] . " " . $row['desig']; ?></td>
                                                    <?php } ?>

                                                    <td><?= isset($prev_types[$j])  ? $prev_types[$j] . " " . $prev_addresses[$j]  : ''; ?></td>
                                                    <td><?= isset($prev_values[$j]) ? $prev_values[$j] : ''; ?></td>
                                                    <td><?php
                                                        if ($prop_on_name_prev[$j] == 2) {
                                                            echo isset($person_prev[$j]) ? $person_prev[$j] . " " . $rrt_name_prev[$j] . "<br>" : 'null';
                                                        } else if ($prop_on_name_prev[$j] == 1) {
                                                            echo 'self' . "<br>";
                                                        } else
                                                            echo " " . "<br>";
                                                        echo isset($prop_acq_type_name_prev[$j]) ? $prop_acq_type_name_prev[$j] . " " : '';
                                                        if (isset($acq_date_prev[$j]) && !empty($acq_date_prev[$j])) {
                                                            echo date('d-m-Y', strtotime($acq_date_prev[$j])) . " ";
                                                        } else {
                                                            echo "";
                                                        }
                                                        echo isset($share_prev[$j]) ? $share_prev[$j] : '';
                                                        ?></td>
                                                    <td><?= isset($annual_income_prev[$j]) ? $annual_income_prev[$j] : ''; ?></td>
                                                    <td><?= isset($remarks_prev[$j]) ? $remarks_prev[$j] : ''; ?></td>



                                                    <td><?= isset($prop_type_name_curr[$j])  ? $prop_type_name_curr[$j] . " " . $current_address[$j]  : ''; ?></td>
                                                    <td><?= isset($present_value_curr[$j]) ? $present_value_curr[$j] : ''; ?></td>
                                                    <td><?php
                                                        if (isset($string_agg[$j]) && $string_agg[$j] == 2) {
                                                            echo isset($person_current[$j]) ? $person_current[$j] . " " . $rrt_name_curr[$j] . "<br>" : 'null';
                                                        } else if (isset($string_agg[$j]) && $string_agg[$j] == 1) {
                                                            echo 'self' . "<br>";
                                                        } else
                                                            echo " " . "<br>";
                                                        echo isset($prop_acq_type_name_curr[$j]) ? $prop_acq_type_name_curr[$j] . " " : '';
                                                        if (isset($acq_date_curr[$j]) && !empty($acq_date_curr[$j])) {
                                                            echo date('d-m-Y', strtotime($acq_date_curr[$j])) . " ";
                                                        } else {
                                                            echo "";
                                                        }
                                                        echo isset($share_curr[$j]) ? $share_curr[$j] : '';
                                                        ?></td>
                                                    <td><?= isset($annual_income_curr[$j]) ? $annual_income_curr[$j] : ''; ?></td>
                                                    <td><?= isset($remarks_curr[$j]) ? $remarks_curr[$j] : ''; ?></td>
                                                </tr>
                                    <?php }
                                        }
                                    } ?>
                                </tbody>
                            </table>

this is the table part and i tried to initialise this using datatable, but datatables failed to paginate or append search to it.

How to Set a Default Image in Laravel Filament FileUpload?

How can I set a default banner image in the file uploader?

I’m using Laravel’s Filament FileUpload component, and I want to display a default banner image when the page loads. If the user uploads a new image, it should replace the default. However, if no image is uploaded, the default banner image should remain.

I’ve tried using the default() method and the formatStateUsing() function, but neither seems to work:

FormsComponentsFileUpload::make('banner')
    ->disk('banner')
    ->directory('banner')
    ->image()
    ->imageEditor()
    ->maxSize(3072) // 3MB limit
    ->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
    ->formatStateUsing(fn($state) => $state ?? ['banner/banner.png']) // Default banner image
    ->validationMessages([
        'banner.dimensions' => __('validationBannerDimensions'),
        'banner.max' => __('validationBannerMax'),
    ])
    ->rules([
        'dimensions:min_width=500,min_height=500,max_width=1000,max_height=1000'
    ])
    ->helperText(__('validationBannerHelperMsg')),

How can I correctly set the default image so that it appears when the form loads?

How to use ngrok with Laravel Breeze (Inertia + Vue.js) when using two different ports?

I am working on a Laravel(v9) Breeze project using Inertia.js and Vue.js. My project runs on two different ports:

Laravel backend (php artisan serve) → http://localhost:8000
Vue.js frontend (npm run dev) → http://localhost:5173

I want to use ngrok to make both backend and frontend accessible publicly. However, since the free version of ngrok only allows one session at a time, I tried defining multiple tunnels in ngrok.yml and running ngrok start –all, but I got the following error:

ERROR: Error reading configuration file 'C:UsersMyUserAppDataLocal/ngrok/ngrok.yml': YAML parsing error: yaml: line 5: did not find expected key

Here’s my ngrok.yml configuration:

version: "3"
authtoken: NGROK_AUTH_TOKEN

tunnels:
  backend:
    proto: http
    addr: 8000
  frontend:
    proto: http
    addr: 5173

Any guidance would be greatly appreciated. Thanks!

How do I make a role based system to allow or deny files in an XAMPP server

I have tried using readfile() in php, after redirecting through .htaccess. but php doesn’t run the file. For example when I use something like hello_world.php with the content of

<?php
    echo "hello World!";
?>

then access it after being granted access (meaning that the php has used readfile())
it will open as if its a text document, showing me the code and not running it.
This doesn’t work with me as i want everything to run like normal, in the matter of running the file normally through Apache, and if it stops other file types from acting like this too, then its not an option i would like to go with.

i Also don’t want to download any file, i simply want to either be served the file (to be displayed on the web) or to be denied.

How to throw an exception if a certain class object is serialized via json_encode?

Due to a refactoring I have the use case to throw a LogicException if, and only if, a certain class instance is serialized via json_encode. (Currently, a lot of serialization happens silently under the hood, generating broken/empty data structures, yet the code runs fine as no error is thrown. I prefer Exceptions to really catch all the places.)

E.g.:

class ValueObject
{
    public function __construct(public string $someProperty)
    {
    }
}
$an_object = new ValueObject('example');
$result = json_encode($an_object, JSON_PRETTY_PRINT); // this should throw as an instance of ValueObject is passed
echo $result;

This should also work if the instances appear nested, e.g. in an array but also as part of other object’s properties:

$nested_array = [
    [
        'foo',
        new ValueObject('foo'),
        new ValueObject('GNARF'),
    ],
    'gnarf' => new ValueObject('poit'),
];
$nested_result = json_encode($nested_array, JSON_PRETTY_PRINT); // should fail too
echo $nested_result;

React App Not Serving Static Files Correctly – MIME Type Issues

Problem:
My React app is not serving static files correctly. Requests for JavaScript and CSS files return a text/html content type instead of the expected application/javascript or text/css.

Details:

Server Details:

  • Hosting Package: Silver 100
  • Server Name: s938
  • cPanel Version: 124.0 (build 26)
  • Apache Version: 2.4.62
  • Database Version: 10.6.21-MariaDB
  • Operating System: Linux
  • IP Address:

Observations:

  1. Requests for static files (e.g., main.9b9eb604.js and main.724539ac.css) return text/html content type.
  2. Static files seem to be redirected to index.php and serve index.html.
  3. .htaccess rules appear to be causing issues with serving static files correctly.

Steps Taken:

  1. Updated .htaccess to include MIME type settings:
    <IfModule mod_mime.c>
        AddType application/javascript .js
        AddType text/css .css
        AddType application/json .json
    </IfModule>
    
  2. Ensured build directory permissions:
    chmod -R 777 /home/wwwplumb/emergencyplumbersmanchester.com/build
    
  3. Verified build output and file locations.
  4. Attempted to access static files directly, but received text/html response.

index.php:

<?php
$react_build_path = __DIR__ . '/build';
$request_uri = $_SERVER['REQUEST_URI'];
$clean_uri = parse_url($request_uri, PHP_URL_PATH);
$file_path = realpath($react_build_path . $clean_uri);

if ($file_path && strpos($file_path, realpath($react_build_path)) === 0 && is_file($file_path)) {
    $mime_type = mime_content_type($file_path);
    header('Content-Type: ' . $mime_type);
    header('Content-Length: ' . filesize($file_path));
    readfile($file_path);
    exit;
} else {
    $index_html_path = $react_build_path . '/index.html';
    if (file_exists($index_html_path)) {
        $content = file_get_contents($index_html_path);
        echo $content;
    } else {
        echo 'React app not found. Please ensure the build directory exists and contains an index.html file.';
    }
}
?>

.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L]
</IfModule>

<IfModule mod_mime.c>
    AddType application/javascript .js
    AddType text/css .css
    AddType application/json .json
</IfModule>

Alias /static /home/wwwplumb/emergencyplumbersmanchester.com/build/static

<Directory "/home/wwwplumb/emergencyplumbersmanchester.com/build/static">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

How to determine .eps vector file version with php?

I want to know how to programmatically read version of EPS file with php (or sample with other language). I know it is text format, but I can’t found version values in the files.

There are many version supports by Adobe Illustartion.

enter image description here

But I need to detect version at least for 8 and 10 beacuse they most widely used.

SymfonyInsight Analysis – Application not bootable

When I tried to analyze the project source code in Symfony Insight, I am getting an error as follows

SymfonyComponentConfigExceptionFileLocatorFileNotFoundException: The file "../config" does not exist (in: "phar:///opt/phar/insight.phar/src/Insight/Sniffer"). in /app/vendor/symfony/config/FileLocator.php:71
Stack trace:
#0 /app/vendor/symfony/http-kernel/Config/FileLocator.php(44): SymfonyComponentConfigFileLocator->locate('../config', 'phar:///opt/pha...', true)
#1 /app/vendor/symfony/config/Loader/FileLoader.php(118): SymfonyComponentHttpKernelConfigFileLocator->locate('../config', 'phar:///opt/pha...', true)
#2 /app/vendor/symfony/config/Loader/FileLoader.php(86): SymfonyComponentConfigLoaderFileLoader->glob('/{packages}/*.y...', false, NULL, false, false, Array)
#3 /app/vendor/symfony/dependency-injection/Loader/FileLoader.php(66): SymfonyComponentConfigLoaderFileLoader->import('../config/{pack...', NULL, false, 'phar:///opt/pha...')
#4 /app/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php(64): SymfonyComponentDependencyInjectionLoaderFileLoader->import('../config/{pack...', NULL, false, 'phar:///opt/pha...')
#5 /app/src/Kernel.php(18): SymfonyComponentDependencyInjectionLoaderConfiguratorContainerConfigurator->import('../config/{pack...')
#6 /app/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php(188): AppKernel->configureContainer(Object(SymfonyComponentDependencyInjectionLoaderConfiguratorContainerConfigurator), Object(SymfonyComponentConfigLoaderDelegatingLoader), Object(ExtendedContainerBuilder))
#7 /app/vendor/symfony/dependency-injection/Loader/ClosureLoader.php(39): AppKernel->SymfonyBundleFrameworkBundleKernel{closure}(Object(ExtendedContainerBuilder), 'prod')
#8 /app/vendor/symfony/config/Loader/DelegatingLoader.php(40): SymfonyComponentDependencyInjectionLoaderClosureLoader->load(Object(Closure), NULL)
#9 /app/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php(196): SymfonyComponentConfigLoaderDelegatingLoader->load(Object(Closure))
#10 /app/vendor/symfony/http-kernel/Kernel.php(649): AppKernel->registerContainerConfiguration(Object(SymfonyComponentConfigLoaderDelegatingLoader))
#11 /app/vendor/symfony/http-kernel/Kernel.php(545): SymfonyComponentHttpKernelKernel->buildContainer()
#12 /app/vendor/symfony/http-kernel/Kernel.php(789): SymfonyComponentHttpKernelKernel->initializeContainer()
#13 /app/vendor/symfony/http-kernel/Kernel.php(128): SymfonyComponentHttpKernelKernel->preBoot()
#14 /app/InsightKernel.php(15) : eval()'d code(8): SymfonyComponentHttpKernelKernel->boot()
#15 /app/InsightKernel.php(15): eval()
#16 {main}

The application boots normally in local environment. I am using ddev as local development environment. I tried a lot of solutions by searching relevant sites, noting worked so far. Any help is appreciated.

Adding more context
enter image description here

Application boot normal composer install. No dependency on database and there are no errors. It fails only when SymfonyInsight try to boot the application

How to get data values from collection using group by on laravel

I want to remove [ ] before data collect

This is the data output

"data": [
        [
            {
                "id": 2,
                "runtime_batch": 24528,
                "smallstoptime_batch": 250,
                "downtime_batch": 200,
            },
            {
                "id": 2,
                "runtime_batch": 2074,
                "smallstoptime_batch": 0,
                "downtime_batch": 1,
            }
        ],
        [
            {
                "id": 3,
                "runtime_batch": 185,
                "smallstoptime_batch": 252,
                "downtime_batch": 1409,
            },
            {
                "id": 3,
                "runtime_batch": 2127,
                "smallstoptime_batch": 377,
                "downtime_batch": 22452,
            }
        ]
    ]

and this is the script using collection

$linedata = GetMyData::select('id', 'runtime_batch', 'smallstoptime_batch', 'downtime_batch', 'output', 'output_final')->get();

foreach($linedata as $ld) {

$ld->runtime_batch = round(($ld->runtime_batch+$ld->smallstoptime_batch)/($ld->runtime_batch+$ld->smallstoptime_batch+$ld->downtime_batch)*100, 2);
$ld->downtime_batch = round($ld->output/$ld->output_final*100, 2);
$ld->smallstoptime_batch = round($ld->output_final/($ld->runtime_batch+$ld->smallstoptime_batch)*100, 2);
}

$groupingline = collect($linedata)->groupBy('id')->values()->all();

I want to group by after, because the data its not result after get and i want to calculate on foreach, after it i want grouping by id. But the result its not i wanted.

get();

Or do you have a another script? its very help me..
Thanks for your help, because i stuck in this script 🙁

Retrieving order meta data not working WooCommerce [duplicate]

I have a website under WordPress 6.7.1 with WooCommerce 9.6.1. I use the following code to add and save some custom checkout fields:

/**
 * 1️⃣ Add custom fields to WooCommerce checkout
 */
add_filter('woocommerce_checkout_fields', function ($fields) {

    $fields['billing']['player_id'] = [
        'type'     => 'text',
        'label'    => 'DNI Jugador',
        'required' => true,
        'class'    => ['form-row-wide'],
        'priority' => 20,
    ];

    $fields['billing']['dad_name'] = [
        'type'     => 'text',
        'label'    => 'Nombre Padre/Madre/Tutor',
        'required' => true,
        'class'    => ['form-row-wide'],
        'priority' => 25,
    ];

    $fields['billing']['dad_id'] = [
        'type'     => 'text',
        'label'    => 'DNI Padre/Madre/Tutor',
        'required' => true,
        'class'    => ['form-row-wide'],
        'priority' => 30,
    ];

    $fields['billing']['player_birthdate'] = [
        'type'     => 'date',
        'label'    => 'Fecha de Nacimiento',
        'required' => true,
        'class'    => ['form-row-wide'],
        'priority' => 40,
    ];

    $fields['billing']['player_team'] = [
        'type'     => 'text',
        'label'    => 'Equipo en el que juegas',
        'required' => false,
        'class'    => ['form-row-wide'],
        'priority' => 50,
    ];

    $fields['billing']['player_adult'] = [
        'type'     => 'select',
        'label'    => '¿Eres mayor de edad?',
        'required' => true,
        'options'  => [
            ''   => 'Selecciona una opción',
            'yes' => 'Sí',
            'no'  => 'No',
        ],
        'class'    => ['form-row-wide'],
        'priority' => 60,
    ];

    $fields['billing']['pictures_consent'] = [
        'type'     => 'select',
        'label'    => 'Con la inclusión de las nuevas tecnologías dentro del mundo del deporte y ante la posibilidad de que en estas puedan aparecer imágenes de vuestros hijos/as durante la realización de las actividades deportivas. Y dado que el derecho a la propia imagen está reconocido al articulo 18 de la Constitución y regulado por la Ley 1/1982, de 5 de mayo, sobre el derecho al honor, a la intimidad personal y familiar y a la propia imagen y la Ley 15/1999, de 13 de diciembre, sobre la Protección de Datos de Carácter Personal. Timeout Workouts pide el consentimiento a los padres o tutores legales para poder publicar las imágenes en las cuales aparezcan individualmente o en grupo, que con carácter informativo se puedan realizar a los jugadores/as participantes en nuestras actividades.',
        'required' => true,
        'options'  => [
            ''   => 'Selecciona una opción',
            'yes' => 'Sí',
            'no'  => 'No',
        ],
        'class'    => ['form-row-wide'],
        'priority' => 70,
    ];

    $fields['billing']['player_allergies'] = [
        'type'     => 'textarea',
        'label'    => 'Alergias o enfermedades',
        'required' => false,
        'class'    => ['form-row-wide'],
        'priority' => 80,
    ];

    $fields['billing']['player_medicine'] = [
        'type'     => 'textarea',
        'label'    => 'Medicamentos',
        'required' => false,
        'class'    => ['form-row-wide'],
        'priority' => 90,
    ];

    $fields['billing']['player_video'] = [
        'type'     => 'text',
        'label'    => '¡Queremos conocerte! Te podemos ver jugar con un Link a un vídeo',
        'required' => true,
        'class'    => ['form-row-wide'],
        'priority' => 100,
    ];

    $fields['billing']['player_shirt'] = [
        'type'     => 'select',
        'label'    => 'Talla de camiseta',
        'required' => true,
        'options'  => [
            ''    => 'Selecciona una opción',
            's'   => 'S',
            'm'   => 'M',
            'l'   => 'L',
            'xl'  => 'XL',
            'xxl' => 'XXL',
        ],
        'class'    => ['form-row-wide'],
        'priority' => 110,
    ];

    $fields['billing']['how_meet_us'] = [
        'type'     => 'select',
        'label'    => '¿Cómo nos has conocido?',
        'required' => true,
        'options'  => [
            ''        => 'Selecciona una opción',
            'social'  => 'Redes sociales',
            'friends' => 'Amigos',
            'other'   => 'Otros',
        ],
        'class'    => ['form-row-wide'],
        'priority' => 120,
    ];
    
    $fields['billing']['payment_times'] = [
        'type'     => 'select',
        'label'    => '¿En cuántas cuotas deseas pagar?',
        'required' => true,
        'options'  => [
            ''        => 'Selecciona una opción',
            '1'  => 'Pago unico',
            '2' => '2 Pagos fraccionados',
        ],
        'class'    => ['form-row-wide'],
        'priority' => 130,
    ];

    return $fields;
});

/**
 * 2️⃣ Save custom checkout fields to order meta
 */
add_action('woocommerce_checkout_update_order_meta', function ($order_id) {
    $order = wc_get_order($order_id); // Obtener el objeto de la orden

    $fields = [
        'player_id', 
        'dad_id',
        'dad_name',
        'player_birthdate',
        'player_team',
        'player_adult',
        'pictures_consent',
        'player_allergies',
        'player_medicine',
        'player_video',
        'player_shirt',
        'how_meet_us',
        'payment_times',
    ];

    foreach ($fields as $field) {
        if ( isset( $_POST[ $field ] ) && ! empty( $_POST[ $field ] ) ) {
            $order->update_meta_data( $field, sanitize_text_field( $_POST[ $field ] ) );
        }
    }
    $order->save(); // Guardar la orden
});

It works fine, and I am able to see that all related custom metadata in the order details page, in the custom fields section (see the screenshot below):

Admin order page

The data is being stored correctly and I can see it there.

The problem is when I try to show it on my all orders page. I want a new column for each of these custom fields. For that, I had this code

/**
 * 3️⃣ Display custom fields in WooCommerce order details page
 */
add_action('woocommerce_admin_order_data_after_billing_address', function ($order) {
    echo '<h3>Información del Jugador</h3>';
    
    $fields = [
        'player_id'        => 'DNI Jugador',
        'dad_id'           => 'DNI Padre/Madre/Tutor',
        'dad_name'         => 'Nombre del Padre/Madre/Tutor',
        'player_birthdate' => 'Fecha de Nacimiento',
        'player_team'      => 'Equipo',
        'player_adult'     => 'Mayor de Edad',
        'pictures_consent' => 'Consentimiento Fotos',
        'player_allergies' => 'Alergias o enfermedades',
        'player_medicine'  => 'Medicamentos',
        'player_video'     => 'Vídeo jugando',
        'player_shirt'     => 'Talla camiseta',
        'how_meet_us'      => '¿Cómo nos has conocido?',
        'payment_times'    => 'Número de cuotas para el pago',
    ];
        
    
    foreach ($fields as $key => $label) {
        $value = $order->get_meta($field);
        if (!empty($value)) {
            echo "<p><strong>$label:</strong> " . esc_html($value) . "</p>";
        }
    }
});

/**
 * 4️⃣ Add custom columns to WooCommerce orders table (HPOS compatible)
 */
add_filter('woocommerce_shop_order_list_table_columns', function ($columns) {
    // Define los nuevos campos
    $fields = [
        'player_id'        => 'DNI Jugador',
        'dad_id'           => 'DNI Padre/Madre/Tutor',
        'dad_name'         => 'Nombre del Padre/Madre/Tutor',
        'player_birthdate' => 'Fecha de Nacimiento',
        'player_team'      => 'Equipo',
        'player_adult'     => 'Mayor de Edad',
        'pictures_consent' => 'Consentimiento Fotos',
        'player_allergies' => 'Alergias o enfermedades',
        'player_medicine'  => 'Medicamentos',
        'player_video'     => 'Vídeo jugando',
        'player_shirt'     => 'Talla camiseta',
        'how_meet_us'      => '¿Cómo nos has conocido?',
        'payment_times'    => 'Número de cuotas para el pago',
    ];

    // Insertar las nuevas columnas después de la columna 'order_total'
    $new_columns = [];
    foreach ($columns as $key => $value) {
        $new_columns[$key] = $value;
        if ('order_total' === $key) {
            foreach ($fields as $field_key => $field_label) {
                $new_columns[$field_key] = $field_label;
            }
        }
    }
    return $new_columns;
}, 20);

add_action('woocommerce_shop_order_list_table_custom_column', function ($column, $order) {
    // Definir los campos a mostrar
    $fields = [
        'player_id'        => 'DNI Jugador',
        'dad_id'           => 'DNI Padre/Madre/Tutor',
        'dad_name'         => 'Nombre del Padre/Madre/Tutor',
        'player_birthdate' => 'Fecha de Nacimiento',
        'player_team'      => 'Equipo',
        'player_adult'     => 'Mayor de Edad',
        'pictures_consent' => 'Consentimiento Fotos',
        'player_allergies' => 'Alergias o enfermedades',
        'player_medicine'  => 'Medicamentos',
        'player_video'     => 'Vídeo jugando',
        'player_shirt'     => 'Talla camiseta',
        'how_meet_us'      => '¿Cómo nos has conocido?',
        'payment_times'    => 'Número de cuotas para el pago',
    ];

    // Mostrar los valores de los campos personalizados
    if (isset($fields[$column])) {
        $value = $order->get_meta($field);
        echo !empty($value) ? esc_html($value) : '—';
    }
}, 10, 2);

Which at some point worked, but now I don’t know why it shows a “-” in every field. The columns are being added correctly to the table, but the are all empty. I’ve tried a lot of things with no success. Need to clarify that I’m new with php and Woocommerce and this code is mostly AI-generated. Also, a couple of days ago, Woocommerce was updated, but I have only found that the changes are the logo and colors, so it shouldn’t have affected my site, but who knows. I think that before the update (or at least when it worked) these custom fields did not appear where they do now in the order’s detail page. Don’t know if that’s relevant.