تابع ووکامرسی wc_has_notice بررسی اینکه آیا هشدار ( اعلان ) اضافه شده ؟

تابع ووکامرسی wc_has_notice – بررسی اینکه آیا هشدار ( اعلان ) اضافه شده ؟
Syntax – سینتکس
wc_has_notice( (string) $message, (string) $notice_type = 'success' );
Parameters – پارامتر ها (2)
- 1- $message (string)
- 2- $notice_type (string)
Usage – نحوه استفاده
if ( !function_exists( 'wc_has_notice' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-notice-functions.php';
}
// The text to display in the notice.
$message = '';
// The singular name of the notice type - either error, success or notice. [optional]
$notice_type = 'success';
// NOTICE! Understand what this does before running.
$result = wc_has_notice($message, $notice_type);
Defined – محل تعریف
/includes/wc-notice-functions.php
function wc_has_notice( $message, $notice_type = 'success' ) {
if ( ! did_action( 'woocommerce_init' ) ) {
wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', woocommerce ), '2.3' );
return false;
}
$notices = WC()->session->get( 'wc_notices', array() );
$notices = isset( $notices[ $notice_type ] ) ? $notices[ $notice_type ] : array();
return array_search( $message, $notices ) !== false;
}
versions – نسخه ها
از نسخه : 2.1
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر