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


PHP WC_Subscriptions::append_numeral_suffix方法代码示例

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


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

示例1: wcs_get_subscription_period_interval_strings

/**
 * Return an i18n'ified associative array of all possible subscription periods.
 *
 * @param int (optional) An interval in the range 1-6
 * @since 2.0
 */
function wcs_get_subscription_period_interval_strings($interval = '')
{
    $intervals = array(1 => _x('every', 'period interval (eg "$10 _every_ 2 weeks")', 'woocommerce-subscriptions'));
    foreach (range(2, 6) as $i) {
        // translators: period interval, placeholder is ordinal (eg "$10 every _2nd/3rd/4th_", etc)
        $intervals[$i] = sprintf(_x('every %s', 'period interval with ordinal number (e.g. "every 2nd"', 'woocommerce-subscriptions'), WC_Subscriptions::append_numeral_suffix($i));
    }
    $intervals = apply_filters('woocommerce_subscription_period_interval_strings', $intervals);
    if (empty($interval)) {
        return $intervals;
    } else {
        return $intervals[$interval];
    }
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:20,代码来源:wcs-time-functions.php

示例2: get_subscription_period_interval_strings

 /**
  * Return an i18n'ified associative array of all possible subscription periods.
  *
  * @since 1.0
  */
 public static function get_subscription_period_interval_strings($interval = '')
 {
     $intervals = array(1 => __('per', WC_Subscriptions::$text_domain));
     foreach (range(2, 6) as $i) {
         $intervals[$i] = sprintf(__('every %s', WC_Subscriptions::$text_domain), WC_Subscriptions::append_numeral_suffix($i));
     }
     $intervals = apply_filters('woocommerce_subscription_period_interval_strings', $intervals);
     if (empty($interval)) {
         return $intervals;
     } else {
         return $intervals[$interval];
     }
 }
开发者ID:bulats,项目名称:chef,代码行数:18,代码来源:class-wc-subscriptions-manager.php

示例3: get_price_string


//.........这里部分代码省略.........
                 $price = $include['price'];
             } else {
                 $price = $product->get_price_including_tax();
             }
             if (true === $include['sign_up_fee']) {
                 $sign_up_fee = $product->get_sign_up_fee_including_tax();
             }
         }
     } else {
         if (isset($include['price'])) {
             $price = $include['price'];
         } else {
             $price = woocommerce_price($base_price);
         }
     }
     $price .= ' <span class="subscription-details">';
     $billing_interval = self::get_interval($product);
     $billing_period = self::get_period($product);
     $subscription_length = self::get_length($product);
     $trial_length = self::get_trial_length($product);
     $trial_period = self::get_trial_period($product);
     if (is_numeric($sign_up_fee)) {
         $sign_up_fee = woocommerce_price($sign_up_fee);
     }
     if ($include['subscription_length']) {
         $ranges = WC_Subscriptions_Manager::get_subscription_ranges($billing_period);
     }
     if ($include['subscription_length'] && $subscription_length != 0) {
         $include_length = true;
     } else {
         $include_length = false;
     }
     $subscription_string = '';
     if ($include['subscription_price'] && $include['subscription_period']) {
         // Allow extensions to not show price or billing period e.g. Name Your Price
         if ($include_length && $subscription_length == $billing_interval) {
             $subscription_string = $price;
             // Only for one billing period so show "$5 for 3 months" instead of "$5 every 3 months for 3 months"
         } elseif (WC_Subscriptions_Synchroniser::is_product_synced($product) && in_array($billing_period, array('week', 'month', 'year'))) {
             $payment_day = WC_Subscriptions_Synchroniser::get_products_payment_day($product);
             switch ($billing_period) {
                 case 'week':
                     $payment_day_of_week = WC_Subscriptions_Synchroniser::get_weekday($payment_day);
                     if (1 == $billing_interval) {
                         // e.g. $5 every Wednesday
                         $subscription_string = sprintf(__('%s every %s', 'woocommerce-subscriptions'), $price, $payment_day_of_week);
                     } else {
                         // e.g. $5 every 2 weeks on Wednesday
                         $subscription_string = sprintf(__('%s every %s on %s', 'woocommerce-subscriptions'), $price, WC_Subscriptions_Manager::get_subscription_period_strings($billing_interval, $billing_period), $payment_day_of_week);
                     }
                     break;
                 case 'month':
                     if (1 == $billing_interval) {
                         // e.g. $15 on the 15th of each month
                         if ($payment_day > 27) {
                             $subscription_string = sprintf(__('%s on the last day of each month', 'woocommerce-subscriptions'), $price);
                         } else {
                             $subscription_string = sprintf(__('%s on the %s of each month', 'woocommerce-subscriptions'), $price, WC_Subscriptions::append_numeral_suffix($payment_day));
                         }
                     } else {
                         // e.g. $15 on the 15th of every 3rd month
                         if ($payment_day > 27) {
                             $subscription_string = sprintf(__('%s on the last day of every %s month', 'woocommerce-subscriptions'), $price, WC_Subscriptions::append_numeral_suffix($billing_interval));
                         } else {
                             $subscription_string = sprintf(__('%s on the %s day of every %s month', 'woocommerce-subscriptions'), $price, WC_Subscriptions::append_numeral_suffix($payment_day), WC_Subscriptions::append_numeral_suffix($billing_interval));
                         }
                     }
                     break;
                 case 'year':
                     if (1 == $billing_interval) {
                         // e.g. $15 on March 15th each year
                         $subscription_string = sprintf(__('%s on %s %s each year', 'woocommerce-subscriptions'), $price, $wp_locale->month[$payment_day['month']], WC_Subscriptions::append_numeral_suffix($payment_day['day']));
                     } else {
                         // e.g. $15 on March 15th every 3rd year
                         $subscription_string = sprintf(__('%s on %s %s every %s year', 'woocommerce-subscriptions'), $price, $wp_locale->month[$payment_day['month']], WC_Subscriptions::append_numeral_suffix($payment_day['day']), WC_Subscriptions::append_numeral_suffix($billing_interval));
                     }
                     break;
             }
         } else {
             $subscription_string = sprintf(_n('%s / %s', ' %s every %s', $billing_interval, 'woocommerce-subscriptions'), $price, WC_Subscriptions_Manager::get_subscription_period_strings($billing_interval, $billing_period));
         }
     } elseif ($include['subscription_price']) {
         $subscription_string = $price;
     } elseif ($include['subscription_period']) {
         $subscription_string = sprintf(_n('%s', 'every %s', $billing_interval, 'woocommerce-subscriptions'), WC_Subscriptions_Manager::get_subscription_period_strings($billing_interval, $billing_period));
     }
     // Add the length to the end
     if ($include_length) {
         $subscription_string = sprintf(__('%s for %s', 'woocommerce-subscriptions'), $subscription_string, $ranges[$subscription_length]);
     }
     if ($include['trial_length'] && $trial_length != 0) {
         $trial_string = WC_Subscriptions_Manager::get_subscription_trial_period_strings($trial_length, $trial_period);
         $subscription_string = sprintf(__('%s with %s free trial', 'woocommerce-subscriptions'), $subscription_string, $trial_string);
     }
     if ($include['sign_up_fee'] && self::get_sign_up_fee($product) > 0) {
         $subscription_string = sprintf(__('%s and a %s sign-up fee', 'woocommerce-subscriptions'), $subscription_string, $sign_up_fee);
     }
     $subscription_string .= '</span>';
     return apply_filters('woocommerce_subscriptions_product_price_string', $subscription_string, $product, $include);
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:101,代码来源:class-wc-subscriptions-product.php

示例4: wcs_price_string

/**
 * Creates a subscription price string from an array of subscription details. For example, "$5 / month for 12 months".
 *
 * @param array $subscription_details A set of name => value pairs for the subscription details to include in the string. Available keys:
 *		'initial_amount': The upfront payment for the subscription, including sign up fees, as a string from the @see wc_price(). Default empty string (no initial payment)
 *		'initial_description': The word after the initial payment amount to describe the amount. Examples include "now" or "initial payment". Defaults to "up front".
 *		'recurring_amount': The amount charged per period. Default 0 (no recurring payment).
 *		'subscription_interval': How regularly the subscription payments are charged. Default 1, meaning each period e.g. per month.
 *		'subscription_period': The temporal period of the subscription. Should be one of {day|week|month|year} as used by @see wcs_get_subscription_period_strings()
 *		'subscription_length': The total number of periods the subscription should continue for. Default 0, meaning continue indefinitely.
 *		'trial_length': The total number of periods the subscription trial period should continue for.  Default 0, meaning no trial period.
 *		'trial_period': The temporal period for the subscription's trial period. Should be one of {day|week|month|year} as used by @see wcs_get_subscription_period_strings()
 * @since 2.0
 * @return string The price string with translated and billing periods included
 */
function wcs_price_string($subscription_details)
{
    global $wp_locale;
    $subscription_details = wp_parse_args($subscription_details, array('currency' => '', 'initial_amount' => '', 'initial_description' => _x('up front', 'initial payment on a subscription', 'woocommerce-subscriptions'), 'recurring_amount' => '', 'subscription_interval' => 1, 'subscription_period' => '', 'subscription_length' => 0, 'trial_length' => 0, 'trial_period' => '', 'is_synced' => false, 'synchronised_payment_day' => 0, 'display_excluding_tax_label' => false));
    $subscription_details['subscription_period'] = strtolower($subscription_details['subscription_period']);
    // Make sure prices have been through wc_price()
    if (is_numeric($subscription_details['initial_amount'])) {
        $initial_amount_string = wc_price($subscription_details['initial_amount'], array('currency' => $subscription_details['currency'], 'ex_tax_label' => $subscription_details['display_excluding_tax_label']));
    } else {
        $initial_amount_string = $subscription_details['initial_amount'];
    }
    if (is_numeric($subscription_details['recurring_amount'])) {
        $recurring_amount_string = wc_price($subscription_details['recurring_amount'], array('currency' => $subscription_details['currency'], 'ex_tax_label' => $subscription_details['display_excluding_tax_label']));
    } else {
        $recurring_amount_string = $subscription_details['recurring_amount'];
    }
    $subscription_period_string = wcs_get_subscription_period_strings($subscription_details['subscription_interval'], $subscription_details['subscription_period']);
    $subscription_ranges = wcs_get_subscription_ranges();
    if ($subscription_details['subscription_length'] > 0 && $subscription_details['subscription_length'] == $subscription_details['subscription_interval']) {
        if (!empty($subscription_details['initial_amount'])) {
            if ($subscription_details['subscription_interval'] == $subscription_details['subscription_length'] && 0 == $subscription_details['trial_length']) {
                $subscription_string = $initial_amount_string;
            } else {
                // translators: 1$: initial amount, 2$: initial description (e.g. "up front"), 3$: recurring amount string (e.g. "£10 / month" )
                $subscription_string = sprintf(__('%1$s %2$s then %3$s', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string);
            }
        } else {
            $subscription_string = $recurring_amount_string;
        }
    } elseif (true === $subscription_details['is_synced'] && in_array($subscription_details['subscription_period'], array('week', 'month', 'year'))) {
        // Verbosity is important here to enable translation
        $payment_day = $subscription_details['synchronised_payment_day'];
        switch ($subscription_details['subscription_period']) {
            case 'week':
                $payment_day_of_week = WC_Subscriptions_Synchroniser::get_weekday($payment_day);
                if (1 == $subscription_details['subscription_interval']) {
                    if (!empty($subscription_details['initial_amount'])) {
                        // translators: 1$: initial amount, 2$: initial description (e.g. "up front"), 3$: recurring amount string, 4$: payment day of the week (e.g. "$15 up front, then $10 every Wednesday")
                        $subscription_string = sprintf(__('%1$s %2$s then %3$s every %4$s', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, $payment_day_of_week);
                    } else {
                        // translators: 1$: recurring amount string, 2$: day of the week (e.g. "$10 every Wednesday")
                        $subscription_string = sprintf(__('%1$s every %2$s', 'woocommerce-subscriptions'), $recurring_amount_string, $payment_day_of_week);
                    }
                } else {
                    // e.g. $5 every 2 weeks on Wednesday
                    if (!empty($subscription_details['initial_amount'])) {
                        // translators: 1$: initial amount, 2$: initial description (e.g. "up front" ), 3$: recurring amount, 4$: interval (e.g. "2nd week"), 5$: day of the week (e.g. "Thursday"); (e.g. "$10 up front, then $20 every 2nd week on Wednesday")
                        $subscription_string = sprintf(__('%1$s %2$s then %3$s every %4%s on %5$s', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, wcs_get_subscription_period_strings($subscription_details['subscription_interval'], $subscription_details['subscription_period']), $payment_day_of_week);
                    } else {
                        // translators: 1$: recurring amount string, 2$: interval (e.g. "2nd week"), 3$: day of the week (e.g. "Thursday"); (e.g. "$10 every 2nd week on Wednesday")
                        $subscription_string = sprintf(__('%1$s every %2$s on %3$s', 'woocommerce-subscriptions'), $recurring_amount_string, wcs_get_subscription_period_strings($subscription_details['subscription_interval'], $subscription_details['subscription_period']), $payment_day_of_week);
                    }
                }
                break;
            case 'month':
                if (1 == $subscription_details['subscription_interval']) {
                    // e.g. $15 on the 15th of each month
                    if (!empty($subscription_details['initial_amount'])) {
                        if ($payment_day > 27) {
                            // translators: 1$: initial amount, 2$: initial description (e.g. "up front"), 3$: recurring amount; (e.g. "$10 up front then $30 on the last day of each month")
                            $subscription_string = sprintf(__('%1$s %2$s then %3$s on the last day of each month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string);
                        } else {
                            // translators: 1$: initial amount, 2$: initial description (e.g. "up front"), 3$: recurring amount, 4$: day of the month (e.g. "23rd"); (e.g. "$10 up front then $40 on the 23rd of each month")
                            $subscription_string = sprintf(__('%1$s %2$s then %3$s on the %4$s of each month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($payment_day));
                        }
                    } else {
                        if ($payment_day > 27) {
                            // translators: placeholder is recurring amount
                            $subscription_string = sprintf(__('%s on the last day of each month', 'woocommerce-subscriptions'), $recurring_amount_string);
                        } else {
                            // translators: 1$: recurring amount, 2$: day of the month (e.g. "23rd")
                            $subscription_string = sprintf(__('%1$s on the %2$s of each month', 'woocommerce-subscriptions'), $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($payment_day));
                        }
                    }
                } else {
                    // e.g. $15 on the 15th of every 3rd month
                    if (!empty($subscription_details['initial_amount'])) {
                        if ($payment_day > 27) {
                            // translators: 1$: initial amount, 2$: initial description (e.g. "up front"), 3$: recurring amount, 4$: interval (e.g. "3rd")
                            $subscription_string = sprintf(__('%1$s %2$s then %3$s on the last day of every %4$s month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($subscription_details['subscription_interval']));
                        } else {
                            // translators: 1$: initial amount, 2$: initial description (e.g. "up front"), 3$: recurring amount, 4$: day of the month (e.g. "23rd"), 5$: interval (e.g. "3rd")
                            $subscription_string = sprintf(__('%1$s %2$s then %3$s on the %4$s day of every %5$s month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($payment_day), WC_Subscriptions::append_numeral_suffix($subscription_details['subscription_interval']));
                        }
                    } else {
//.........这里部分代码省略.........
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:101,代码来源:wcs-formatting-functions.php

示例5: get_billing_period_ranges

 /**
  * Return an i18n'ified associative array of all possible subscription periods.
  *
  * @since 1.5
  */
 public static function get_billing_period_ranges($billing_period = '')
 {
     global $wp_locale;
     if (empty(self::$billing_period_ranges)) {
         foreach (array('week', 'month', 'year') as $key) {
             self::$billing_period_ranges[$key][0] = __('Do not synchronise', 'woocommerce-subscriptions');
         }
         // Week
         $weekdays = array_merge($wp_locale->weekday, array($wp_locale->weekday[0]));
         unset($weekdays[0]);
         foreach ($weekdays as $i => $weekly_billing_period) {
             self::$billing_period_ranges['week'][$i] = sprintf(__('%s each week', 'woocommerce-subscriptions'), $weekly_billing_period);
         }
         // Month
         foreach (range(1, 27) as $i) {
             self::$billing_period_ranges['month'][$i] = sprintf(__('%s day of the month', 'woocommerce-subscriptions'), WC_Subscriptions::append_numeral_suffix($i));
         }
         self::$billing_period_ranges['month'][28] = __('Last day of the month', 'woocommerce-subscriptions');
         self::$billing_period_ranges = apply_filters('woocommerce_subscription_billing_period_ranges', self::$billing_period_ranges);
     }
     if (empty($billing_period)) {
         return self::$billing_period_ranges;
     } elseif (isset(self::$billing_period_ranges[$billing_period])) {
         return self::$billing_period_ranges[$billing_period];
     } else {
         return array();
     }
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:33,代码来源:class-wc-subscriptions-synchroniser.php

示例6: get_subscription_price_string

 /**
  * Creates a subscription price string from an array of subscription details. For example, ""$5 / month for 12 months".
  *
  * @param array $subscription_details A set of name => value pairs for the subscription details to include in the string. Available keys:
  *		'initial_amount': The upfront payment for the subscription, including sign up fees, as a string from the @see woocommerce_price(). Default empty string (no initial payment)
  *		'initial_description': The word after the initial payment amount to describe the amount. Examples include "now" or "initial payment". Defaults to "up front".
  *		'recurring_amount': The amount charged per period. Default 0 (no recurring payment).
  *		'subscription_interval': How regularly the subscription payments are charged. Default 1, meaning each period e.g. per month.
  *		'subscription_period': The temporal period of the subscription. Should be one of {day|week|month|year} as used by @see self::get_subscription_period_strings()
  *		'subscription_length': The total number of periods the subscription should continue for. Default 0, meaning continue indefinitely.
  *		'trial_length': The total number of periods the subscription trial period should continue for.  Default 0, meaning no trial period.
  *		'trial_period': The temporal period for the subscription's trial period. Should be one of {day|week|month|year} as used by @see self::get_subscription_period_strings()
  * @since 1.2
  * @return float $proportion A proportion of the total (e.g. 0.5 is half of the total)
  */
 public static function get_subscription_price_string($subscription_details)
 {
     global $wp_locale;
     $subscription_details = wp_parse_args($subscription_details, array('currency' => '', 'initial_amount' => '', 'initial_description' => __('up front', 'woocommerce-subscriptions'), 'recurring_amount' => '', 'subscription_interval' => 1, 'subscription_period' => '', 'subscription_length' => 0, 'trial_length' => 0, 'trial_period' => '', 'is_synced' => false, 'synchronised_payment_day' => 0));
     $subscription_details['subscription_period'] = strtolower($subscription_details['subscription_period']);
     // Make sure prices have been through woocommerce_price()
     $initial_amount_string = is_numeric($subscription_details['initial_amount']) ? woocommerce_price($subscription_details['initial_amount'], array('currency' => $subscription_details['currency'])) : $subscription_details['initial_amount'];
     $recurring_amount_string = is_numeric($subscription_details['recurring_amount']) ? woocommerce_price($subscription_details['recurring_amount'], array('currency' => $subscription_details['currency'])) : $subscription_details['recurring_amount'];
     $subscription_period_string = self::get_subscription_period_strings($subscription_details['subscription_interval'], $subscription_details['subscription_period']);
     $subscription_ranges = self::get_subscription_ranges();
     if ($subscription_details['subscription_length'] > 0 && $subscription_details['subscription_length'] == $subscription_details['subscription_interval']) {
         if (!empty($subscription_details['initial_amount'])) {
             if ($subscription_details['subscription_length'] == $subscription_details['subscription_interval'] && $subscription_details['trial_length'] == 0) {
                 $subscription_string = $initial_amount_string;
             } else {
                 $subscription_string = sprintf(__('%s %s then %s', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string);
             }
         } else {
             $subscription_string = $recurring_amount_string;
         }
     } elseif (true === $subscription_details['is_synced'] && in_array($subscription_details['subscription_period'], array('week', 'month', 'year'))) {
         // Verbosity is important here to enable translation
         $payment_day = $subscription_details['synchronised_payment_day'];
         switch ($subscription_details['subscription_period']) {
             case 'week':
                 $payment_day_of_week = WC_Subscriptions_Synchroniser::get_weekday($payment_day);
                 if (1 == $subscription_details['subscription_interval']) {
                     // e.g. $5 every Wednesday
                     if (!empty($subscription_details['initial_amount'])) {
                         $subscription_string = sprintf(__('%s %s then %s every %s', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, $payment_day_of_week);
                     } else {
                         $subscription_string = sprintf(__('%s every %s', 'woocommerce-subscriptions'), $recurring_amount_string, $payment_day_of_week);
                     }
                 } else {
                     // e.g. $5 every 2 weeks on Wednesday
                     if (!empty($subscription_details['initial_amount'])) {
                         $subscription_string = sprintf(__('%s %s then %s every %s on %s', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, WC_Subscriptions_Manager::get_subscription_period_strings($subscription_details['subscription_interval'], $subscription_details['subscription_period']), $payment_day_of_week);
                     } else {
                         $subscription_string = sprintf(__('%s every %s on %s', 'woocommerce-subscriptions'), $recurring_amount_string, WC_Subscriptions_Manager::get_subscription_period_strings($subscription_details['subscription_interval'], $subscription_details['subscription_period']), $payment_day_of_week);
                     }
                 }
                 break;
             case 'month':
                 if (1 == $subscription_details['subscription_interval']) {
                     // e.g. $15 on the 15th of each month
                     if (!empty($subscription_details['initial_amount'])) {
                         if ($payment_day > 27) {
                             $subscription_string = sprintf(__('%s %s then %s on the last day of each month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string);
                         } else {
                             $subscription_string = sprintf(__('%s %s then %s on the %s of each month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($payment_day));
                         }
                     } else {
                         if ($payment_day > 27) {
                             $subscription_string = sprintf(__('%s on the last day of each month', 'woocommerce-subscriptions'), $recurring_amount_string);
                         } else {
                             $subscription_string = sprintf(__('%s on the %s of each month', 'woocommerce-subscriptions'), $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($payment_day));
                         }
                     }
                 } else {
                     // e.g. $15 on the 15th of every 3rd month
                     if (!empty($subscription_details['initial_amount'])) {
                         if ($payment_day > 27) {
                             $subscription_string = sprintf(__('%s %s then %s on the last day of every %s month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($subscription_details['subscription_interval']));
                         } else {
                             $subscription_string = sprintf(__('%s %s then %s on the %s day of every %s month', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($payment_day), WC_Subscriptions::append_numeral_suffix($subscription_details['subscription_interval']));
                         }
                     } else {
                         if ($payment_day > 27) {
                             $subscription_string = sprintf(__('%s on the last day of every %s month', 'woocommerce-subscriptions'), $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($subscription_details['subscription_interval']));
                         } else {
                             $subscription_string = sprintf(__('%s on the %s day of every %s month', 'woocommerce-subscriptions'), $recurring_amount_string, WC_Subscriptions::append_numeral_suffix($payment_day), WC_Subscriptions::append_numeral_suffix($subscription_details['subscription_interval']));
                         }
                     }
                 }
                 break;
             case 'year':
                 if (1 == $subscription_details['subscription_interval']) {
                     // e.g. $15 on March 15th each year
                     if (!empty($subscription_details['initial_amount'])) {
                         $subscription_string = sprintf(__('%s %s then %s on %s %s each year', 'woocommerce-subscriptions'), $initial_amount_string, $subscription_details['initial_description'], $recurring_amount_string, $wp_locale->month[$payment_day['month']], WC_Subscriptions::append_numeral_suffix($payment_day['day']));
                     } else {
                         $subscription_string = sprintf(__('%s on %s %s each year', 'woocommerce-subscriptions'), $recurring_amount_string, $wp_locale->month[$payment_day['month']], WC_Subscriptions::append_numeral_suffix($payment_day['day']));
                     }
                 } else {
                     // e.g. $15 on March 15th every 3rd year
//.........这里部分代码省略.........
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:101,代码来源:class-wc-subscriptions-manager.php

示例7: get_price_string


//.........这里部分代码省略.........
         }
     } else {
         if (isset($include['price'])) {
             $price = $include['price'];
         } else {
             $price = wc_price($base_price);
         }
     }
     $price .= ' <span class="subscription-details">';
     $billing_interval = self::get_interval($product);
     $billing_period = self::get_period($product);
     $subscription_length = self::get_length($product);
     $trial_length = self::get_trial_length($product);
     $trial_period = self::get_trial_period($product);
     if (is_numeric($sign_up_fee)) {
         $sign_up_fee = wc_price($sign_up_fee);
     }
     if ($include['subscription_length']) {
         $ranges = wcs_get_subscription_ranges($billing_period);
     }
     if ($include['subscription_length'] && 0 != $subscription_length) {
         $include_length = true;
     } else {
         $include_length = false;
     }
     $subscription_string = '';
     if ($include['subscription_price'] && $include['subscription_period']) {
         // Allow extensions to not show price or billing period e.g. Name Your Price
         if ($include_length && $subscription_length == $billing_interval) {
             $subscription_string = $price;
             // Only for one billing period so show "$5 for 3 months" instead of "$5 every 3 months for 3 months"
         } elseif (WC_Subscriptions_Synchroniser::is_product_synced($product) && in_array($billing_period, array('week', 'month', 'year'))) {
             $payment_day = WC_Subscriptions_Synchroniser::get_products_payment_day($product);
             switch ($billing_period) {
                 case 'week':
                     $payment_day_of_week = WC_Subscriptions_Synchroniser::get_weekday($payment_day);
                     if (1 == $billing_interval) {
                         // translators: 1$: recurring amount string, 2$: day of the week (e.g. "$10 every Wednesday")
                         $subscription_string = sprintf(__('%1$s every %2$s', 'woocommerce-subscriptions'), $price, $payment_day_of_week);
                     } else {
                         // translators: 1$: recurring amount string, 2$: period, 3$: day of the week (e.g. "$10 every 2nd week on Wednesday")
                         $subscription_string = sprintf(__('%1$s every %2$s on %3$s', 'woocommerce-subscriptions'), $price, wcs_get_subscription_period_strings($billing_interval, $billing_period), $payment_day_of_week);
                     }
                     break;
                 case 'month':
                     if (1 == $billing_interval) {
                         if ($payment_day > 27) {
                             // translators: placeholder is recurring amount
                             $subscription_string = sprintf(__('%s on the last day of each month', 'woocommerce-subscriptions'), $price);
                         } else {
                             // translators: 1$: recurring amount, 2$: day of the month (e.g. "23rd") (e.g. "$5 every 23rd of each month")
                             $subscription_string = sprintf(__('%1$s on the %2$s of each month', 'woocommerce-subscriptions'), $price, WC_Subscriptions::append_numeral_suffix($payment_day));
                         }
                     } else {
                         if ($payment_day > 27) {
                             // translators: 1$: recurring amount, 2$: interval (e.g. "3rd") (e.g. "$10 on the last day of every 3rd month")
                             $subscription_string = sprintf(__('%1$s on the last day of every %2$s month', 'woocommerce-subscriptions'), $price, WC_Subscriptions::append_numeral_suffix($billing_interval));
                         } else {
                             // translators: 1$: <price> on the, 2$: <date> day of every, 3$: <interval> month (e.g. "$10 on the 23rd day of every 2nd month")
                             $subscription_string = sprintf(__('%1$s on the %2$s day of every %3$s month', 'woocommerce-subscriptions'), $price, WC_Subscriptions::append_numeral_suffix($payment_day), WC_Subscriptions::append_numeral_suffix($billing_interval));
                         }
                     }
                     break;
                 case 'year':
                     if (1 == $billing_interval) {
                         // translators: 1$: <price> on, 2$: <date>, 3$: <month> each year (e.g. "$15 on March 15th each year")
                         $subscription_string = sprintf(__('%1$s on %2$s %3$s each year', 'woocommerce-subscriptions'), $price, $wp_locale->month[$payment_day['month']], WC_Subscriptions::append_numeral_suffix($payment_day['day']));
                     } else {
                         // translators: 1$: recurring amount, 2$: month (e.g. "March"), 3$: day of the month (e.g. "23rd") (e.g. "$15 on March 15th every 3rd year")
                         $subscription_string = sprintf(__('%1$s on %2$s %3$s every %4$s year', 'woocommerce-subscriptions'), $price, $wp_locale->month[$payment_day['month']], WC_Subscriptions::append_numeral_suffix($payment_day['day']), WC_Subscriptions::append_numeral_suffix($billing_interval));
                     }
                     break;
             }
         } else {
             // translators: 1$: recurring amount, 2$: subscription period (e.g. "month" or "3 months") (e.g. "$15 / month" or "$15 every 2nd month")
             $subscription_string = sprintf(_n('%1$s / %2$s', ' %1$s every %2$s', $billing_interval, 'woocommerce-subscriptions'), $price, wcs_get_subscription_period_strings($billing_interval, $billing_period));
         }
     } elseif ($include['subscription_price']) {
         $subscription_string = $price;
     } elseif ($include['subscription_period']) {
         // translators: billing period (e.g. "every week")
         $subscription_string = sprintf(__('every %s', 'woocommerce-subscriptions'), wcs_get_subscription_period_strings($billing_interval, $billing_period));
     }
     // Add the length to the end
     if ($include_length) {
         // translators: 1$: subscription string (e.g. "$10 up front then $5 on March 23rd every 3rd year"), 2$: length (e.g. "4 years")
         $subscription_string = sprintf(__('%1$s for %2$s', 'woocommerce-subscriptions'), $subscription_string, $ranges[$subscription_length]);
     }
     if ($include['trial_length'] && 0 != $trial_length) {
         $trial_string = wcs_get_subscription_trial_period_strings($trial_length, $trial_period);
         // translators: 1$: subscription string (e.g. "$15 on March 15th every 3 years for 6 years"), 2$: trial length (e.g.: "with 4 months free trial")
         $subscription_string = sprintf(__('%1$s with %2$s free trial', 'woocommerce-subscriptions'), $subscription_string, $trial_string);
     }
     if ($include['sign_up_fee'] && self::get_sign_up_fee($product) > 0) {
         // translators: 1$: subscription string (e.g. "$15 on March 15th every 3 years for 6 years with 2 months free trial"), 2$: signup fee price (e.g. "and a $30 sign-up fee")
         $subscription_string = sprintf(__('%1$s and a %2$s sign-up fee', 'woocommerce-subscriptions'), $subscription_string, $sign_up_fee);
     }
     $subscription_string .= '</span>';
     return apply_filters('woocommerce_subscriptions_product_price_string', $subscription_string, $product, $include);
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:101,代码来源:class-wc-subscriptions-product.php


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