本文整理匯總了PHP中WC_Coupon::get_coupon_message方法的典型用法代碼示例。如果您正苦於以下問題:PHP WC_Coupon::get_coupon_message方法的具體用法?PHP WC_Coupon::get_coupon_message怎麽用?PHP WC_Coupon::get_coupon_message使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WC_Coupon
的用法示例。
在下文中一共展示了WC_Coupon::get_coupon_message方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: overwrite_success_message
/**
* Overwrite the default "Coupon added" notice with a more descriptive message.
* @param WC_Coupon $coupon The coupon data
* @param bool $remove_message_only If true the notice will be removed, and no notice will be shown.
* @return void
*/
private function overwrite_success_message($coupon, $remove_message_only = false)
{
$succss_msg = $coupon->get_coupon_message(WC_Coupon::WC_COUPON_SUCCESS);
//If ajax, remove only
$remove_message_only |= defined('DOING_AJAX') && DOING_AJAX;
$new_succss_msg = sprintf(__("Discount applied: %s", 'woocommerce-jos-autocoupon'), __($this->coupon_excerpt($coupon), 'woocommerce-jos-autocoupon'));
//Compatibility woocommerce-2-1-notice-api
if (function_exists('wc_get_notices')) {
$all_notices = wc_get_notices();
if (!isset($all_notices['success'])) {
$all_notices['success'] = array();
}
$messages = $all_notices['success'];
} else {
$messages = $woocommerce->messages;
}
$sizeof_messages = sizeof($messages);
for ($y = 0; $y < $sizeof_messages; $y++) {
if ($messages[$y] == $succss_msg) {
if (isset($all_notices)) {
if ($remove_message_only) {
unset($all_notices['success'][$y]);
} else {
$all_notices['success'][$y] = $new_succss_msg;
}
WC()->session->set('wc_notices', $all_notices);
} else {
if ($remove_message_only) {
unset($messages[$y]);
} else {
$messages[$y] = $new_succss_msg;
}
}
break;
}
}
}