Differences

This shows you the differences between two versions of the page.

Link to this comparison view

daily:woocommerce_api_php_json_format [2020/03/06 15:04] (current)
admin created
Line 1: Line 1:
 +Using the [[https://​github.com/​woocommerce/​wc-api-php]] api php for woocommerce I've found two interesting things:
  
 +First, I don't like composer. One of the bests things I like from PHP is the code and run anywhere. I just need apache php and a few php packages from repository to run any web or script in any linux server or any desktop. I don't like php frameworks.
 +
 +To use the wrapper I don't use composer, so I have to edit the firsts lines of the src files provided in the releases. I only change the use Automattic\WooCommerce\HttpClient\HttpClient;​ for a include '​HttpClient/​HttpClient.php and done.
 +
 +Second. It seems easy to insert or update products (or any element from woocomerce) BUT be carefull when in the [[https://​woocommerce.github.io/​woocommerce-rest-api-docs|API Reference]] a property is typed as Array you may use this
 +
 +<code php>
 +$array_list_of_variables = Array('​1Kg','​5Kg','​10Kg'​);​
 + ​$prod_data['​attributes'​] = Array('​id'​ => 8, '​option'​ => $array_list_of_variables);​
 +</​code>​
 +
 +But this fails.
 +
 +You should do:
 +<code php>
 +$array_list_of_variables = Array('​1Kg','​5Kg','​10Kg'​);​
 + ​$prod_data['​attributes'​] = [Array('​id'​ => 8, '​option'​ => $array_list_of_variables)];​
 +</​code>​
  • daily/woocommerce_api_php_json_format.txt
  • Last modified: 2020/03/06 15:04
  • by admin