Damit man das vernünftig lesen kenn:
function displayPriceProduct( $atts )
{
$atts = shortcode_atts( array('id' => null,), $atts, 'bartag');
$html = '';
if(intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ))
{
$_product = wc_get_product( $atts['id'] );
$html = "Preis = " . $_product->get_price() .
", Normaler Preis = " . $_product->get_regular_price() .
", Angebotspreis = " . $_product->get_sale_price() .
", Angebotsenddatum = " . $_product->get_date_on_sale_to();
}
return $html;
}
add_shortcode( 'woocommerce_product_price', 'displayPriceProduct' );
Alles anzeigen
Diese Zeile solltest du dir mal genauer ansehen:
$atts = shortcode_atts( array('id' => null,), $atts, 'bartag');
Eine ideale Vorraussetzung, um für WordPress Short-Codes zu schreiben. 