| @@ -122,9 +122,25 @@ | ||
| 122 | 122 | return $this->product->get_meta( '_subscrpt_max_no_payment' ); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public function is_enabled(): bool { |
| 126 | - return $this->product->get_meta( '_subscrpt_enabled' ); | |
| 126 | + if ( empty( $this->product->get_meta( '_subscrpt_enabled' ) ) ) { | |
| 127 | + return false; | |
| 128 | + } | |
| 129 | + | |
| 130 | + // Once plan-connected, a product is a subscription only while it still has | |
| 131 | + // a plan — it never falls back to the legacy terms after a detach. | |
| 132 | + if ( 'yes' === $this->product->get_meta( '_subscrpt_plan_connected_before' ) && function_exists( 'subscrpt_product_has_plan' ) ) { | |
| 133 | + $parent = $this->product->get_parent_id(); | |
| 134 | + $has_plan = $parent | |
| 135 | + ? subscrpt_product_has_plan( $parent, $this->product->get_id() ) | |
| 136 | + : subscrpt_product_has_plan( $this->product->get_id() ); | |
| 137 | + if ( ! $has_plan ) { | |
| 138 | + return false; | |
| 139 | + } | |
| 140 | + } | |
| 141 | + | |
| 142 | + return true; | |
| 127 | 143 | } |
| 128 | 144 | |
| 129 | 145 | public function get_trial_timing_per(): int { |
| 130 | 146 | return (int) ( $this->product->get_meta( '_subscrpt_trial_timing_per' ) ?? 1 ); |