| @@ -1,9 +1,15 @@ | ||
| 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; |
| 8 | 14 | use SpringDevs\Subscription\Illuminate\Cancellation; |
| 9 | 15 | use SpringDevs\Subscription\Illuminate\Cron; |
| @@ -36,11 +42,45 @@ | ||
| 36 | 42 | new Stats(); |
| 37 | 43 | new Post(); |
| 38 | 44 | new Block(); |
| 39 | 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 | + } | |
| 40 | 53 | new GuestCheckout(); |
| 41 | 54 | new AutoRenewal(); |
| 42 | 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' ) ); | |
| 62 | + } | |
| 63 | + | |
| 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 | + ); | |
| 43 | 83 | } |
| 44 | 84 | |
| 45 | 85 | /** |
| 46 | 86 | * Stripe Initialization. |