WooCommerce

WooCommerce

Postby Silvio.Falconi » Fri Oct 20, 2023 7:28 am

How to transfer the articles.dbf data to a site that has woocommerce?
I would need the same thing for orders placed on the site

then Sending articles and receiving orders

Obviously I understood that I have to create a csv file and I found the structure of how it should be

as a reference for the structure of the csv file this page for articles
https://woocommerce.com/document/produc ... 9a1f95f7cc


as a reference for the structure of the csv file this page for orders
https://woocommerce.com/documentation/p ... sv-export/

If I create the csv file then I can import the articles into woocoomerce ok
but I wanted to do it automatically from a fwh program i.e. the procedure must work in the background i.e. it must save the articles on the website which I pass to it the parameters web address \ consumer key \ consumer secret

Is there anyone who has done a small procedure to test?
any help thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: WooCommerce

Postby Marc Venken » Fri Oct 20, 2023 8:17 am

Silvio,

Then you will need to use the API. Uploading a csv will always need intervention of customer. At least in my webshop.

I suppose you have the Token from the shop in order to connect.

Here is a small sample of connection via API. WooCommerce seems to work with the same RESTAPI.

This site needs no Token (For testing RESTAPI)

Code: Select all  Expand view  RUN
#include "FiveWin.ch"

Function Main()
   local oWnd, oActiveX1, oActiveX2, cTemp

   DEFINE WINDOW oWnd TITLE "FiveWin multiple ActiveX support"

   @ 5, 5 BUTTON "&API TEST"     OF oWnd SIZE 40, 20  ACTION TestAPI()

   ACTIVATE WINDOW oWnd

return nil

function TestAPI()

   local oHttp
   local cUrl  := "https://petstore.swagger.io/v2/pet/3"  //  the 3 is the item number in the database
   local hDatos    := { => }
   local uResponse, cCookies, I, cLink
   local cData

   cData    := '{ "name": "Noyca", "status" : "available" }'  //  Data for uploading changes.  Not needed for this sample

   MsgRun( cUrl, "READING API PAGE", { || uResponse := WebPageContents( cUrl, .t. ) } )

   XBrowser( uResponse ) FASTEDIT

   hb_JsonDecode( uResponse, @hDatos )     // -> Hash. You need some HASH functions to strip the data, change them and upload again
   XBrowser( hDatos ) FASTEDIT


   oHttp := FWGetOleObject( "WINHTTP.WinHttpRequest.5.1" )

   WITH OBJECT oHttp
      :SetTimeouts(0, 60000, 30000, 120000)
//      :Open( "POST", cUrl, .f. )   //  Sometimes POST or PATCH
      :Open( "PATCH", cUrl, .f. )
      :SetRequestHeader( "Accept",        "application/json" )
      :SetRequestHeader( "Content-Type",  "application/json" )
      :Send( cData )
      :WaitForResponse()
      ? :Status, :StatusText // 200 OK
   END
//  Writing gives a error.  I think a Token is needed for writing now
return nil

 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: WooCommerce

Postby Marc Venken » Fri Oct 20, 2023 8:20 am

A Url like I need to do :

cOnlineCode = Dbf-ID that I want to see.

cUrl="https://mave.../api/v2/products/"+alltrim(cOnlineCode)+"?token=47b...."
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: WooCommerce

Postby Silvio.Falconi » Fri Oct 20, 2023 1:51 pm

Marc,
I have to understand well
to access the web domain I use a user code and a password

then to access the woocommerce program I have
the Address folder of the website created with WooCommerce,

Consumer key / Consumer secret
Access keys generated via WooCommerce administration

Now I want to create a woocommerce demo to test
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Surasak and 39 guests