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


PHP WC_Subscriptions_Manager::get_subscription_trial_lengths方法代码示例

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


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

示例1: get_order_subscription_string

 /**
  * Creates a string representation of the subscription period/term for each item in the cart
  * 
  * @param $price float (optional) The price to display in the subscription. Defaults to empty, which returns just the period & duration components of the string.
  * @since 1.0
  */
 public static function get_order_subscription_string($order, $price = '', $sign_up_fee = '')
 {
     if (count($order->get_items()) == 1) {
         $subscription_period = self::get_subscription_period($order);
         $subscription_length = self::get_subscription_length($order);
         $subscription_interval = self::get_subscription_interval($order);
         $subscription_trial_length = self::get_subscription_trial_length($order);
         $subscription_string = sprintf(_n(' %s / %s', ' %s every %s', $subscription_interval, WC_Subscriptions::$text_domain), $price, WC_Subscriptions_Manager::get_subscription_period_strings($subscription_interval, strtolower($subscription_period)));
         if ($subscription_length) {
             $ranges = WC_Subscriptions_Manager::get_subscription_ranges($subscription_period);
             $subscription_string = sprintf(__('%s for %s', WC_Subscriptions::$text_domain), $subscription_string, $ranges[$subscription_length]);
         }
         if ($subscription_trial_length > 0) {
             $trial_lengths = WC_Subscriptions_Manager::get_subscription_trial_lengths($subscription_period);
             $subscription_string = sprintf(__('%s with %s free trial', WC_Subscriptions::$text_domain), $subscription_string, $trial_lengths[$subscription_trial_length]);
         }
         $sign_up_fee = !empty($sign_up_fee) ? $sign_up_fee : self::get_meta($order, '_sign_up_fee_total');
         if ($sign_up_fee > 0) {
             if (self::is_renewal($order)) {
                 $subscription_string = sprintf(__('%s with a %s initial payment', WC_Subscriptions::$text_domain), $subscription_string, woocommerce_price($sign_up_fee));
             } else {
                 $subscription_string = sprintf(__('%s with a %s sign-up fee', WC_Subscriptions::$text_domain), $subscription_string, woocommerce_price($sign_up_fee));
             }
         }
     } else {
         $subscription_string = __('Multiple Subscriptions', WC_Subscriptions::$text_domain);
     }
     return $subscription_string;
 }
开发者ID:picassentviu,项目名称:AMMPro,代码行数:35,代码来源:class-wc-subscriptions-order.php

示例2: enqueue_styles_scripts

 /**
  * Adds all necessary admin styles.
  * 
  * @param array Array of Product types & their labels, excluding the Subscription product type.
  * @return array Array of Product types & their labels, including the Subscription product type.
  * @since 1.0
  */
 public static function enqueue_styles_scripts()
 {
     global $woocommerce, $pagenow, $post;
     // Get admin screen id
     $screen = get_current_screen();
     if (in_array($screen->id, array('product', 'edit-shop_order', 'shop_order'))) {
         $dependencies = array('jquery');
         if ($screen->id == 'product') {
             $dependencies[] = 'woocommerce_writepanel';
             $script_params = array('productType' => WC_Subscriptions::$name, 'trialLengths' => WC_Subscriptions_Manager::get_subscription_trial_lengths(), 'subscriptionLengths' => WC_Subscriptions_Manager::get_subscription_ranges());
         } else {
             if ($screen->id == 'edit-shop_order') {
                 $script_params = array('bulkTrashWarning' => __("You are about to trash one or more orders which contain a subscription.\n\nTrashing the orders will also trash the subscriptions purchased with these orders.", WC_Subscriptions::$text_domain));
             } else {
                 if ($screen->id == 'shop_order') {
                     $script_params = array('bulkTrashWarning' => __('Trashing this order will also trash the subscription purchased with the order.', WC_Subscriptions::$text_domain));
                 }
             }
         }
         wp_enqueue_script('woocommerce_subscriptions_admin', plugin_dir_url(WC_Subscriptions::$plugin_file) . 'js/admin.js', $dependencies);
         wp_localize_script('woocommerce_subscriptions_admin', 'WCSubscriptions', apply_filters('woocommerce_subscriptions_admin_script_parameters', $script_params));
         // Maybe add the pointers for first timers
         if (isset($_GET['subscription_pointers']) && self::show_user_pointers()) {
             $dependencies[] = 'wp-pointer';
             $pointer_script_params = array('typePointerContent' => sprintf(__('%sChoose Subscription%sThe WooCommerce Subscriptions extension adds a new %sSubscription%s product type.%s', WC_Subscriptions::$text_domain), '<h3>', '</h3><p>', '<em>', '</em>', '</p>'), 'pricePointerContent' => sprintf(__('%sSet a Price%sSubscription prices are a little different to product prices. You also have to set a billing period and length for a subscription.%s', WC_Subscriptions::$text_domain), '<h3>', '</h3><p>', '</p>'));
             wp_enqueue_script('woocommerce_subscriptions_admin_pointers', plugin_dir_url(WC_Subscriptions::$plugin_file) . 'js/admin-pointers.js', $dependencies);
             wp_localize_script('woocommerce_subscriptions_admin_pointers', 'WCSPointers', apply_filters('woocommerce_subscriptions_admin_pointer_script_parameters', $pointer_script_params));
             wp_enqueue_style('wp-pointer');
         }
     }
     // Maybe add the admin notice
     if (get_transient(WC_Subscriptions::$activation_transient) == true) {
         wp_enqueue_style('woocommerce-activation', plugins_url('/assets/css/activation.css', self::get_woocommerce_plugin_dir_file()));
         add_action('admin_notices', __CLASS__ . '::admin_installed_notice');
         delete_transient(WC_Subscriptions::$activation_transient);
     }
     wp_enqueue_style('woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css');
     wp_enqueue_style('woocommerce_subscriptions_admin', plugin_dir_url(WC_Subscriptions::$plugin_file) . 'css/admin.css');
 }
开发者ID:picassentviu,项目名称:AMMPro,代码行数:46,代码来源:class-wc-subscriptions-admin.php

示例3: get_price_string

 /**
  * Returns a string representing the details of the subscription. 
  * 
  * For example "$20 per Month for 3 Months with a $10 sign-up fee".
  * 
  * @param $product WC_Product | Int A WC_Product object or ID of a WC_Product.
  * @param $inclusions array An associative array of flags to indicate how to calculate the price and what to include, values:
  *			'tax_calculation'     => false to ignore tax, 'include_tax' or 'exclude_tax' To indicate that tax should be added or excluded respectively
  *			'subscription_length' => true to include subscription's length (default) or false to exclude it
  *			'sign_up_fee'         => true to include subscription's sign up fee (default) or false to exclude it
  *			'price'               => string a price to short-circuit the price calculations and use in a string for the product
  * @since 1.0
  */
 public static function get_price_string($product, $include = array())
 {
     if (!is_object($product)) {
         $product = new WC_Product($product);
     }
     // Shouldn't matter if product is variation as all we need is the product_type
     if (!self::is_subscription($product)) {
         return;
     }
     $include = wp_parse_args($include, array('tax_calculation' => false, 'subscription_length' => true, 'sign_up_fee' => true, 'trial_length' => true));
     if ($include['tax_calculation'] != false) {
         if ($include['tax_calculation'] == 'exclude_tax') {
             // Subtract Tax
             $tax_per_period = self::calculate_tax_for_subscription($product->product_custom_fields['_subscription_price'][0], $product);
             if (isset($include['price'])) {
                 $price = $include['price'];
             } else {
                 $price = woocommerce_price($product->product_custom_fields['_subscription_price'][0] - $tax_per_period);
             }
             if ($product->product_custom_fields['_subscription_sign_up_fee'][0] > 0) {
                 $sign_up_tax = self::calculate_tax_for_subscription($product->product_custom_fields['_subscription_sign_up_fee'][0], $product);
                 $sign_up_fee = $product->product_custom_fields['_subscription_sign_up_fee'][0] - $sign_up_tax;
             }
         } else {
             // Add Tax
             $tax_per_period = self::calculate_tax_for_subscription($product->product_custom_fields['_subscription_price'][0], $product, true);
             if (isset($include['price'])) {
                 $price = $include['price'];
             } else {
                 $price = woocommerce_price($product->product_custom_fields['_subscription_price'][0] + $tax_per_period);
             }
             if ($product->product_custom_fields['_subscription_sign_up_fee'][0] > 0) {
                 $sign_up_tax = self::calculate_tax_for_subscription($product->product_custom_fields['_subscription_sign_up_fee'][0], $product, true);
                 $sign_up_fee = $product->product_custom_fields['_subscription_sign_up_fee'][0] - $sign_up_tax;
             }
         }
     } else {
         if (isset($include['price'])) {
             $price = $include['price'];
         } else {
             $price = woocommerce_price($product->product_custom_fields['_subscription_price'][0]);
         }
         if ($product->product_custom_fields['_subscription_sign_up_fee'][0] > 0) {
             $sign_up_fee = $product->product_custom_fields['_subscription_sign_up_fee'][0];
         }
     }
     $subscription_string = sprintf(_n(' %s / %s', ' %s every %s', self::get_interval($product), WC_Subscriptions::$text_domain), $price, WC_Subscriptions_Manager::get_subscription_period_strings(self::get_interval($product), self::get_period($product)));
     if ($include['subscription_length'] && isset($product->product_custom_fields['_subscription_length'][0]) && $product->product_custom_fields['_subscription_length'][0] != 0) {
         $ranges = WC_Subscriptions_Manager::get_subscription_ranges(self::get_period($product));
         $subscription_string = sprintf(__('%s for %s', WC_Subscriptions::$text_domain), $subscription_string, $ranges[$product->product_custom_fields['_subscription_length'][0]]);
     }
     if ($include['trial_length'] && isset($product->product_custom_fields['_subscription_trial_length'][0]) && $product->product_custom_fields['_subscription_trial_length'][0] != 0) {
         $trial_lengths = WC_Subscriptions_Manager::get_subscription_trial_lengths(self::get_period($product));
         $subscription_string = sprintf(__('%s with %s free trial', WC_Subscriptions::$text_domain), $subscription_string, $trial_lengths[$product->product_custom_fields['_subscription_trial_length'][0]]);
     }
     if ($include['sign_up_fee'] && $product->product_custom_fields['_subscription_sign_up_fee'][0] > 0) {
         $subscription_string = sprintf(__('%s and a %s sign-up fee', WC_Subscriptions::$text_domain), $subscription_string, woocommerce_price($sign_up_fee));
     }
     return apply_filters('woocommerce_subscription_price_string', $subscription_string, $product);
 }
开发者ID:picassentviu,项目名称:AMMPro,代码行数:73,代码来源:class-wc-subscriptions-product.php

示例4: get_cart_subscription_string

 /**
  * Creates a string representation of the subscription period/term for each item in the cart
  * 
  * @param $price_string float (optional) The price to display in the subscription. Defaults to empty, which returns just the period & duration components of the string.
  * @param $include array (optional) Array of flags to determine what is included in the price. Options:
  * 			'length' Include the length of the subscription.
  * 			'sign_up_fee' Include the sign-up fee for the subscription.
  * 			'exclude_tax' Remove tax from the price (and other prices to include in the string, like sign-up fee)
  * @since 1.0
  */
 public static function get_cart_subscription_string($subscription_price, $sign_up_fee = 0)
 {
     global $woocommerce;
     if (strpos($subscription_price, $woocommerce->countries->inc_tax_or_vat()) !== false) {
         $subscription_price = str_replace($woocommerce->countries->inc_tax_or_vat(), '', $subscription_price);
     }
     if (strpos($subscription_price, $woocommerce->countries->ex_tax_or_vat()) !== false) {
         $subscription_price = str_replace($woocommerce->countries->ex_tax_or_vat(), '', $subscription_price);
     }
     $subscription_interval = self::get_cart_subscription_interval();
     $subscription_string = sprintf(_n(' %s / %s', ' %s every %s', $subscription_interval, WC_Subscriptions::$text_domain), $subscription_price, WC_Subscriptions_Manager::get_subscription_period_strings($subscription_interval, strtolower(self::get_cart_subscription_period())));
     if (self::get_cart_subscription_length()) {
         $ranges = WC_Subscriptions_Manager::get_subscription_ranges(self::get_cart_subscription_period());
         $subscription_string = sprintf(__('%s for %s', WC_Subscriptions::$text_domain), $subscription_string, $ranges[self::get_cart_subscription_length()]);
     }
     if (self::get_cart_subscription_trial_length()) {
         $trial_lengths = WC_Subscriptions_Manager::get_subscription_trial_lengths(self::get_cart_subscription_period());
         $subscription_string = sprintf(__('%s with %s free trial', WC_Subscriptions::$text_domain), $subscription_string, $trial_lengths[self::get_cart_subscription_trial_length()]);
     }
     if ($sign_up_fee > 0) {
         $subscription_string = sprintf(__('%s and a %s sign-up fee', WC_Subscriptions::$text_domain), $subscription_string, woocommerce_price($sign_up_fee));
     }
     return $subscription_string;
 }
开发者ID:picassentviu,项目名称:AMMPro,代码行数:34,代码来源:class-wc-subscriptions-cart.php


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