@@ 484-525 (lines=42) @@ | ||
481 | * @param array $atts |
|
482 | * @return string |
|
483 | */ |
|
484 | public static function get_subscription_period_interval( $atts ) { |
|
485 | global $wpdb, $post; |
|
486 | ||
487 | $defaults = shortcode_atts( array( |
|
488 | 'id' => '', |
|
489 | 'sku' => '', |
|
490 | ), $atts ); |
|
491 | ||
492 | $atts = wp_parse_args( $atts, $defaults ); |
|
493 | ||
494 | if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
495 | $product_data = wc_get_product( $atts['id'] ); |
|
496 | } elseif ( ! empty( $atts['sku'] ) ) { |
|
497 | $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
498 | $product_data = get_post( $product_id ); |
|
499 | } else { |
|
500 | $product_data = wc_get_product( $post->ID ); |
|
501 | } |
|
502 | ||
503 | // Check that the product type is supported. Return blank if not supported. |
|
504 | if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
505 | return ''; |
|
506 | } |
|
507 | ||
508 | ob_start(); |
|
509 | ||
510 | // Get Subscription Period Interval |
|
511 | $period_interval = WC_Subscriptions_Product::get_interval( $product_data ); |
|
512 | ||
513 | // If the period is empty, look for alternative. |
|
514 | if ( empty( $period_interval ) ) { |
|
515 | $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
516 | ||
517 | if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
518 | $period_interval = $scheme['scheme']['subscription_period_interval']; |
|
519 | } |
|
520 | } |
|
521 | ||
522 | echo $period_interval; |
|
523 | ||
524 | return ob_get_clean(); |
|
525 | } // END get_subscription_period_interval() |
|
526 | ||
527 | /** |
|
528 | * Displays the subscription length of the subscription product. |
|
@@ 729-770 (lines=42) @@ | ||
726 | * @param array $atts |
|
727 | * @return string |
|
728 | */ |
|
729 | public static function get_subscription_trial_length( $atts ) { |
|
730 | global $wpdb, $post; |
|
731 | ||
732 | $defaults = shortcode_atts( array( |
|
733 | 'id' => '', |
|
734 | 'sku' => '', |
|
735 | ), $atts ); |
|
736 | ||
737 | $atts = wp_parse_args( $atts, $defaults ); |
|
738 | ||
739 | if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
740 | $product_data = wc_get_product( $atts['id'] ); |
|
741 | } elseif ( ! empty( $atts['sku'] ) ) { |
|
742 | $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
743 | $product_data = get_post( $product_id ); |
|
744 | } else { |
|
745 | $product_data = wc_get_product( $post->ID ); |
|
746 | } |
|
747 | ||
748 | // Check that the product type is supported. Return blank if not supported. |
|
749 | if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
750 | return ''; |
|
751 | } |
|
752 | ||
753 | ob_start(); |
|
754 | ||
755 | // Get Subscription Trial Length |
|
756 | $trial_length = WC_Subscriptions_Product::get_trial_length( $product_data ); |
|
757 | ||
758 | // If the trial length is empty, look for alternative. |
|
759 | if ( empty( $trial_length ) ) { |
|
760 | $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
761 | ||
762 | if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
763 | $trial_length = $scheme['scheme']['subscription_trial_length']; |
|
764 | } |
|
765 | } |
|
766 | ||
767 | echo $trial_length; |
|
768 | ||
769 | return ob_get_clean(); |
|
770 | } // END get_subscription_trial_length() |
|
771 | ||
772 | /** |
|
773 | * Displays the subscription trial period of the subscription product. |