• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_get_notices函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wc_get_notices函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_notices函数的具体用法?PHP wc_get_notices怎么用?PHP wc_get_notices使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wc_get_notices函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: store_pay_shortcode_mesages

 /**
  * Store any messages or errors added by other plugins, particularly important for those occasions when the new payment
  * method caused and error or failure.
  *
  * @since 1.4
  */
 public static function store_pay_shortcode_mesages()
 {
     if (wc_notice_count('notice') > 0) {
         self::$woocommerce_messages = wc_get_notices('success');
         self::$woocommerce_messages += wc_get_notices('notice');
     }
     if (wc_notice_count('error') > 0) {
         self::$woocommerce_errors = wc_get_notices('error');
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:16,代码来源:class-wc-subscriptions-change-payment-gateway.php


示例2: output

 /**
  * Output the shortcode.
  *
  * @param array $atts
  */
 public static function output($atts)
 {
     global $wp;
     // Check cart class is loaded or abort
     if (is_null(WC()->cart)) {
         return;
     }
     if (!is_user_logged_in()) {
         $message = apply_filters('woocommerce_my_account_message', '');
         if (!empty($message)) {
             wc_add_notice($message);
         }
         // After password reset, add confirmation message.
         if (!empty($_GET['password-reset'])) {
             wc_add_notice(__('Your password has been reset successfully.', 'woocommerce'));
         }
         if (isset($wp->query_vars['lost-password'])) {
             self::lost_password();
         } else {
             wc_get_template('myaccount/form-login.php');
         }
     } else {
         // Start output buffer since the html may need discarding for BW compatibility
         ob_start();
         // Collect notices before output
         $notices = wc_get_notices();
         // Output the new account page
         self::my_account($atts);
         /**
          * Deprecated my-account.php template handling. This code should be
          * removed in a future release.
          *
          * If woocommerce_account_content did not run, this is an old template
          * so we need to render the endpoint content again.
          */
         if (!did_action('woocommerce_account_content')) {
             foreach ($wp->query_vars as $key => $value) {
                 if ('pagename' === $key) {
                     continue;
                 }
                 if (has_action('woocommerce_account_' . $key . '_endpoint')) {
                     ob_clean();
                     // Clear previous buffer
                     wc_set_notices($notices);
                     wc_print_notices();
                     do_action('woocommerce_account_' . $key . '_endpoint', $value);
                     break;
                 }
             }
             wc_deprecated_function('Your theme version of my-account.php template', '2.6', 'the latest version, which supports multiple account pages and navigation, from WC 2.6.0');
         }
         // Send output buffer
         ob_end_flush();
     }
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:60,代码来源:class-wc-shortcode-my-account.php


示例3: store_pay_shortcode_mesages

 /**
  * Store any messages or errors added by other plugins, particularly important for those occasions when the new payment
  * method caused and error or failure.
  *
  * @since 1.4
  */
 public static function store_pay_shortcode_mesages()
 {
     global $woocommerce;
     if (function_exists('wc_notice_count')) {
         // WC 2.1+
         if (wc_notice_count('notice') > 0) {
             self::$woocommerce_messages = wc_get_notices('success');
             self::$woocommerce_messages += wc_get_notices('notice');
         }
         if (wc_notice_count('error') > 0) {
             self::$woocommerce_errors = wc_get_notices('error');
         }
     } else {
         if ($woocommerce->message_count() > 0) {
             self::$woocommerce_messages = $woocommerce->get_messages();
         }
         if ($woocommerce->error_count() > 0) {
             self::$woocommerce_errors = $woocommerce->get_errors();
         }
     }
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:27,代码来源:class-wc-subscriptions-change-payment-gateway.php


示例4: woocommerce_add_to_cart_variable_rc_callback

 function woocommerce_add_to_cart_variable_rc_callback()
 {
     ob_start();
     $product_id = apply_filters('woocommerce_add_to_cart_product_id', absint($_POST['product_id']));
     $quantity = empty($_POST['quantity']) ? 1 : apply_filters('woocommerce_stock_amount', $_POST['quantity']);
     $variation_id = $_POST['variation_id'];
     $variation = $_POST['variation'];
     $passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, $quantity);
     if ($passed_validation && WC()->cart->add_to_cart($product_id, $quantity, $variation_id, $variation)) {
         do_action('woocommerce_ajax_added_to_cart', $product_id);
         if (get_option('woocommerce_cart_redirect_after_add') == 'yes') {
             wc_add_to_cart_message($product_id);
         }
         // Return fragments
         WC_AJAX::get_refreshed_fragments();
     } else {
         // If there was an error adding to the cart, redirect to the product page to show any errors
         $notice = end(wc_get_notices('error'));
         $data = array('error' => true, 'product_url' => apply_filters('woocommerce_cart_redirect_after_error', get_permalink($product_id), $product_id), 'notice' => $notice);
         wp_send_json($data);
     }
     die;
 }
开发者ID:vlabunets,项目名称:my-php-functions,代码行数:23,代码来源:woocommerce-ajax-add-to-cart-variable-products.php


示例5: test_wc_get_notices

 /**
  * Test wc_get_notices().
  *
  * @since 2.2
  */
 public function test_wc_get_notices()
 {
     // no notices
     $notices = wc_get_notices();
     $this->assertInternalType('array', $notices);
     $this->assertEmpty($notices);
     // default type
     wc_add_notice('Another Notice');
     $this->assertEquals(array('success' => array('Another Notice')), wc_get_notices());
     // specific type
     wc_add_notice('Error Notice', 'error');
     $this->assertEquals(array('Error Notice'), wc_get_notices('error'));
     // invalid type
     $notices = wc_get_notices('bogus_type');
     $this->assertInternalType('array', $notices);
     $this->assertEmpty($notices);
 }
开发者ID:bitoncoin,项目名称:woocommerce,代码行数:22,代码来源:notice-functions.php


示例6: get_permalink

        $redirect_url = get_permalink(icl_object_id(function_exists('wc_get_page_id') ? wc_get_page_id('cart') : woocommerce_get_page_id('cart')), 'page', true);
    } else {
        $redirect_url = get_permalink(function_exists('wc_get_page_id') ? wc_get_page_id('cart') : woocommerce_get_page_id('cart'));
    }
} else {
    $redirect_url = $yith_wcwl->get_wishlist_url();
}
//get the details of the product
$details = $yith_wcwl->get_product_details($_GET['wishlist_item_id']);
//add to the cart
if ($woocommerce->cart->add_to_cart($details[0]['prod_id'], 1)) {
    //$_SESSION['messages'] 	= sprintf( '<a href="%s" class="button">%s</a> %s', get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart &rarr;', 'yit' ), __( 'Product successfully added to the cart.', 'yit' ) );
    if (function_exists('wc_add_to_cart_message')) {
        wc_add_to_cart_message($details[0]['prod_id']);
    } else {
        woocommerce_add_to_cart_message($details[0]['prod_id']);
    }
    //$woocommerce->set_messages();
    if (get_option('yith_wcwl_remove_after_add_to_cart') == 'yes') {
        $yith_wcwl->remove($details[0]['ID']);
    }
    header("Location: {$redirect_url}");
} else {
    //if failed, redirect to wishlist page with errors
    if (function_exists('wc_get_notices')) {
        $_SESSION['errors'] = wc_get_notices("error");
    } else {
        $_SESSION['errors'] = $woocommerce->get_errors();
    }
    header("Location: {$error_link_url}");
}
开发者ID:epiii,项目名称:aros,代码行数:31,代码来源:add-to-cart.php


示例7: payment_failure

 /**
  * @param $gateway_id
  * @param $order_id
  * @param $response
  */
 private function payment_failure($gateway_id, $order_id, $response)
 {
     $message = isset($response['messages']) ? $response['messages'] : wc_get_notices('error');
     // if messages empty give generic response
     if (empty($message)) {
         $message = __('There was an error processing the payment', 'woocommerce-pos');
     }
     update_post_meta($order_id, '_pos_payment_result', 'failure');
     update_post_meta($order_id, '_pos_payment_message', $message);
 }
开发者ID:rpidanny,项目名称:WooCommerce-POS,代码行数:15,代码来源:class-wc-pos-orders.php


示例8: get_messages

 /**
  * @deprecated 2.1.0
  * @return mixed
  */
 public function get_messages()
 {
     _deprecated_function('Woocommerce->get_messages', '2.1', 'wc_get_notices( "success" )');
     return wc_get_notices('success');
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:9,代码来源:woocommerce.php


示例9: avia_woocommerce_cart_dropdown

function avia_woocommerce_cart_dropdown()
{
    global $woocommerce, $avia_config;
    $cart_subtotal = $woocommerce->cart->get_cart_subtotal();
    $link = $woocommerce->cart->get_cart_url();
    $id = "";
    $added = wc_get_notices('success');
    $trigger = !empty($added) ? "av-display-cart-on-load" : "";
    if (avia_get_option('cart_icon') == "always_display_menu") {
        $id = 'id="menu-item-shop"';
    }
    $output = "";
    $output .= "<ul {$id} class = 'cart_dropdown {$trigger}' data-success='" . __('was added to the cart', 'avia_framework') . "'><li class='cart_dropdown_first'>";
    $output .= "<a class='cart_dropdown_link' href='" . $link . "'><span " . av_icon_string('cart') . "></span><span class='av-cart-counter'>0</span><span class='avia_hidden_link_text'>" . __('Shopping Cart', 'avia_framework') . "</span></a><!--<span class='cart_subtotal'>" . $cart_subtotal . "</span>-->";
    $output .= "<div class='dropdown_widget dropdown_widget_cart'><div class='avia-arrow'></div>";
    $output .= '<div class="widget_shopping_cart_content"></div>';
    $output .= "</div>";
    $output .= "</li></ul>";
    echo $output;
}
开发者ID:darrylivan,项目名称:caraccidentlawyerflagstaff.com,代码行数:20,代码来源:config.php


示例10: wc_add_to_cart_message

$error_link_url = $yith_wcwl->get_wishlist_url();
//determine to success link redirect url
//handle redirect option chosen by admin
if (isset($_GET['redirect_to_cart']) && $_GET['redirect_to_cart'] == 'true') {
    $redirect_url = $woocommerce->cart->get_cart_url();
} else {
    $redirect_url = $yith_wcwl->get_wishlist_url();
}
//get the details of the product
$details = $yith_wcwl->get_product_details($_GET['wishlist_item_id']);
//add to the cart
if ($woocommerce->cart->add_to_cart($details[0]['prod_id'], 1)) {
    if (function_exists('wc_add_to_cart_message')) {
        wc_add_to_cart_message($details[0]['prod_id']);
    } else {
        woocommerce_add_to_cart_message($details[0]['prod_id']);
    }
    $woocommerce->set_messages();
    if (get_option('yith_wcwl_remove_after_add_to_cart') == 'yes') {
        $yith_wcwl->remove($details[0]['ID']);
    }
    header("Location: {$redirect_url}");
} else {
    //if failed, redirect to wishlist page with errors
    if (function_exists('wc_get_notices')) {
        $_SESSION['errors'] = wc_get_notices('error');
    } else {
        $_SESSION['errors'] = $woocommerce->get_errors();
    }
    header("Location: {$error_link_url}");
}
开发者ID:zgomotos,项目名称:Bazar,代码行数:31,代码来源:add-to-cart.php


示例11: ajax_product_add_to_cart

 function ajax_product_add_to_cart()
 {
     global $post, $woocommerce, $product;
     /* Set arrays and variables */
     $prod_id = $_POST['id'];
     $var_id = '';
     $quantity = $_POST['quantity'];
     $attributes = $_POST['atts'];
     /* Get Product by id*/
     $product = wc_get_product($prod_id);
     /* Set attribute array for this cart item and modify it to fit  */
     $att_query = array();
     foreach ($attributes as $name => $value) {
         $new_att_name = 'attribute_' . $name;
         $value = str_replace(" ", "-", $value);
         $att_query[$new_att_name] = strtolower($value);
     }
     /* If has children get variations and check the array against the data passed before */
     if ($product->has_child()) {
         $available_variations = $product->get_available_variations();
         $count = count($available_variations);
         /* if only one variation, use only one id */
         if ($count == '1') {
             foreach ($available_variations as $avar) {
                 $var_id = $avar['variation_id'];
                 $attributes = $att_query;
                 $result = $woocommerce->cart->add_to_cart($prod_id, $quantity, $var_id, $attributes, null);
             }
             /* if more than one variation, do this fancy pants logic */
         } elseif ($count > '1') {
             $var_id = '';
             $count_difference = '999';
             foreach ($available_variations as $avar) {
                 $attributes = $avar['attributes'];
                 $att_count = count($attributes);
                 /* check for exact match. If exact, add to cart and exit */
                 if ($att_query == $attributes) {
                     $var_id = $avar['variation_id'];
                     break;
                 } else {
                     $difference = array_diff($att_query, $attributes);
                     $cdif = count($difference);
                     if ($cdif < $count_difference) {
                         $count_difference = $cdif;
                         $var_id = $avar['variation_id'];
                         $check_dif = $difference;
                     }
                 }
             }
             $attributes = $att_query;
             $result = $woocommerce->cart->add_to_cart($prod_id, $quantity, $var_id, $attributes, null);
         }
         /* If no children, just add to cart */
     } else {
         $result = $woocommerce->cart->add_to_cart($prod_id, $quantity);
     }
     /* Call WC ajax after add to cart. Not yet found a way to make this work. */
     //add_filter('add_to_cart_fragments', WC_AJAX::get_refreshed_fragments());
     //add_action('woocommerce_add_to_cart','');
     /* cart notices */
     $notices = wc_get_notices();
     if (!empty($notices)) {
         wc_print_notices();
         exit;
     }
     if (!empty($result) && empty($notices)) {
         echo '<ul class="woocommerce-success"><li>Product successfully added to your cart.</li></ul>';
         exit;
     }
     if (empty($result) && empty($notices)) {
         echo '<ul class="woocommerce-error"><li>Product could not be added to your cart.</li></ul>';
         exit;
     } else {
         exit;
     }
 }
开发者ID:hslatman,项目名称:woocommerce-bulk-order-form,代码行数:76,代码来源:variation_search_template.php


示例12: expire_notice_added

 public function expire_notice_added()
 {
     foreach (wc_get_notices() as $type => $notices) {
         foreach ($notices as $notice) {
             if (false !== strpos($notice, 'wc-csr-countdown')) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:begatsby,项目名称:woocommerce-cart-stock-reducer,代码行数:11,代码来源:class-woocommerce-cart-stock-reducer.php


示例13: 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;
         }
     }
 }
开发者ID:JaneJieYing,项目名称:kiddoonline_dvlpment,代码行数:43,代码来源:wjecf-autocoupon.php



注:本文中的wc_get_notices函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_get_order函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_get_log_file_path函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap