| @@ -1,11 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Service container bootstrap. | |
| 4 | + * | |
| 5 | + * @package SpringDevs\Subscription | |
| 6 | + */ | |
| 2 | 7 | |
| 3 | 8 | namespace SpringDevs\Subscription; |
| 4 | 9 | |
| 5 | 10 | use SpringDevs\Subscription\Frontend\Checkout; |
| 11 | +use SpringDevs\Subscription\Frontend\PlanCheckout; | |
| 6 | 12 | use SpringDevs\Subscription\Illuminate\AutoRenewal; |
| 7 | 13 | use SpringDevs\Subscription\Illuminate\Block; |
| 14 | +use SpringDevs\Subscription\Illuminate\Cancellation; | |
| 8 | 15 | use SpringDevs\Subscription\Illuminate\Cron; |
| 9 | 16 | use SpringDevs\Subscription\Illuminate\Email; |
| 10 | 17 | use SpringDevs\Subscription\Illuminate\Order; |
| 11 | 18 | use SpringDevs\Subscription\Illuminate\Post; |
| @@ -30,18 +37,53 @@ | ||
| 30 | 37 | new Subscription(); |
| 31 | 38 | new RoleManagement(); |
| 32 | 39 | new Order(); |
| 33 | 40 | new Cron(); |
| 41 | + new Cancellation(); | |
| 34 | 42 | new Stats(); |
| 35 | 43 | new Post(); |
| 36 | 44 | new Block(); |
| 37 | 45 | new Checkout(); |
| 46 | + // Pro ships a superset plan checkout (Subscribe & Save, Installments, | |
| 47 | + // variable / per-variation) on the same hooks and priorities, so free's | |
| 48 | + // Recurring-simple checkout runs only when Pro is absent — otherwise the two | |
| 49 | + // would create the subscription twice. | |
| 50 | + if ( ! subscrpt_pro_activated() ) { | |
| 51 | + new PlanCheckout(); | |
| 52 | + } | |
| 38 | 53 | new GuestCheckout(); |
| 39 | 54 | new AutoRenewal(); |
| 40 | 55 | new Email(); |
| 56 | + | |
| 57 | + // Hide the internal plan snapshot meta from the admin order-item screen. | |
| 58 | + // WooCommerce's admin item view lists every meta key not in this filter | |
| 59 | + // (it does not hide the leading-underscore prefix there). Registered here — | |
| 60 | + // always loaded, both plugins share these keys — so it covers free and pro. | |
| 61 | + add_filter( 'woocommerce_hidden_order_itemmeta', array( $this, 'hidden_plan_order_itemmeta' ) ); | |
| 41 | 62 | } |
| 42 | 63 | |
| 43 | 64 | /** |
| 65 | + * Hide the plan snapshot meta keys on the admin order-item screen. | |
| 66 | + * | |
| 67 | + * @param array $keys Hidden order-item meta keys. | |
| 68 | + * | |
| 69 | + * @return array | |
| 70 | + */ | |
| 71 | + public function hidden_plan_order_itemmeta( $keys ) { | |
| 72 | + return array_merge( | |
| 73 | + (array) $keys, | |
| 74 | + array( | |
| 75 | + '_subscrpt_plan_id', | |
| 76 | + '_subscrpt_plan_group_id', | |
| 77 | + '_subscrpt_plan_price', | |
| 78 | + '_subscrpt_plan_payment_type', | |
| 79 | + '_subscrpt_plan_max_no_payment', | |
| 80 | + '_subscrpt_plan_terms', | |
| 81 | + ) | |
| 82 | + ); | |
| 83 | + } | |
| 84 | + | |
| 85 | + /** | |
| 44 | 86 | * Stripe Initialization. |
| 45 | 87 | * |
| 46 | 88 | * @return void |
| 47 | 89 | */ |
| @@ -74,9 +116,9 @@ | ||
| 74 | 116 | $is_paypal_integration_enabled = 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' ); |
| 75 | 117 | |
| 76 | 118 | // Register the PayPal gateway with WooCommerce. |
| 77 | 119 | if ( $is_paypal_integration_enabled ) { |
| 78 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'register_paypal_gateway' ) ); | |
| 120 | + add_filter( 'woocommerce_payment_gateways', [ $this, 'register_paypal_gateway' ] ); | |
| 79 | 121 | } |
| 80 | 122 | } |
| 81 | 123 | |
| 82 | 124 | /** |