Jump to content
  • 0

Woocommerce & Filemaker - 2023


StevenDn

Question

Posted (edited)

Korte inleiding :

Ik maak al een tijdje webshops in Wordpress met WooCommerce. En ik kan afzonderlijk wel ( licht ) overweg met filemaker. Nu heb ik een kassasysteem gemaakt in filemaker die werkt, maar ik zou deze graag willen linken met mijn verschillende webshops om de klant nog beter te bedienen.

Nu sinds sinds de opkomst. van "chatgpt" probeer ik de scripts te maken en te vervolledigen. Maar ik zit vast met WooCommerce api die de 2 systemen met elkaar verbind. Ik krijg maar een blanco pagina, terwijl ik niet weer wat er mis is. Alvast bedankt voor de eventuele reacties 

 

Code hier :

 

<?php
// Your WooCommerce store URL
$store_url = "https://beautiqa.be/shop/";

// Your API consumer key and secret key
$consumer_key = "ck_blablacodehier";
$consumer_secret = "cs_blablacodehier";

// The WooCommerce API endpoint for getting products
$endpoint = "/wp-json/wc/v4/products";

// Use curl to send a GET request to the endpoint
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $store_url . $endpoint );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_USERPWD, $consumer_key . ':' . $consumer_secret );
curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
$response = curl_exec( $ch );
curl_close( $ch );

// Check for errors
if ( $response === false ) {
    // Handle error
    echo 'Error: ' . curl_error( $ch );
} else {
    // Parse the response body as JSON
    $data = json_decode( $response );
    if (json_last_error() !== JSON_ERROR_NONE) {
        echo 'Error: ' . json_last_error_msg();
        exit;
    }
    // Iterate through the products
    foreach ( $data as $product ) {
        // Output the product name and stock amount
        echo $product->name . ": " . $product->stock_quantity . "<br>";
    }

}
?>

 

Edited by StevenDn

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

Waarom PHP en niet rechtstreeks met FMP?

Je curl url heeft dubbele slashes!

"https://beautiqa.be/shop/" . "/wp-json/wc/v4/products"

 

Edited by Banach

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...