Jump to content

Temporary_Failure

New Members
  • Posts

    1
  • Joined

  • Last visited

Temporary_Failure's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php error_reporting(E_ALL & ~E_NOTICE); if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['someAction'])) { func(); } function func() { $sku = $_POST['sku']; $haku = file_get_contents("https://mydomain.org/wp-json/wc/v3/products/" . $sku . "?consumer_key=ck_notrealtjejyj8b0f84cf68a9afd9ba6&consumer_secret=cs_notreal68d8rku5757k5yu2094747cfb4c1e2af"); //echo strip_tags($haku); $haku = json_decode($haku, true); echo "<br><br>Tuotenumero: ".$haku['sku']."<br>"; echo "Varastosaldo: ".$haku['stock_quantity']."<br>"; echo "Hinta: ".$haku['price']."<br>"; $hinta = $haku['price']; $stock = $haku['stock_quantity']; } ?> <!DOCTYPE html> <html> <head> <title>Horror</title> <meta charset="utf-8"> </head> <form action="API.php" method="post"> <table> <tr><td><label for="sku">Tuotenumero</label></td> <td><input type="text" id="sku" name="sku" value="150000"></td></tr> <tr><td><label for="stock">Varastosaldo</label></td> <td><input type="text" id="stock" name="stock" value="<?php echo $stock; ?>"></td></tr> <tr><td><label for="price">Hinta</label></td> <td><input type="text" id="price" name="price" value="<?php echo $hinta; ?>"></td></tr> </table> <input type="submit" name="someAction" value="Lähetä" /> </form> </html> Something little missing here. I have code which gets stock_quantity and price when submitting product sku. It works fine. I get echoed right results with that code. but problem is that I need to get them to text fields after submitting. Stock and price fields just stays empty. What is the problem?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.