php – Link of a JSON parameter to a product in Woocommerce


I have a JSON that returns a list with some flight data:

  "programa": "multiplus",
  "qtdOpcoesIda": 50,
  "qtdOpcoesVolta": 50,
  "menorTarifa": {
    "pontos": 15000,
    "dinheiro": 767.8
  "taxaEmbarque": {
    "POA": 29.9,
    "FLN": 29.9
  "passagens": [
      "pontos": 23000,
      "dinheiro": 738.9,
      "opcoesIda": [

I'm printing this data in a table with "SELECT FLIGHT" buttons (still unreferenced because I'm stuck on that) for each flight separately. How would I make these buttons use the individual "program" and "points" parameters of each flight to search for products on woocommerce that had a certain program as a category, and the minimum points of the result?

I'll be happy if you can help…


If I understand correctly, you need to access the properties of this JSON, right? Use json_decode() to transform into an object:

$json = '{ "programa": "multiplus", ... }';
$objeto = json_decode( $json );

echo $objeto->programa; // 'multiplus'
echo $objeto->menorTarifa->pontos; // '15000'
echo $objeto->passagens[0]->pontos; // '23000'
Scroll to Top