License Manager for WooCommerce

Easily sell and manage software license keys through your shop

lmfwc_delete_license_meta()

function lmfwc_delete_license_meta(int $licenseId, string $metaKey, mixed $metaValue = null)

Description

Deletes a license meta field for the given license ID. You can match based on the key, or key and value. Removing based on key and value, will keep from removing duplicate metadata with the same key. It also allows removing all metadata matching the key, if needed.

Parameters

$licenseId

(int) (Required) License ID.

$metaKey

(string) (Required) Metadata name.

$metaValue

(mixed) (Optional) Metadata value. Must be serializable if non-scalar.

Return value

(bool) True on success, false on failure.

Source

File: /includes/functions/lmfwc-meta-functions.php

/**
 * Deletes one or multiple rows from the license meta table.
 *
 * @param int    $licenseId
 * @param string $metaKey
 * @param mixed  $metaValue
 *
 * @return bool
 */
function lmfwc_delete_license_meta($licenseId, $metaKey, $metaValue = null)
{
    $license = LicenseResourceRepository::instance()->find($licenseId);

    if (!$license) {
        return false;
    }

    $deleteQueryCondition = array(
        'license_id' => $licenseId,
        'meta_key' => $metaKey
    );

    if ($metaValue) {
        $deleteQueryCondition['meta_value'] = $metaValue;
    }

    $deleteResult = LicenseMetaResourceRepository::instance()->deleteBy($deleteQueryCondition);

    if ($deleteResult) {
        return true;
    }

    return false;
}