Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Woocommerce API
phpamator
post
Post #1





Grupa: Zarejestrowani
Postów: 328
Pomógł: 3
Dołączył: 10.07.2016
Skąd: UK-raine

Ostrzeżenie: (0%)
-----


Hejka, jako, że święta tuż tuż,
WSZYSTKIEGO DOBREGO, wielkiego Mikołaja i prezentów po sufit.


Dość słodzenia i do rzeczy (IMG:style_emoticons/default/tongue.gif)

Szukam przykładów jak pobrać listę klientów woocomerce przez API.
Nie wiem gdzie jest błąd ale jak wysyłam request to mi zwraca wszystko co się tylko da ale nie listę. Mogę zobaczyć wszystkie obiekty jakie tylko, wszystkie endpointy ale nie mogę wyciągnąć danych klientów
  1. require __DIR__ . '/vendor/autoload.php';
  2.  
  3. use Automattic\WooCommerce\Client;
  4.  
  5. use Automattic\WooCommerce\HttpClient\HttpClientException;
  6.  
  7. $woocommerce = new Client(
  8. 'https://applications.com/index.php',
  9. 'moj klucz',
  10. 'ymoj klucz',
  11. [
  12. 'version' => 'wc/v3/?=',
  13. ]
  14. );
  15. try {
  16. // Array of response results.
  17. $data = [
  18. 'role' => 'customer'
  19.  
  20. ];
  21. $results = $woocommerce->get('customers',$data);
  22. echo '<pre>';
  23. print_r($results);
  24.  
  25. // foreach ($results as $prod)
  26. // {
  27. // $prods .= '';
  28. // }
  29.  
  30. } catch (HttpClientException $e) {
  31. //
  32. }
  33.  

przykładowy kod wywala mi tylko ....
  1. stdClass Object
  2. (
  3. [namespace] => wc/v3
  4. [routes] => stdClass Object
  5. (
  6. [/wc/v3] => stdClass Object
  7. (
  8. [namespace] => wc/v3
  9. [methods] => Array
  10. (
  11. [0] => GET
  12. )
  13.  
  14. [endpoints] => Array
  15. (
  16. [0] => stdClass Object
  17. (
  18. [methods] => Array
  19. (
  20. [0] => GET
  21. )
  22.  
  23. [args] => stdClass Object
  24. (
  25. [namespace] => stdClass Object
  26. (
  27. [default] => wc/v3
  28. [required] =>
  29. )
  30.  
  31. [context] => stdClass Object
  32. (
  33. [default] => view
  34. [required] =>
  35. )
  36.  
  37. )
  38.  
  39. )
  40.  
  41. )
  42.  
  43. [_links] => stdClass Object
  44. (
  45. [self] => Array
  46. (
  47. [0] => stdClass Object .............
  48.  
  49.  


Podpowiedzcie proszę
oczywiście nie podpinam się z WP, robię zewnętrzny skrypt.
zapomniałem dodać, że używan do tego :
automattic/woocommerce PHP wrapper for the WooCommerce REST API
który działa na innym systemie (przynajmniej pobiera produkty) (IMG:style_emoticons/default/tongue.gif)


Ten post edytował phpamator 16.12.2021, 22:12:32
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.12.2025 - 11:41