Kann mir jemand helfen und sagen wo ich einstellen bzw. den Code ändern kann damit es nur den kleinsten Preis von Variablen Produkte zeigt anstatt z.B 20-400. Es soll so sein ab 20 CHF. Ich habe im Internet gesucht und was gefunden hat aber mir nichts gebracht vielleicht habt ihr eine bessere Idee.
Woocommerce Variable Produkte - Preis
-
-
- Gerade eben
- 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)
-
Um auf das alte 2.0er Format "ab Preis" zurück zu gehen ist die Lösung von Gerhard Potgieter zu empfehlen. Der folgende Code geht in die functions.php Deines Child Themes
PHP
Alles anzeigen<?php // Use WC 2.0 variable price format, now include sale price strikeout add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 ); function wc_wc20_variation_price_format( $price, $product ) { // Main Price $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ); $price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %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( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); if ( $price !== $saleprice ) { $price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>'; } return $price; } [COLOR=#000000]?> [/COLOR] -
Eine vereinfachte Version, die ich persönlich nicht so prickelnd finde, ist
Code[COLOR=#333333][FONT=Arial]add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2); [/FONT][/COLOR][COLOR=#333333][FONT=Arial]function custom_variation_price( $price, $product ) { [/FONT][/COLOR][COLOR=#333333][FONT=Arial] $price = ''; [/FONT][/COLOR][COLOR=#333333][FONT=Arial] $price .= woocommerce_price($product->min_variation_price); [/FONT][/COLOR][COLOR=#333333][FONT=Arial] return $price; [/FONT][/COLOR][COLOR=#333333][FONT=Arial] [/FONT][/COLOR][COLOR=#333333][FONT=Arial]} [/FONT][/COLOR] -
Bei mir klappt das nicht :(
Ich muss das Thema nochmal aufwärmen... Ich habe die erste Variante in die functions.php des Themes geschrieben. Allerdings ändert sich nichts am preis-format.
Ich hab die ganz an Anfang geschrieben, dann in die Mitte, dann ans Ende... Hat alles nix gebracht :( -
"ab" Preis in Woocommerce
gib diesen Code in deinem child Theme in der function.php:
es sind sowohl die normalen variablen preisen sowie die sale-preiseadd_filter( 'woocommerce_variable_sale_price_html', 'custom_variation_price', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'custom_variation_price', 10, 2 );
function custom_variation_price( $price, $product ) {
$price = 'ab ';
$price .= woocommerce_price($product->min_variation_price);
return $price;
} -
"ab" Preis oder "sale" Preis
auch das ist eine möglichkeit wenn man die gestrichene sale preise nicht haben will sondern nur den tiefen ab preis: die variable in die letzte zeile ist dafür zuständig: saleprice or price
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $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 ( $saleprice !== $price ) {
$price = '<del>' . $price . '</del> <ins>' . $saleprice . '</ins>';
}
return $saleprice;/* or $price */
} -
Hi :) - Hab das alles mal zusammengetragen und auf mein Blog veröffentlicht.. hab das auch auf verschiedenen Templates ausprobiert - Funktioniert einwandfrei bisher.. http://adem-oezen.de/woocommerce-pr…on-bis/12-2014/ - über Feedback würde ich mich freuen :)
-
wo ist da jetzt der Mehrwert?
-
[FONT=arial][COLOR=#1B1B1B]Ich habe bemerkt das durch den Code,[/COLOR] unter WooCommerce > Einstellungen > Mehrwertsteuer [COLOR=#1B1B1B]im Reiter[/COLOR] Mehrwertsteueroptionen[COLOR=#1B1B1B] die [/COLOR]Preisanzeige Zusatz/ Endung[COLOR=#1B1B1B] deaktiviert wird. Was ich schade finde da ich dieses Feld, meistens für einen verweiß mit einem Sternchen (*) genutzt habe – um Informationen im Footer zu ergänzen. Beispielsweise [/COLOR]*Preis inkl. 19 % MwSt. – zzgl. Versand.
Gibt es dafür auch eine Lösung?[/FONT]
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!