PHP Hilfe Code einfaches Produkt
-
Vielleicht kann mir da jemand helfen.
Wie wird der Code korrekt aufgebaut?
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
function display_attribute_on_shop_page() {
global $product;
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'versandkosten';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Versandkosten: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'abholung';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Abholung: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'bett-matratzengroesse';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Bett / Matratzen Grösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'bh-groesse';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>BH Grösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'kleidergroesse-damen';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Kleidergrösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'kleidergroesse-herren';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Kleidergrösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'kleidergroesse-kinder-baby
';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Kleidergrösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'kleidergroesse-teenager';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Kleidergrösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'pc-monitor';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Grösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'schuhgroesse';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Grösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'display_attribute_on_shop_page', 5 );
// Überprüfen, ob das Produkt einfach ist
if ( $product->is_type( 'simple' ) ) {
$attribute_name = 'tv-groesse';
$attribute_values = $product->get_attribute( $attribute_name );
// Wenn das Attribut einen Wert hat, wird es ausgegeben
if ( ! empty( $attribute_values ) ) {
echo '<div class="shop-product-attribute">';
echo '<strong>Grösse: </strong>' . $attribute_values;
echo '</div>';
}
}
}
Ansicht von 5 Antworten – 1 bis 5 (von insgesamt 5)
Ansicht von 5 Antworten – 1 bis 5 (von insgesamt 5)
Du musst angemeldet sein, um auf dieses Thema zu antworten.