WC_Order_Data_Store_CPT::get_order_id_by_order_key()publicWC 1.0

Finds an Order ID based on an order key.

Метод класса: WC_Order_Data_Store_CPT{}

Хуков нет.


int. The ID of an order, or 0 if the order could not be found


$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->get_order_id_by_order_key( $order_key );
$order_key(строка) (обязательный)
An order key has generated by.

Код WC_Order_Data_Store_CPT::get_order_id_by_order_key() WC 8.9.3

public function get_order_id_by_order_key( $order_key ) {
	global $wpdb;
	return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = '_order_key' AND meta_value = %s", $order_key ) );