تابع ووکامرسی wc_get_coupon_id_by_code دریافت آیدی کوپن بر اساس کد کوپن

تابع ووکامرسی wc_get_coupon_id_by_code – دریافت آیدی کوپن بر اساس کد کوپن
Syntax – سینتکس
(int) wc_get_coupon_id_by_code( (string) $code, (int) $exclude = 0 );
Parameters – پارامتر ها (2)
- 1- $code (string)
- 2- $exclude (int)
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_coupon_id_by_code' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-coupon-functions.php';
}
// The code.
$code = '';
// Used to exclude an ID from the check if you're checking existence.
$exclude = -1;
// NOTICE! Understand what this does before running.
$result = wc_get_coupon_id_by_code($code, $exclude);
Defined – محل تعریف
/includes/wc-coupon-functions.php
function wc_get_coupon_id_by_code( $code, $exclude = 0 ) {
$data_store = WC_Data_Store::load( 'coupon' );
$ids = wp_cache_get( WC_Cache_Helper::get_cache_prefix( 'coupons' ) . 'coupon_id_from_code_' . $code, 'coupons' );
if ( false === $ids ) {
$ids = $data_store->get_ids_by_code( $code );
if ( $ids ) {
wp_cache_set( WC_Cache_Helper::get_cache_prefix( 'coupons' ) . 'coupon_id_from_code_' . $code, $ids, 'coupons' );
}
}
$ids = array_diff( array_filter( array_map( 'absint', (array) $ids ) ), array( $exclude ) );
return apply_filters( 'woocommerce_get_coupon_id_from_code', absint( current( $ids ) ), $code, $exclude );
}
versions – نسخه ها
از نسخه : 3.0.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر