PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.9.5
Subscriptions for WooCommerce with Stripe Recurring Payments v1.9.5
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / includes / Illuminate / Subscription / Subscription.php

Subscription.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.9.5, at includes/Illuminate/Subscription/Subscription.php

62 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main subscription class.
4 *
5 * TODO: Refactor and move all subscription related logic from Helper class into this class.
6 *
7 * @package Subscription
8 */
9
10 namespace SpringDevs\Subscription\Illuminate\Subscription;
11
12 use SpringDevs\Subscription\Illuminate\Helper;
13 use SpringDevs\Subscription\Utils\Product;
14 use SpringDevs\Subscription\Utils\ProductFactory;
15 use WC_Product;
16
17 /**
18 * Class Subscription
19 *
20 * @package Illuminate\Subscription
21 */
22 class Subscription {
23 /**
24 * Get WC product in subscription wrapper.
25 *
26 * @param WC_Product|int $product Product.
27 * @return Product|false
28 */
29 public static function get_subs_product( $product ) {
30 if ( ! $product instanceof WC_Product ) {
31 $product = wc_get_product( absint( $product ) );
32 }
33
34 return $product ? ProductFactory::load( $product ) : false;
35 }
36
37 /**
38 * Get subscription endpoint.
39 *
40 * @param string $view View type.
41 * @return string
42 */
43 public static function get_user_endpoint( string $view = 'subs_list' ) {
44 $is_pro = subscrpt_pro_activated();
45
46 switch ( strtolower( $view ) ) {
47 case 'view_subs':
48 $default_endpoint = 'subscription';
49 $endpoint = $is_pro ? get_option( 'wpsubs_custom_view_subscription_endpoint', $default_endpoint ) : $default_endpoint;
50 break;
51
52 case 'subs_list':
53 default:
54 $default_endpoint = 'subscriptions';
55 $endpoint = $is_pro ? get_option( 'wpsubs_custom_subscriptions_endpoint', $default_endpoint ) : $default_endpoint;
56 break;
57 }
58
59 return untrailingslashit( $endpoint );
60 }
61 }
62