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


PHP WC_Subscriptions_Product::get_first_renewal_payment_time方法代码示例

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


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

示例1: get_recurring_cart_key

 /**
  * Construct a cart key based on the billing schedule of a subscription product.
  *
  * Subscriptions groups products by billing schedule when calculating cart totals, so that shipping and other "per order" amounts
  * can be calculated for each group of items for each renewal. This method constructs a cart key based on the billing schedule
  * to allow products on the same billing schedule to be grouped together - free trials and synchronisation is accounted for by
  * using the first renewal date (if any) for the susbcription.
  *
  * @since 2.0
  */
 public static function get_recurring_cart_key($cart_item, $renewal_time = '')
 {
     $cart_key = '';
     $product = $cart_item['data'];
     $product_id = !empty($product->variation_id) ? $product->variation_id : $product->id;
     $renewal_time = !empty($renewal_time) ? $renewal_time : WC_Subscriptions_Product::get_first_renewal_payment_time($product_id);
     $interval = WC_Subscriptions_Product::get_interval($product);
     $period = WC_Subscriptions_Product::get_period($product);
     $length = WC_Subscriptions_Product::get_length($product);
     $trial_period = WC_Subscriptions_Product::get_trial_period($product);
     $trial_length = WC_Subscriptions_Product::get_trial_length($product);
     if ($renewal_time > 0) {
         $cart_key .= date('Y_m_d_', $renewal_time);
     }
     // First start with the billing interval and period
     switch ($interval) {
         case 1:
             if ('day' == $period) {
                 $cart_key .= 'daily';
                 // always gotta be one exception
             } else {
                 $cart_key .= sprintf('%sly', $period);
             }
             break;
         case 2:
             $cart_key .= sprintf('every_2nd_%s', $period);
             break;
         case 3:
             $cart_key .= sprintf('every_3rd_%s', $period);
             // or sometimes two exceptions it would seem
             break;
         default:
             $cart_key .= sprintf('every_%dth_%s', $interval, $period);
             break;
     }
     if ($length > 0) {
         $cart_key .= '_for_';
         $cart_key .= sprintf('%d_%s', $length, $period);
         if ($length > 1) {
             $cart_key .= 's';
         }
     }
     if ($trial_length > 0) {
         $cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period);
     }
     return apply_filters('woocommerce_subscriptions_recurring_cart_key', $cart_key, $cart_item);
 }
开发者ID:slavic18,项目名称:cats,代码行数:57,代码来源:class-wc-subscriptions-cart.php


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