Jump to content

How to change an order status on woocommerce using AutoIt


Recommended Posts

Hello Everyone, 

So I'm using auto it to automate the download of pictures in woocommerce orders. Once images are downloaded, I need to change the status of the order from in process to completed. This is how my code looks like: 

Download()

Func Download()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @DesktopDir&"\TestAutomatizacion\"&@YEAR &"_"& @MON &"_"& @MDAY & "_picpic_orders.zip"

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("https://hellopicpic.com/get_pic_orders.php?token=ygtV2bMh23uJ7f6s&type=pic", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

EndFunc   ;==>Download

 

Thanks for any help you can give. 

Link to comment
Share on other sites

21 hours ago, rudi said:

Hi,

 

I do not get, what's your Problem. You are asking on how to Change the order startus for "woocommerce", but all you give is Code to download URLs?

 

cu, Rudi.

Thanks for your interest. I figure it out. A colleague will run a php file on the server, so I had to do in in another way. Reading in the forum, looking for solutions I found ideas on how to make it done. So I end with this: 

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <InetConstants.au3>
#include <WinAPIFiles.au3>


MarkCompleted()

Func MarkCompleted()
    ; List all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray(@DesktopDir &"\" &@YEAR &"_"& @MON &"_"& @MDAY & "_picpic_orders", "*.txt")
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf

For $i= 1 to 18
   Local $sString = StringLeft($aFileList[$i], 4) ; Retrieve 5 characters from the left of the string.
   InetGet("https://hellopicpic.com/set_pic_orders_completed.php?token=ygtV2bMh23uJ7f6s&id="&$sString & @CRLF, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

Next
 EndFunc   ;==>MarkCompleted

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...