Map one of the WC_Coupon message codes to a message string.
public get_coupon_message ( integer $msg_code ) : string | ||
$msg_code | integer | |
return | string |
/** * 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; } } }