تابع ووکامرسی wc_add_notice افزودن هشدار در woocommerce

تابع ووکامرسی wc_add_notice – اضافه و ذخیره هشدار در ووکامرس
Syntax – سینتکس
wc_add_notice( (string) $message, (string) $notice_type = 'success' );
Parameters – پارامتر ها (2)
- 1- $message (string)
- 2- $notice_type (string)
Usage – نحوه استفاده
if ( !function_exists( 'wc_add_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_add_notice($message, $notice_type);
Defined – محل تعریف
/includes/wc-notice-functions.php
function wc_add_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;
}
$notices = WC()->session->get( 'wc_notices', array() );
// Backward compatibility
if ( 'success' === $notice_type ) {
$message = apply_filters( 'woocommerce_add_message', $message );
}
$notices[ $notice_type ][] = apply_filters( 'woocommerce_add_' . $notice_type, $message );
WC()->session->set( 'wc_notices', $notices );
}
versions – نسخه ها
از نسخه : 2.1
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر