/* 
Theme Name: Hello Elementor Child
Theme URI: https://github.com/elementor/hello-theme-child/
Description: Hello Elementor Child is a child theme of Hello Elementor, created by Elementor team
Author: Elementor Team
Author URI: https://elementor.com/
Template: hello-elementor
Version: 2.0.0
Text Domain: hello-elementor-child
License: GNU General Public License v3 or later.
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Tags: flexible-header, custom-colors, custom-menu, custom-logo, editor-style, featured-images, rtl-language-support, threaded-comments, translation-ready
*/

/**
 * Subscriptions for WooCommerce: "/ Month" im Preis-HTML auf Deutsch umbiegen
 * (greift i.d.R. auch im Warenkorb/Checkout, da es am price_html hängt)
 */
add_filter('woocommerce_get_price_html', function ($price_html, $product) {

    // Ersetzt genau den Plugin-Teil: <span class="wps_sfw_interval"> / Month </span>
    $price_html = preg_replace(
        '~(<span[^>]*class="wps_sfw_interval"[^>]*>\s*/\s*)Month(\s*</span>)~i',
        '$1Monate$2',
        $price_html
    );

    // Falls das Plugin an anderer Stelle " / Month" ohne Span ausgibt (Fallback)
    $price_html = str_replace(array('/ Month', '/  Month'), '/ Monate', $price_html);

    return $price_html;
}, 20, 2);