本文整理汇总了PHP中wc_add_notice函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_add_notice函数的具体用法?PHP wc_add_notice怎么用?PHP wc_add_notice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_add_notice函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: apply_coupon
/**
* AJAX apply coupon on checkout page
*/
public function apply_coupon()
{
check_ajax_referer('apply-coupon', 'security');
if (!empty($_POST['coupon_code'])) {
WC()->cart->add_discount(sanitize_text_field($_POST['coupon_code']));
} else {
wc_add_notice(WC_Coupon::get_generic_coupon_error(WC_Coupon::E_WC_COUPON_PLEASE_ENTER), 'error');
}
wc_print_notices();
die;
}
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:14,代码来源:class-wc-ajax.php
示例2: wc_redirects__add_to_cart_redirect
function wc_redirects__add_to_cart_redirect($url)
{
static $cached_result = null;
if (isset($cached_result)) {
return $cached_result;
}
if (!isset($_REQUEST['add-to-cart'])) {
return $url;
}
$product_id = apply_filters('woocommerce_add_to_cart_product_id', absint($_REQUEST['add-to-cart']));
$selected_redirection_type = get_post_meta($product_id, WC_REDIRECTS__REDIRECTION_TYPE_META_NAME, true);
if (!empty($selected_redirection_type)) {
foreach (wc_redirects__get_valid_redirection_types() as $redirection_type) {
if ($redirection_type['name'] === $selected_redirection_type) {
$result = call_user_func($redirection_type['callback']);
if ($result === false) {
wc_add_notice("Item added to cart, but redirection " . "to {$redirection_type['label']} failed.");
} else {
$url = $result;
}
break;
}
}
}
return $cached_result = $url;
}
开发者ID:BurlesonBrad,项目名称:woocommerce-redirects,代码行数:26,代码来源:woocommerce-redirects-wc.php
示例3: calculate_shipping
/**
* Calculate shipping for the cart
*/
public static function calculate_shipping()
{
try {
WC()->shipping->reset_shipping();
$country = wc_clean($_POST['calc_shipping_country']);
$state = wc_clean(isset($_POST['calc_shipping_state']) ? $_POST['calc_shipping_state'] : '');
$postcode = apply_filters('woocommerce_shipping_calculator_enable_postcode', true) ? wc_clean($_POST['calc_shipping_postcode']) : '';
$city = apply_filters('woocommerce_shipping_calculator_enable_city', false) ? wc_clean($_POST['calc_shipping_city']) : '';
if ($postcode && !WC_Validation::is_postcode($postcode, $country)) {
throw new Exception(__('Please enter a valid postcode/ZIP.', 'woocommerce'));
} elseif ($postcode) {
$postcode = wc_format_postcode($postcode, $country);
}
if ($country) {
WC()->customer->set_location($country, $state, $postcode, $city);
WC()->customer->set_shipping_location($country, $state, $postcode, $city);
} else {
WC()->customer->set_to_base();
WC()->customer->set_shipping_to_base();
}
WC()->customer->calculated_shipping(true);
wc_add_notice(__('Shipping costs updated.', 'woocommerce'), 'notice');
do_action('woocommerce_calculated_shipping');
} catch (Exception $e) {
if (!empty($e)) {
wc_add_notice($e->getMessage(), 'error');
}
}
}
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:32,代码来源:class-wc-shortcode-cart.php
示例4: checkout_validate_vat
public static function checkout_validate_vat()
{
check_ajax_referer('update-order-review', 'security');
if (!isset($_POST['vat_id']) || !isset($_POST['country'])) {
die;
}
$country = sanitize_text_field($_POST['country']);
$vat_id = trim(preg_replace("/[^a-z0-9.]+/i", "", sanitize_text_field($_POST['vat_id'])));
// Strip away country code
if (substr($vat_id, 0, 2) == $country) {
$vat_id = substr($vat_id, 2);
}
if (WC_GZDP_VAT_Helper::instance()->validate($country, $vat_id)) {
// Add price vat filters..
add_filter('woocommerce_cart_get_taxes', array(__CLASS__, "remove_taxes"), 0, 2);
echo json_encode(array('valid' => true, 'vat_id' => $country . '-' . $vat_id));
} else {
wc_add_notice(__('VAT ID seems to be invalid.', 'woocommerce-germanized-pro'), 'error');
ob_start();
wc_print_notices();
$messages = ob_get_clean();
echo json_encode(array('valid' => false, 'error' => $messages));
}
die;
}
开发者ID:radscheit,项目名称:unicorn,代码行数:25,代码来源:class-wc-gzdp-ajax.php
示例5: cancel_booking
/**
* Cancel a booking.
*/
public static function cancel_booking()
{
if (isset($_GET['cancel_booking']) && isset($_GET['booking_id'])) {
$booking_id = absint($_GET['booking_id']);
$booking = get_wc_booking($booking_id);
$booking_can_cancel = $booking->has_status(apply_filters('woocommerce_valid_booking_statuses_for_cancel', array('unpaid', 'pending-confirmation', 'confirmed', 'paid')));
$redirect = $_GET['redirect'];
if ($booking->has_status('cancelled')) {
// Already cancelled - take no action
} elseif ($booking_can_cancel && $booking->id == $booking_id && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'woocommerce-bookings-cancel_booking')) {
// Cancel the booking
$booking->update_status('cancelled');
WC_Cache_Helper::get_transient_version('bookings', true);
// Message
wc_add_notice(apply_filters('woocommerce_booking_cancelled_notice', __('Your booking was cancelled.', 'woocommerce-bookings')), apply_filters('woocommerce_booking_cancelled_notice_type', 'notice'));
do_action('woocommerce_bookings_cancelled_booking', $booking->id);
} elseif (!$booking_can_cancel) {
wc_add_notice(__('Your booking can no longer be cancelled. Please contact us if you need assistance.', 'woocommerce-bookings'), 'error');
} else {
wc_add_notice(__('Invalid booking.', 'woocommerce-bookings'), 'error');
}
if ($redirect) {
wp_safe_redirect($redirect);
exit;
}
}
}
开发者ID:tonyvu1985,项目名称:appletutorings,代码行数:30,代码来源:class-wc-booking-form-handler.php
示例6: wc_minimum_order_amount
function wc_minimum_order_amount()
{
global $woocommerce;
$postcode = get_user_meta(get_current_user_id(), 'shipping_postcode', true);
if (strstr(' 90024 90027 90028 90029 90034 90036 90038 90039 90046 90048 90064 90066 90067 90068 90069 90095 90230 90291 90401 90402 90403 90404 90405 91505 91506 91602 91604 91607 91608 90010 90012 90019 90020 90025 90232 91601 91606 90073 90031 90090 90005 90004 90026 90035 90056 90211 90212 ', $postcode)) {
$minimum = 60;
} else {
if (strstr(' 90045 90049 90016 90292 91423 90008 90018 90045 90049 90210 90245 90272 90293 90077 90094 91403 91436 90079 90210 90007 90015 90017 90057 90071 90089 90266 90013 90014 ', $postcode)) {
$minimum = 100;
} else {
$minimum = false;
}
}
if ($minimum == false) {
wc_print_notice(sprintf('We are unable to service your area at this time. Please give us a call at (323) 450-7708 to discuss arrangements for your delivery.', wc_price($minimum), wc_price(WC()->cart->subtotal)), 'error');
echo "<script>\n\t\t\t\tjQuery(document).ready(function(\$) {\n\t\t\t\t\t\$('.checkout-button').addClass('disabled');\n\t\t\t\t\t\$('.checkout-button').click(function(e) { e.preventDefault(); });\n\t\t\t\t});\n\t\t\t</script>";
} elseif (WC()->cart->subtotal < $minimum) {
if (is_cart()) {
wc_print_notice(sprintf('Based on your zip code ' . $postcode . ', you must have an order with a minimum of %s to checkout. Your current order total is %s.', wc_price($minimum), wc_price(WC()->cart->subtotal)), 'error');
echo "\n\t\t\t\t<script>\n\t\t\t\t\tjQuery(document).ready(function(\$) {\n\t\t\t\t\t\t\$('.checkout-button').addClass('disabled');\n\t\t\t\t\t\t\$('.checkout-button').click(function(e) { e.preventDefault(); });\n\t\t\t\t\t});\n\t\t\t\t</script>";
} else {
wc_add_notice(sprintf('Based on your zip code ' . $postcode . ', you must have an order with a minimum of %s to checkout. Your current order total is %s.', wc_price($minimum), wc_price(WC()->cart->subtotal)), 'error');
}
}
}
开发者ID:keyshames,项目名称:tcm2016,代码行数:25,代码来源:checkout.php
示例7: renew_handler
/**
* Handle a renewal url
*/
public function renew_handler()
{
if (!empty($_GET['renew_licence']) && is_user_logged_in()) {
global $wpdb;
$licence_key = sanitize_text_field($_GET['renew_licence']);
$licence = $wpdb->get_row($wpdb->prepare("\n\t\t\t\tSELECT * FROM {$wpdb->prefix}wp_plugin_licencing_licences\n\t\t\t\tWHERE licence_key = %s\n\t\t\t\tAND ( user_id = %d OR user_id = 0 )\n\t\t\t", $licence_key, get_current_user_id()));
// Renewable?
if (!$licence) {
wc_add_notice(__('Invalid licence', 'wp-plugin-licencing'), 'error');
return;
}
if (!$licence->date_expires || strtotime($licence->date_expires) > current_time('timestamp')) {
wc_add_notice(__('This licence does not need to be renewed yet', 'wp-plugin-licencing'), 'notice');
return;
}
// Purchasable?
$product = get_product($licence->product_id);
if (!$product->is_purchasable()) {
wc_add_notice(__('This product can no longer be purchased', 'wp-plugin-licencing'), 'error');
return;
}
// Add to cart
WC()->cart->empty_cart();
WC()->cart->add_to_cart($licence->product_id, 1, '', '', array('renewing_key' => $licence_key));
// Message
wc_add_notice(sprintf(__('The product has been added to your cart with a %d%% discount.', 'wp-plugin-licencing'), apply_filters('wp_plugin_licencing_renewal_discount_percent', 30)), 'success');
// Redirect to checkout
wp_redirect(get_permalink(wc_get_page_id('checkout')));
exit;
}
}
开发者ID:ChromeOrange,项目名称:wp-plugin-licencing,代码行数:34,代码来源:class-wp-plugin-licencing-renewals.php
示例8: validate_add_cart_item
public function validate_add_cart_item($passed, $product_id, $qty)
{
$product = get_product($product_id);
if ($product->product_type !== 'trip') {
return $passed;
}
$stockOk = false;
foreach ($this->package_types as $package) {
if (isset($_POST['wc_trip_' . $package . "_package"])) {
$post = $_POST['wc_trip_' . $package . "_package"];
$stockCheck = $product->check_package_stock($package, $post);
if ($stockCheck) {
$stockOk = true;
} else {
wc_add_notice("Sorry, " . $post . " is out of stock", 'error');
return false;
}
}
}
if ($stockOk) {
return true;
} else {
wc_add_notice("Couldn't find specified packages, try again", 'error');
return false;
}
}
开发者ID:NerdyDillinger,项目名称:ovrride,代码行数:26,代码来源:class-wc-trips-cart.php
示例9: wc_template_redirect
/**
* Handle redirects before content is output - hooked into template_redirect so is_page works.
*/
function wc_template_redirect()
{
global $wp_query, $wp;
// When default permalinks are enabled, redirect shop page to post type archive url
if (!empty($_GET['page_id']) && '' === get_option('permalink_structure') && $_GET['page_id'] == wc_get_page_id('shop')) {
wp_safe_redirect(get_post_type_archive_link('product'));
exit;
} elseif (is_page(wc_get_page_id('checkout')) && WC()->cart->is_empty() && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
wc_add_notice(__('Checkout is not available whilst your cart is empty.', 'woocommerce'), 'notice');
wp_redirect(wc_get_page_permalink('cart'));
exit;
} elseif (isset($wp->query_vars['customer-logout'])) {
wp_redirect(str_replace('&', '&', wp_logout_url(wc_get_page_permalink('myaccount'))));
exit;
} elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && 1 === absint($wp_query->found_posts)) {
$product = wc_get_product($wp_query->post);
if ($product && $product->is_visible()) {
wp_safe_redirect(get_permalink($product->id), 302);
exit;
}
} elseif (is_add_payment_method_page()) {
WC()->payment_gateways();
} elseif (is_checkout()) {
// Buffer the checkout page
ob_start();
// Ensure gateways and shipping methods are loaded early
WC()->payment_gateways();
WC()->shipping();
}
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:33,代码来源:wc-template-functions.php
示例10: validate_custom_checkout_field_process
function validate_custom_checkout_field_process()
{
// Check if set, if its not set add an error.
if (isset($_POST['latitude']) && !$_POST['latitude'] || isset($_POST['longitude']) && !$_POST['longitude']) {
wc_add_notice(__('Please define your location on the map.'), 'error');
}
}
开发者ID:ambisyoso901,项目名称:wordpress,代码行数:7,代码来源:custom-checkout-field-to-shipping-method.php
示例11: plp_cartcontent
function plp_cartcontent()
{
global $woocommerce;
$poj = new WC_Product_Factory();
$count = 0;
if (isset($_POST['productadd'])) {
$woocommerce->cart = new WC_Cart();
$woocommerce->cart->get_cart_from_session();
foreach ($_POST['productadd'] as $productId => $quantity) {
$quantity = (int) $quantity;
$productId = (int) $productId;
$product = $poj->get_product($productId);
if ($quantity > 0) {
if (isset($product->variation_id) && isset($product->parent)) {
$woocommerce->cart->add_to_cart($product->parent->id, $quantity, $product->variation_id, $product->get_variation_attributes());
} else {
$woocommerce->cart->add_to_cart($productId, $quantity);
}
$count++;
}
}
if ($count >= 1) {
$success_msg = get_option('plp_custom_success_msg');
wc_add_notice($success_msg, "success");
} else {
$error_msg = get_option('plp_custom_err_msg');
wc_add_notice($error_msg, "error");
}
}
}
开发者ID:brian3t,项目名称:orchidmate,代码行数:30,代码来源:plugin.php
示例12: maybe_setup_cart
/**
* Setup the cart for paying for a delayed initial payment for a subscription.
*
* @since 2.0
*/
public function maybe_setup_cart()
{
global $wp;
if (isset($_GET['pay_for_order']) && isset($_GET['key']) && isset($wp->query_vars['order-pay'])) {
// Pay for existing order
$order_key = $_GET['key'];
$order_id = isset($wp->query_vars['order-pay']) ? $wp->query_vars['order-pay'] : absint($_GET['order_id']);
$order = wc_get_order($wp->query_vars['order-pay']);
if ($order->order_key == $order_key && $order->has_status(array('pending', 'failed')) && !wcs_order_contains_subscription($order, array('renewal', 'resubscribe'))) {
$subscriptions = wcs_get_subscriptions_for_order($order, array('order_type' => 'parent'));
if (get_current_user_id() !== $order->get_user_id()) {
wc_add_notice(__('That doesn\'t appear to be your order.', 'woocommerce-subscriptions'), 'error');
wp_safe_redirect(get_permalink(wc_get_page_id('myaccount')));
exit;
} elseif (!empty($subscriptions)) {
// Setup cart with all the original order's line items
$this->setup_cart($order, array('order_id' => $order_id));
WC()->session->set('order_awaiting_payment', $order_id);
// Set cart hash for orders paid in WC >= 2.6
$this->set_cart_hash($order_id);
wp_safe_redirect(WC()->cart->get_checkout_url());
exit;
}
}
}
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:31,代码来源:class-wcs-cart-initial-payment.php
示例13: active_free_order
/**
* @return void
*/
public function active_free_order()
{
try {
$response = array();
$fb_id = isset($_POST['post_id']) ? $_POST['post_id'] : 0;
$redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : '';
if (!$fb_id || !$redirect_url || !is_user_logged_in()) {
throw new Exception(__('Không thể kích hoạt', NDV_WOO));
return false;
}
$user = wp_get_current_user();
update_user_meta($user->ID, 'ndv_share', $fb_id);
$response['status'] = 'success';
$response['redirect'] = $redirect_url;
if (is_ajax()) {
echo '<!--WC_START-->' . json_encode($response) . '<!--WC_END-->';
exit;
} else {
wp_redirect($response['redirect']);
exit;
}
} catch (Exception $e) {
if (!empty($e)) {
wc_add_notice($e->getMessage(), 'error');
}
}
if (is_ajax()) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
echo '<!--WC_START-->' . json_encode(array('result' => 'failure', 'messages' => isset($messages) ? $messages : '')) . '<!--WC_END-->';
exit;
}
}
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:37,代码来源:class-ndv-share.php
示例14: wc_gateway_ppec_format_paypal_api_exception
function wc_gateway_ppec_format_paypal_api_exception($errors)
{
$error_strings = array();
foreach ($errors as $error) {
$error_strings[] = $error->maptoBuyerFriendlyError();
}
wc_add_notice(__('Payment error:', 'woocommerce-gateway-paypal-express-checkout') . '<ul><li>' . implode('</li><li>', $error_strings) . '</li></ul>', 'error');
}
开发者ID:ksan5835,项目名称:maadithottam,代码行数:8,代码来源:functions.php
示例15: checkoutProcess
/**
* @author Panagiotis Vagenas <[email protected]>
* @since 151229
*/
public function checkoutProcess()
{
if ($this->isTimologioRequest()) {
$valid = $this->validateInvoicePostFields();
if (count($valid) < count($this->fields)) {
wc_add_notice(__('Please fill all invoice fields', 'wc-timologio'), 'error');
}
}
}
开发者ID:panvagenas,项目名称:timologio-for-woocommerce,代码行数:13,代码来源:WcTimologio.php
示例16: add_error
/**
* Add an error
*/
public function add_error($error)
{
if (function_exists('wc_add_notice')) {
wc_add_notice($error, 'error');
} else {
global $woocommerce;
$woocommerce->add_error($error);
}
}
开发者ID:brian3t,项目名称:orchidmate,代码行数:12,代码来源:class-product-addon-cart.php
示例17: woocommerce_billing_fields_ro_process
function woocommerce_billing_fields_ro_process()
{
global $woocommerce;
// Check if set, if its not set add an error. This one is only required for companies
if (isset($_POST['billing_company']) && !empty($_POST['billing_company'])) {
if (empty($_POST['wbfr_cif']) || empty($_POST['wbfr_regcom']) || empty($_POST['wbfr_cont_banca']) || empty($_POST['wbfr_banca'])) {
wc_add_notice(__('Nu ai introdus toate câmpurile de la <strong>Date facturare firmă</strong> din partea de jos a paginii'), 'error');
}
}
}
开发者ID:neamtua,项目名称:woocommerce-billing-fields-ro,代码行数:10,代码来源:woocommerce-billing-fields-ro.php
示例18: nm_wc_add_notice
/**
* some WC functions wrapper
* */
function nm_wc_add_notice($string, $type = "error")
{
global $woocommerce;
if (version_compare($woocommerce->version, 2.1, ">=")) {
wc_add_notice($string, $type);
// Use new, updated functions
} else {
$woocommerce->add_error($string);
}
}
开发者ID:GermansRegi,项目名称:wordpress-bacicleta,代码行数:13,代码来源:config.php
示例19: coupon_validation
public function coupon_validation()
{
$wc = WC();
$coupons = $wc->cart->get_coupons();
if (empty($coupons)) {
$options = get_option('foa_woo_force_coupon', '');
$errornotice = empty($options['errornotice']) ? __('Coupon is a required field. Please enter a coupon.', 'woo-force-coupon') : $options['errornotice'];
wc_add_notice($errornotice, 'error');
}
}
开发者ID:kowsar89,项目名称:woo-force-coupon,代码行数:10,代码来源:class-woo-force-coupon.php
示例20: __construct
public function __construct()
{
$this->paydunya_errors = new WP_Error();
$this->id = 'paydunya';
$this->medthod_title = 'PAYDUNYA';
$this->icon = apply_filters('woocommerce_paydunya_icon', plugins_url('assets/images/logo.png', __FILE__));
$this->has_fields = false;
$this->init_form_fields();
$this->init_settings();
$this->title = $this->settings['title'];
$this->description = $this->settings['description'];
$this->live_master_key = $this->settings['master_key'];
$this->live_private_key = $this->settings['live_private_key'];
$this->live_token = $this->settings['live_token'];
$this->test_private_key = $this->settings['test_private_key'];
$this->test_token = $this->settings['test_token'];
$this->sandbox = $this->settings['sandbox'];
$this->sms = $this->settings['sms'];
$this->sms_url = $this->settings['sms_url'];
$this->sms_message = $this->settings['sms_message'];
if ($this->settings['sandbox'] == "yes") {
$this->posturl = 'https://app.paydunya.com/sandbox-api/v1/checkout-invoice/create';
$this->geturl = 'https://app.paydunya.com/sandbox-api/v1/checkout-invoice/confirm/';
} else {
$this->posturl = 'https://app.paydunya.com/api/v1/checkout-invoice/create';
$this->geturl = 'https://app.paydunya.com/api/v1/checkout-invoice/confirm/';
}
$this->msg['message'] = "";
$this->msg['class'] = "";
if (isset($_REQUEST["paydunya"])) {
wc_add_notice($_REQUEST["paydunya"], "error");
}
if (isset($_REQUEST["token"]) && $_REQUEST["token"] != "") {
$token = trim($_REQUEST["token"]);
$this->check_paydunya_response($token);
} else {
$query_str = $_SERVER['QUERY_STRING'];
$query_str_arr = explode("?", $query_str);
foreach ($query_str_arr as $value) {
$data = explode("=", $value);
if (trim($data[0]) == "token") {
$token = isset($data[1]) ? trim($data[1]) : "";
if ($token != "") {
$this->check_paydunya_response($token);
}
break;
}
}
}
if (version_compare(WOOCOMMERCE_VERSION, '2.0.0', '>=')) {
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options'));
} else {
add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
}
}
开发者ID:paydunya,项目名称:paydunya-wordpress,代码行数:55,代码来源:paydunya-woocommerce-gateway.php
注:本文中的wc_add_notice函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论