jhaustein
Goto Top

Wordpress: "Preis ab" anzeigen lassen

Hallo Gemeinschaft,

habe folgendes Script gefunden, welches mir es ermöglicht einen ab Preis anzuzeigen - in diesem fall 13,17 - ich weiss das darüber brauche ich nur zum Teil - nun ist ein Produkt dabei, "Sonderartikel" dort darf diese Anzeige nicht auftauchen

könnt iohr dabei helfen

/**
 * Skip to content link
 */
function envo_shop_skip_link() {
	echo '<a class="skip-link screen-reader-text" href="#site-content">' . esc_html__( 'Skip to the content', 'envo-shop' ) . '</a>';  
}

add_action( 'wp_body_open', 'envo_shop_skip_link', 5 );  
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 ( $price !== $saleprice ) {
$price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';  
}
	$price = 'ab 13,17 €';  
return $price;
}

Content-Key: 13380854538

Url: https://administrator.de/contentid/13380854538

Printed on: June 16, 2024 at 16:06 o'clock

Member: godlie
godlie May 24, 2024 at 05:55:30 (UTC)
Goto Top
Hallo,

wie ist denn der "Sonderartikel" gekennzeichnet? Hat er als dies als Produktname ?

Du kannst dir ja mal das ganze $product ( print_r($product)); ausgeben und dann einfache eine Abfrage ala

if($product->name !== 'Sonderartikel'){  
  $price = 'ab 13,71€';  
} else {
  $price = 'Spezailpreis';  
}
return $price;
grüße