PHP Code verschachteln

Fragen zu allen Themen rund ums Programmieren außerhalb von phpBB können hier gestellt werden - auch zu anderen Programmiersprachen oder Software wie Webservern und Editoren.
Antworten
260607Gast

PHP Code verschachteln

Beitrag 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>';
        }
    }
}]
Verschoben von Support-Forum nach Coding & Technik am 07.06.2026 10:17 durch Crizzo

Benutzeravatar
Crizzo
Administrator
Administrator
Beiträge: 12242
Registriert: 19.05.2005 21:45
Kontaktdaten:

Re: PHP Code verschachteln

Beitrag 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
Antworten

Zurück zu „Coding & Technik“