Seite 1 von 1

PHP Code verschachteln

Verfasst: 07.06.2026 08:57
von 260607Gast
Hallo Leute
Da ich kein Programmierer bin weiss ich nicht wie das korrekt aufgebaut wird und mir jemand von euh Hilfestellung geben kann.

Code: Alles auswählen

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>';
        }
    }
}]

Re: PHP Code verschachteln

Verfasst: 07.06.2026 10:32
von Crizzo
Hi,

und willkommen im Forum.

Da es sich hier vermutlich um eine Wordpress-Sache handelt und sich hier alles um phpBB dreht, ist das wahrscheinlich der falsche Platz für dein Anliegen. Insbesondere, da gar nicht ersichtlich ist, was genau hier passieren soll und wie dieses Wordpress-Plugin funktioniert.

Grüße