value( 'discounts', 'code_combination', self::COMBINATION_CODE_REPLACES_AUTO ); return in_array( $value, array( self::COMBINATION_CODE_REPLACES_AUTO, self::COMBINATION_STACK ), true ) ? $value : self::COMBINATION_CODE_REPLACES_AUTO; } /** * Whether a typed code stacks with a matching automatic discount. * * @since 1.0.0 * * @return bool */ public function stacks(): bool { return self::COMBINATION_STACK === $this->codeCombination(); } /** * Whether catalog prices show an automatic-sale strikethrough. * * @since 1.0.0 * * @return bool */ public function strikethroughEnabled(): bool { $settings = get_option( self::SETTINGS_OPTION ); if ( is_array( $settings ) && isset( $settings['storefront']['discount_strikethrough'] ) ) { return (bool) $settings['storefront']['discount_strikethrough']; } return true; } /** * Read a raw value from a settings subtree, or a default when absent. * * @since 1.0.0 * * @param string $subtree The top-level settings key (e.g. `discounts`). * @param string $key The key under that subtree. * @param mixed $fallback The value when either segment is absent. * @return mixed */ private function value( string $subtree, string $key, $fallback ) { $settings = get_option( self::SETTINGS_OPTION ); if ( is_array( $settings ) && isset( $settings[ $subtree ][ $key ] ) ) { return $settings[ $subtree ][ $key ]; } return $fallback; } }