当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Subscriptions::print_notices方法代码示例

本文整理汇总了PHP中WC_Subscriptions::print_notices方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions::print_notices方法的具体用法?PHP WC_Subscriptions::print_notices怎么用?PHP WC_Subscriptions::print_notices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Subscriptions的用法示例。


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

示例1: maybe_replace_pay_shortcode

 /**
  * If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form.
  *
  * @since 1.4
  */
 public static function maybe_replace_pay_shortcode()
 {
     if (!self::$is_request_to_change_payment) {
         return;
     }
     $valid_request = false;
     ob_clean();
     do_action('before_woocommerce_pay');
     echo '<div class="woocommerce">';
     if (!empty(self::$woocommerce_errors)) {
         foreach (self::$woocommerce_errors as $error) {
             WC_Subscriptions::add_notice($error, 'error');
         }
     }
     if (!empty(self::$woocommerce_messages)) {
         foreach (self::$woocommerce_messages as $message) {
             WC_Subscriptions::add_notice($message, 'success');
         }
     }
     $subscription = wcs_get_subscription(absint($_GET['change_payment_method']));
     if (wp_verify_nonce($_GET['_wpnonce'], __FILE__) === false) {
         WC_Subscriptions::add_notice(__('There was an error with your request. Please try again.', 'woocommerce-subscriptions'), 'error');
     } elseif (empty($subscription)) {
         WC_Subscriptions::add_notice(__('Invalid subscription.', 'woocommerce-subscriptions'), 'error');
     } elseif (!current_user_can('edit_shop_subscription_payment_method', $subscription->id)) {
         WC_Subscriptions::add_notice(__('That doesn\'t appear to be one of your subscriptions.', 'woocommerce-subscriptions'), 'error');
     } elseif (!$subscription->can_be_updated_to('new-payment-method')) {
         WC_Subscriptions::add_notice(__('The payment method can not be changed for that subscription.', 'woocommerce-subscriptions'), 'error');
     } else {
         if ($subscription->get_time('next_payment') > 0) {
             // translators: placeholder is next payment's date
             $next_payment_string = sprintf(__(' Next payment is due %s.', 'woocommerce-subscriptions'), $subscription->get_date_to_display('next_payment'));
         } else {
             $next_payment_string = '';
         }
         // translators: placeholder is either empty or "Next payment is due..."
         WC_Subscriptions::add_notice(sprintf(__('Choose a new payment method.%s', 'woocommerce-subscriptions'), $next_payment_string), 'notice');
         WC_Subscriptions::print_notices();
         if ($subscription->order_key == $_GET['key']) {
             // Set customer location to order location
             if ($subscription->billing_country) {
                 WC()->customer->set_country($subscription->billing_country);
             }
             if ($subscription->billing_state) {
                 WC()->customer->set_state($subscription->billing_state);
             }
             if ($subscription->billing_postcode) {
                 WC()->customer->set_postcode($subscription->billing_postcode);
             }
             wc_get_template('checkout/form-change-payment-method.php', array('subscription' => $subscription), '', plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/');
             $valid_request = true;
         } else {
             WC_Subscriptions::add_notice(__('Invalid order.', 'woocommerce-subscriptions'), 'error');
         }
     }
     if (false === $valid_request) {
         WC_Subscriptions::print_notices();
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:64,代码来源:class-wc-subscriptions-change-payment-gateway.php

示例2: maybe_replace_pay_shortcode

 /**
  * If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form.
  *
  * @since 1.4
  */
 public static function maybe_replace_pay_shortcode()
 {
     global $woocommerce;
     if (!self::$is_request_to_change_payment) {
         return;
     }
     ob_clean();
     do_action('before_woocommerce_pay');
     echo '<div class="woocommerce">';
     if (!empty(self::$woocommerce_errors)) {
         foreach (self::$woocommerce_errors as $error) {
             WC_Subscriptions::add_notice($error, 'error');
         }
     }
     if (!empty(self::$woocommerce_messages)) {
         foreach (self::$woocommerce_messages as $message) {
             WC_Subscriptions::add_notice($message, 'success');
         }
     }
     $subscription_key = $_GET['change_payment_method'];
     $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
     if (wp_verify_nonce($_GET['_wpnonce'], __FILE__) === false) {
         WC_Subscriptions::add_notice(__('There was an error with your request. Please try again.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } elseif (!WC_Subscriptions_Manager::user_owns_subscription($subscription_key)) {
         WC_Subscriptions::add_notice(__('That doesn\'t appear to be one of your subscriptions.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } elseif (empty($subscription)) {
         WC_Subscriptions::add_notice(__('Invalid subscription.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } elseif (!WC_Subscriptions_Manager::can_subscription_be_changed_to('new-payment-method', $subscription_key, get_current_user_id())) {
         WC_Subscriptions::add_notice(__('The payment method can not be changed for that subscription.', 'woocommerce-subscriptions'), 'error');
         WC_Subscriptions::print_notices();
     } else {
         $order = new WC_Order($subscription['order_id']);
         $order_id = absint($_GET['order_id']);
         $order_key = isset($_GET['key']) ? $_GET['key'] : $_GET['order'];
         $product_id = $subscription['product_id'];
         $next_payment_timestamp = WC_Subscriptions_Order::get_next_payment_timestamp($order, $product_id);
         if (!empty($next_payment_timestamp)) {
             $next_payment_string = sprintf(__(' Next payment is due %s.', 'woocommerce-subscriptions'), date_i18n(woocommerce_date_format(), $next_payment_timestamp));
         } else {
             $next_payment_string = '';
         }
         WC_Subscriptions::add_notice(sprintf(__('Choose a new payment method.%s', 'woocommerce-subscriptions'), $next_payment_string), 'notice');
         WC_Subscriptions::print_notices();
         if ($order->order_key == $order_key) {
             // Set customer location to order location
             if ($order->billing_country) {
                 $woocommerce->customer->set_country($order->billing_country);
             }
             if ($order->billing_state) {
                 $woocommerce->customer->set_state($order->billing_state);
             }
             if ($order->billing_postcode) {
                 $woocommerce->customer->set_postcode($order->billing_postcode);
             }
             // Show form
             WC_Subscriptions_Order::$recurring_only_price_strings = true;
             woocommerce_get_template('checkout/form-change-payment-method.php', array('order' => $order, 'subscription_key' => $subscription_key), '', plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/');
             WC_Subscriptions_Order::$recurring_only_price_strings = false;
         } else {
             WC_Subscriptions::add_notice(__('Invalid order.', 'woocommerce-subscriptions'), 'error');
             WC_Subscriptions::print_notices();
         }
     }
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:72,代码来源:class-wc-subscriptions-change-payment-gateway.php

示例3: maybe_replace_pay_shortcode

    /**
     * If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form.
     *
     * @since 1.4
     */
    public static function maybe_replace_pay_shortcode()
    {
        global $wp;
        $valid_request = false;
        // if the request to pay for the order belongs to a subscription but there's no GET params for changing payment method, show receipt page.
        if (!self::$is_request_to_change_payment && isset($wp->query_vars['order-pay']) && wcs_is_subscription(absint($wp->query_vars['order-pay']))) {
            $valid_request = true;
            ob_clean();
            do_action('before_woocommerce_pay');
            $subscription_key = isset($_GET['key']) ? wc_clean($_GET['key']) : '';
            $subscription = wcs_get_subscription(absint($wp->query_vars['order-pay']));
            if ($subscription->id == absint($wp->query_vars['order-pay']) && $subscription->order_key == $subscription_key) {
                ?>
			<div class="woocommerce">
				<ul class="order_details">
					<li class="order">
						<?php 
                esc_html_e('Subscription Number:', 'woocommerce-subscriptions');
                ?>
						<strong><?php 
                echo esc_html($subscription->get_order_number());
                ?>
</strong>
					</li>
					<li class="date">
						<?php 
                esc_html_e('Next Payment Date:', 'woocommerce-subscriptions');
                ?>
						<strong><?php 
                echo esc_html($subscription->get_date_to_display('next_payment'));
                ?>
</strong>
					</li>
					<li class="total">
						<?php 
                esc_html_e('Total:', 'woocommerce-subscriptions');
                ?>
						<strong><?php 
                echo wp_kses_post($subscription->get_formatted_order_total());
                ?>
</strong>
					</li>
					<?php 
                if ($subscription->payment_method_title) {
                    ?>
					<li class="method">
						<?php 
                    esc_html_e('Payment Method:', 'woocommerce-subscriptions');
                    ?>
						<strong><?php 
                    echo esc_html($subscription->get_payment_method_to_display());
                    ?>
</strong>
					</li>
					<?php 
                }
                ?>
				</ul>

				<?php 
                do_action('woocommerce_receipt_' . $subscription->payment_method, $subscription->id);
                ?>

				<div class="clear"></div>
				<?php 
            } else {
                wc_add_notice(__('Sorry, this subscription change payment method request is invalid and cannot be processed.', 'woocommerce-subscriptions'), 'error');
            }
            wc_print_notices();
        } elseif (!self::$is_request_to_change_payment) {
            return;
        } else {
            ob_clean();
            do_action('before_woocommerce_pay');
            echo '<div class="woocommerce">';
            if (!empty(self::$woocommerce_errors)) {
                foreach (self::$woocommerce_errors as $error) {
                    WC_Subscriptions::add_notice($error, 'error');
                }
            }
            if (!empty(self::$woocommerce_messages)) {
                foreach (self::$woocommerce_messages as $message) {
                    WC_Subscriptions::add_notice($message, 'success');
                }
            }
            $subscription = wcs_get_subscription(absint($_GET['change_payment_method']));
            if (wp_verify_nonce($_GET['_wpnonce'], __FILE__) === false) {
                WC_Subscriptions::add_notice(__('There was an error with your request. Please try again.', 'woocommerce-subscriptions'), 'error');
            } elseif (empty($subscription)) {
                WC_Subscriptions::add_notice(__('Invalid subscription.', 'woocommerce-subscriptions'), 'error');
            } elseif (!current_user_can('edit_shop_subscription_payment_method', $subscription->id)) {
                WC_Subscriptions::add_notice(__('That doesn\'t appear to be one of your subscriptions.', 'woocommerce-subscriptions'), 'error');
            } elseif (!$subscription->can_be_updated_to('new-payment-method')) {
                WC_Subscriptions::add_notice(__('The payment method can not be changed for that subscription.', 'woocommerce-subscriptions'), 'error');
            } else {
//.........这里部分代码省略.........
开发者ID:slavic18,项目名称:cats,代码行数:101,代码来源:class-wc-subscriptions-change-payment-gateway.php


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