llms_get_order_by_key( string $key, string $return = 'order' )
Retrieve an LLMS Order ID by the associated order_key.
Parameters Parameters
- $key
-
(string) (Required) The order key.
- $return
-
(string) (Optional) Type of return, "order" for an instance of the LLMS_Order or "id" to return only the order ID.
Default value: 'order'
Return Return
(mixed) null when no order found, LLMS_Order when $return = 'order', or the WP_Post ID as an int.
Source Source
File: includes/functions/llms.functions.order.php
* @since 3.30.1 Return a real `int` (instead of a numeric string).
*
* @param string $key The order key.
* @param string $return Type of return, "order" for an instance of the LLMS_Order or "id" to return only the order ID.
* @return mixed `null` when no order found, LLMS_Order when `$return` = 'order', or the WP_Post ID as an `int`.
*/
function llms_get_order_by_key( $key, $return = 'order' ) {
global $wpdb;
$id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = '_llms_order_key' AND meta_value = %s", $key ) ); // no-cache ok.
if ( $id && 'order' === $return ) {
return new LLMS_Order( $id );
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.30.1 | Return a real int (instead of a numeric string). |
| 3.0.0 | Introduced. |