當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。