FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour WooCommerce
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
WooCommerce
Posted: Fri Oct 20, 2023 07: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/product-csv-import-suite-column-header-reference/?quid=61d0a20b3db888521bf16e9a1f95f7cc


as a reference for the structure of the csv file this page for orders
https://woocommerce.com/documentation/products/extensions/ordercustomer-csv-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 March-April 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
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: WooCommerce
Posted: Fri Oct 20, 2023 08: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 (fw): Select all Collapse
#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.08 with Harbour
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: WooCommerce
Posted: Fri Oct 20, 2023 08: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.08 with Harbour
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: WooCommerce
Posted: Fri Oct 20, 2023 01: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 March-April 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

Continue the discussion