guard( 'manage_options' ); if ( $check ) { return $check; } $check = $this->guard_discount_pro(); if ( $check ) { return $check; } if ( $discount_id <= 0 ) { return [ 'error' => 'discount_id must be a positive integer.' ]; } try { $discount = \WpCafePro\Models\Discount_Model::find( $discount_id ); if ( ! $discount ) { return [ 'error' => "Discount #{$discount_id} not found." ]; } return $this->shape_discount( $discount ); } catch ( \Throwable $e ) { Log::error( 'Wpcafe_Get_Discount_Tool error', [ 'error' => $e->getMessage() ] ); return [ 'error' => 'Failed to retrieve discount: ' . $e->getMessage() ]; } } }