Как поменять статус заказа в админке WordPress
Вот как приходит заказ на фото 1
Как изменить строку Оплачено под Заказ детали? Хотя заказ еще не оплачен на фото 2
Как делается заказ в файле function.php
global $woocommerce;
$address = array(
'first_name' => $orderInfo["name"],
'last_name' => '',
'company' => '',
'email' => $orderInfo["email"],
'phone' => str_replace(array("-", " ", "+", "(", ")"), "", $orderInfo["phone"]),
'address_1' => $orderInfo["address"],
'address_2' => $orderInfo["comment"],
'city' => '',
'state' => '',
'postcode' => '',
'country' => ''
);
$address1 = array(
'first_name' => $orderInfo["name"],
'last_name' => '',
'company' => '',
'address_1' => $orderInfo["address"],
'address_2' => $orderInfo["comment"],
'city' => '',
'state' => '',
'postcode' => '',
'country' => ''
);
// Now we create the order
$order = wc_create_order();
// The add_product() function below is located in /plugins/woocommerce/includes/abstracts/abstract_wc_order.php
for ($i = 0; $i < count($cart); $i ++) {
$order->add_product( get_product($cart[$i]['id']), $cart[$i]['amount']);
}
$order->set_address( $address, 'billing' );
$order->set_address( $address1, 'shipping' );
$order->calculate_totals();
$order->update_status("processing", 'Imported order', TRUE);
if($orderInfo['pay'] == 1) {
$order->update_status("pending", 'Imported order', TRUE);
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
$result = $available_gateways['tinkoff']->process_payment($order->id);
$result = apply_filters('woocommerce_payment_successful_result', $result, $order->id);
$res = $available_gateways['tinkoff']->receipt_page($order->id, true);
//exit();
if($res != '') {
echo json_encode(['success' => true, 'link' => $res]);
wp_die();
} else {
if ($result['result'] == 'success') {
echo json_encode(['success' => true, 'message' => "Спасибо! Ваш заказ отправлен. Мы свяжемся с Вами в ближайшее время."]);
}
}
} else {
echo json_encode(['success' => true, 'message' => "Спасибо! Ваш заказ отправлен. Мы свяжемся с Вами в ближайшее время."]);
}
wp_die();
}

