2016-03-20 15 views
0

Bu, CI ve wooapi v2 ile yazılmıştır. Sipariş, her zaman manual renewal yerine completed olarak işaretlenir. Hedef, eğer durum zaten manuel yenileme ise, tamamlanmış olarak işaretlenmeyecek, ancak manuel olarak yenilenecektir. Herhangi bir yardım büyük beğeni topluyor. CI için biraz yeni.CI sipariş durumu ile sorun

function complete_order($orderid) { 
    $consumer_key = 'xxx'; // Add your own Consumer Key here 
    $consumer_secret = 'xxxx'; // Add your own Consumer Secret here 
    $store_url = 'xxx'; // Add the home URL to the store you want to connect to here 
    $options = array(
     'debug' => true, 
     'return_as_array' => false, 
     'validate_url' => false, 
     'timeout' => 30, 
     'ssl_verify' => false, 
    ); 
    $servername = "xxx"; 
    $username = "xxx"; 
    $password = "xxx"; 
    $dbname = "xxx"; 
    $conn = new mysqli($servername, $username, $password, $dbname); 
    $sql ="SELECT * FROM xxxxxx WHERE ID = '$orderid'"; 
    $result = $conn->query($sql); 
    while($row = $result->fetch_assoc()) { 
     $poststatus= '. $row["post_status"].'; 
     if ($poststatus = wc-manual-renewal-re){ 
      $client = new WC_API_Client($store_url, $consumer_key, $consumer_secret, $options); 
      $client->orders->update_status($orderid, 'wc-manual-renewal-re'); 
     }else{$client = new WC_API_Client($store_url, $consumer_key, $consumer_secret, $options); 
      $client->orders->update_status($orderid, 'wc-completed'); 
     } 
    } 
} 
+0

hata $ sql olduğunu düşünüyorum = "NEREDE kimlik = '$ orderid' xxxxxx" SELECT * FROM; veya $ poststatus = '. $ Satır [ "post_status"] '.; Bildiğim her şeyi denediniz ve düzeltemiyorum. – gpratt86

+0

bu, 'if ($ poststatus = wc-manual-renewal-re) {' anlamına gelmez. Öncelikle, her zaman doğru olarak dönecek olan === '' yi '' 'yerine atarsınız ve sanırım bu bir dizge olmalı, sabit değil:' wc-manual-re-re' – JimL

+0

Teşekkür ederim. @JImL. Benim bölümümde çok aptalca bir hata. === düzeltildi. Cevabı ver ve doğru olarak işaretleyeceğim. – gpratt86

cevap

0

Sen = atama yerine her zaman doğru dönecektir === karşılaştırdığınız senin burada kod

if ($poststatus = wc-manual-renewal-re){ 
    $client = new WC_API_Client($store_url, $consumer_key, $consumer_secret, $options); 

    $client->orders->update_status($orderid, 'wc-manual-renewal-re'); 
} 

hatalar/yazım bir çift var ve bu bir dize olmamalıdır tahmin sabit: wc-manual-renewal-re

if ($poststatus === 'wc-manual-renewal-re'){ 
    $client = new WC_API_Client($store_url, $consumer_key, $consumer_secret, $options); 

    $client->orders->update_status($orderid, 'wc-manual-renewal-re'); 
}