status

Auto set Woocommerce product to draft status if order is completed

泄露秘密 提交于 2019-12-11 05:55:01
问题 In WooCommerce I would like to set products to draft status when Order is completed… So what I want is to make products to be sold 1 time and passed to draft when order get completed. Any idea? 回答1: Try the following code, that will set the products found in order items with a "draft" status only when order get "processing" or "completed" statuses (paid order statuses) : add_action( 'woocommerce_order_status_changed', 'action_order_status_changed', 10, 4 ); function action_order_status

Check serverlist offline / online PHP

折月煮酒 提交于 2019-12-11 05:29:31
问题 i try to make a script to check if my server are online or offline: <? $server = "12.34.56.78"; $check = @fsockopen($server, 22); if ($check) { @fclose($check); echo "online"; exit; }else{ echo "offline"; } ?> so this script works, but how can i make the script that i can check more than one ip address? Greetings, matthias 回答1: $servers = Array("server1", "server2"); foreach ($servers as $server) { // same as before } 回答2: function checkServerOnline($server, $port = 22) { $check = @fsockopen(

Why wait() returns -1 error code?

旧街凉风 提交于 2019-12-11 03:09:49
问题 I have the following code: void fork1() { pid_t id, cpid; int status; id = fork(); if (id > 0) { // parent code cpid = wait(&status); printf("I received from my child %d this information %d\n", cpid, status); } else if (id == 0) { // child code sleep(2); exit(46); } else exit(EXIT_FAILURE); exit(EXIT_SUCCESS); } The output is: I received from my child -1 this information 0 So, why I receive the -1 error code after wait ? I was expecting to receive the value 46 as status. EDIT: I added the

How to know when the user turn on/off mobile data or wifi?

雨燕双飞 提交于 2019-12-11 02:55:44
问题 My application needs to know when the Wifi or the Mobile data has been turned on or off by the user. Actually it shows when the network changes, if the device has connection or not, works fine. but I want to konw when the user is turning on/off the network manually. Right know I have this on my Manifest. <receiver android:name="pe.com.gps.broadcastreceivers.CheckForMobileDataBroadcastReceiver" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/> </intent-filter> <

What is the db.collection.stats() command in mongoose?

两盒软妹~` 提交于 2019-12-11 02:45:18
问题 I want to check one collection's information just like the db.collection.stats() command in origin MongoDB How can I do it in mongoose on schema or on model? 回答1: Had the same problem and managed to query it this way: YourModel.collection.stats(callback); You basically access a Model 's native interface via the collection property (this is not the collection name, but a property in fact called collection ). You can then use any native functions on this object. 回答2: You can run any arbitrary

How to check user has liked(+1) google+ button on website or url?

…衆ロ難τιáo~ 提交于 2019-12-10 22:45:56
问题 How to get like status of google+ button on website or url? I am using PHP. 回答1: Unfortunately this isn't quite possible. Neither the REST API nor the PlusOne button itselfs provides a method to check whether a user has +1'd the page or not. Furthermore, if you're using PHP, the user would have to authenticate himself first (using OAuth), so that's probably not what you want, anyway. What you can do, however, is using Javascript to catch actions of the current visitor. You can specify a

Check thread status while leaving it in a waitable state

随声附和 提交于 2019-12-10 21:18:22
问题 I am wondering if it is possible to check the status of a thread, which could possibly be in a waitable state but doesn't have to be and if it is in a waitable state I would like to leave it in that state. Basically, how can I check the status of a thread without changing its (waitable) state. By waitable, I mean if I called wait(pid) it would return properly and not hang. Let me also add that I am tracing a multithreaded program, therefore I cannot change the code of it. Also, I omitted this

Adding a status bar to c++ console applications

北慕城南 提交于 2019-12-10 20:02:15
问题 I am making a linux application using C++ and it will print info out to the console. Parts of the program will take a while to compute and I would like to add a status bar in the console similar to the one used in wget (I put my own depiction below). %complete[===========> ] eta What would be the best way to accomplish this goal? Are there any useful libraries that make it easy to add this functionality? 回答1: If your program is like wget, that is, it's basically a batch program without the

Why can't I see my site, and get HTTP Status 404?

ⅰ亾dé卋堺 提交于 2019-12-10 19:38:04
问题 I'm doing servlet using spring mvc and I can't see my site. I've posted my web.xml, mvc-dispatcher-servlet.xml and controller class below. Everything seems to be fine, but when I enter "localhost:8080" I get 404 http status The requested resource is not available . Did I miss something? web.xml: <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee

Angular Http Error status missing

Deadly 提交于 2019-12-10 19:33:06
问题 I'm using an Http client wich is an extended version from Angular 4's Http Client export class SecurityClient extends Http { // ... } In this client I have methods that attempt calls against an api and I want to catch 401 status to try a refresh token. I have an implementation like this: get(url: string, options?: RequestOptionsArgs): Observable<Response> { return super.get(url, this._getOptions(options)).catch((initialError: any) => { console.log('error: ' + JSON.stringify(initialError)); if