Angepasster Preis unter Produkttitel

  • Sehr geehrte Community,

    es handelt sich um das Plugin WooCommerce. Dort ist standardmäßig bei variablen Produkten mit verschieden Preisen eine Preisspanne unter dem Produkttitel auf der Single Product Page angezeigt. Dies habe ich bereits mit Hilfe eines Codes geändert zu "ab X€" statt "X-Y€". Nun suche ich aber nach einer Lösung, dass wenn man eine Variante wählt der Preis sich von "ab X€" zu "Y€" ändert. Der eigentliche Preis wird zwar unten klein angezeigt, jedoch benötige ich den Preis ganz oben unter dem Produkttitel.

    Ich bin für jede Hilfe und Denkanstoß dankbar.

    Vielen Dank im Voraus!

    PS: Habe ein passendes Bild für mein Problem gefunden. Bei mir ist jedoch schon die Preisspanne zu "ab X€" geändert. Und der Clear Button muss nicht entfernt werden.
    Folgenden Code habe ich verwendet:

    function wc_custom_variable_price( $price, $product ) {
    // Main Price
    $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
    $price = $prices[0] !== $prices[1] ? sprintf( __( 'ab %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

    // Sale Price
    $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
    sort( $prices );
    $saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'ab %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

    if ( $price !== $saleprice ) {
    $price = '' . $saleprice . ' ' . $price . '';
    }

    return $price;
    }
    add_filter( 'woocommerce_variable_sale_price_html', 'wc_custom_variable_price', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wc_custom_variable_price', 10, 2 );

    • Anzeige

    Hallo!

    Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.

    • ✔️ Schnelle Ladezeiten (optimiert für WordPress & Co.)
    • ✔️ Deutsche Server & DSGVO-konform
    • ✔️ Persönlicher Support (kein 0815-Ticket-System)

    Mehr erfahren

  • you can also try this WooCommerce Wholesale Prices adding features like Add customer and user role specific pricing. Similarly, there's also an option to add quantity-based pricing for the retailer, wholesale, and other B2B user roles. Apart from this, you can also Customize table color and font size. The categories or selected products that need to be hidden can also be possible through these extensions. This extension also helps you to set different quantity-based discounts for customers.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!