Automattic\WooCommerce\Internal\Caches
CouponCodeLookupInvalidator::get_cache_key
Get the object cache key holding the ids of the published coupons with the given code.
The key must be used with the cache group returned by get_cache_group().
Method of the class: CouponCodeLookupInvalidator{}
No Hooks.
Returns
string. The cache key.
Usage
$CouponCodeLookupInvalidator = new CouponCodeLookupInvalidator(); $CouponCodeLookupInvalidator->get_cache_key( $code ): string;
- $code(string) (required)
- Coupon code.
Changelog
| Since 11.2.0 | Introduced. |
CouponCodeLookupInvalidator::get_cache_key() CouponCodeLookupInvalidator::get cache key code WC 11.3.0
public function get_cache_key( string $code ): string {
// Coupon code allows spaces, which doesn't work well with some cache engines (e.g. memcached), hence the hashing.
$hashed_code = md5( wc_strtolower( $code ) );
return \WC_Cache_Helper::get_cache_prefix( self::CACHE_GROUP ) . 'coupon_id_from_code_' . $hashed_code;
}