- Mensajes
- 5
- Puntuación de reacción
- 0
MOSTRAR ATRIBUTOS PERSONALIZADOS EN PAGINA DE TIENDA
Buenas, he visto el siguiente codigo:
// Paste this in your file, somewhere in the loop, around the h3
<?php echo $product->sku; ?> <?php echo $product->omschrijving; ?> <?php the_title(); ?>
<?php
// Get the attributes
$attributes = $product->get_attributes();
// Start the loop
foreach ( $attributes as $attribute ) : ?>
<?php
// Check and output, adopted from /templates/single-product/product-attributes.php
if ( $attribute['is_taxonomy'] ) {
$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
} else {
// Convert pipes to commas and display values
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
}
?>
<?php endforeach; ?>
Y muestra todos los atributos de producto en la pagina de la tienda, pero seria posible de mostrar por ejemplo el atributo que se llame "LOCALIDAD"?
No comprendo el codigo
JOAQUIN
Buenas, he visto el siguiente codigo:
// Paste this in your file, somewhere in the loop, around the h3
<?php echo $product->sku; ?> <?php echo $product->omschrijving; ?> <?php the_title(); ?>
<?php
// Get the attributes
$attributes = $product->get_attributes();
// Start the loop
foreach ( $attributes as $attribute ) : ?>
<?php
// Check and output, adopted from /templates/single-product/product-attributes.php
if ( $attribute['is_taxonomy'] ) {
$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
} else {
// Convert pipes to commas and display values
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
}
?>
<?php endforeach; ?>
Y muestra todos los atributos de producto en la pagina de la tienda, pero seria posible de mostrar por ejemplo el atributo que se llame "LOCALIDAD"?
No comprendo el codigo
JOAQUIN