2012-04-13 17:33:51 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-11-03 13:53:50 +00:00
|
|
|
* Product attributes
|
2012-04-13 17:33:51 +00:00
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* Used by list_attributes() in the products class.
|
2012-08-14 18:05:45 +00:00
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-attributes.php.
|
2015-10-01 14:07:20 +00:00
|
|
|
*
|
2016-02-12 11:28:41 +00:00
|
|
|
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
|
|
|
* (the theme developer) will need to copy the new files to your theme to
|
|
|
|
* maintain compatibility. We try to do this as little as possible, but it does
|
|
|
|
* happen. When this occurs the version of the template file will be bumped and
|
|
|
|
* the readme will list any important changes.
|
2015-10-01 14:07:20 +00:00
|
|
|
*
|
|
|
|
* @see http://docs.woothemes.com/document/template-structure/
|
2012-08-14 18:05:45 +00:00
|
|
|
* @author WooThemes
|
|
|
|
* @package WooCommerce/Templates
|
2014-02-25 15:33:02 +00:00
|
|
|
* @version 2.1.3
|
2012-04-13 17:33:51 +00:00
|
|
|
*/
|
|
|
|
|
2014-02-25 15:33:02 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly
|
|
|
|
}
|
2012-10-15 10:57:58 +00:00
|
|
|
|
2014-02-25 15:33:02 +00:00
|
|
|
$has_row = false;
|
|
|
|
$alt = 1;
|
2012-04-13 17:33:51 +00:00
|
|
|
$attributes = $product->get_attributes();
|
|
|
|
|
2014-02-25 15:33:02 +00:00
|
|
|
ob_start();
|
2014-09-22 16:37:57 +00:00
|
|
|
|
2012-04-13 17:33:51 +00:00
|
|
|
?>
|
|
|
|
<table class="shop_attributes">
|
2012-08-14 18:05:45 +00:00
|
|
|
|
|
|
|
<?php if ( $product->enable_dimensions_display() ) : ?>
|
|
|
|
|
2014-02-25 15:33:02 +00:00
|
|
|
<?php if ( $product->has_weight() ) : $has_row = true; ?>
|
2015-11-15 02:31:23 +00:00
|
|
|
<tr class="<?php if ( ( $alt = $alt * -1 ) === 1 ) echo 'alt'; ?>">
|
2012-10-16 09:45:33 +00:00
|
|
|
<th><?php _e( 'Weight', 'woocommerce' ) ?></th>
|
2016-03-30 12:19:01 +00:00
|
|
|
<td class="product_weight"><?php echo wc_format_localized_decimal( $product->get_weight() ) . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) ); ?></td>
|
2012-04-13 17:33:51 +00:00
|
|
|
</tr>
|
|
|
|
<?php endif; ?>
|
2012-08-14 18:05:45 +00:00
|
|
|
|
2014-02-25 15:33:02 +00:00
|
|
|
<?php if ( $product->has_dimensions() ) : $has_row = true; ?>
|
2015-11-15 02:31:23 +00:00
|
|
|
<tr class="<?php if ( ( $alt = $alt * -1 ) === 1 ) echo 'alt'; ?>">
|
2012-10-16 09:45:33 +00:00
|
|
|
<th><?php _e( 'Dimensions', 'woocommerce' ) ?></th>
|
2012-11-16 13:50:15 +00:00
|
|
|
<td class="product_dimensions"><?php echo $product->get_dimensions(); ?></td>
|
2012-08-14 18:05:45 +00:00
|
|
|
</tr>
|
2012-04-13 17:33:51 +00:00
|
|
|
<?php endif; ?>
|
2012-08-14 18:05:45 +00:00
|
|
|
|
2012-04-13 17:33:51 +00:00
|
|
|
<?php endif; ?>
|
2012-08-14 18:05:45 +00:00
|
|
|
|
2013-04-16 13:41:23 +00:00
|
|
|
<?php foreach ( $attributes as $attribute ) :
|
2014-02-25 15:33:02 +00:00
|
|
|
if ( empty( $attribute['is_visible'] ) || ( $attribute['is_taxonomy'] && ! taxonomy_exists( $attribute['name'] ) ) ) {
|
2013-04-16 13:41:23 +00:00
|
|
|
continue;
|
2014-02-25 15:33:02 +00:00
|
|
|
} else {
|
|
|
|
$has_row = true;
|
|
|
|
}
|
2012-07-10 13:05:44 +00:00
|
|
|
?>
|
2013-04-16 13:41:23 +00:00
|
|
|
<tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
|
2013-09-12 13:41:02 +00:00
|
|
|
<th><?php echo wc_attribute_label( $attribute['name'] ); ?></th>
|
2012-04-13 17:33:51 +00:00
|
|
|
<td><?php
|
2012-06-10 17:15:02 +00:00
|
|
|
if ( $attribute['is_taxonomy'] ) {
|
2012-08-14 18:05:45 +00:00
|
|
|
|
2013-11-25 13:30:20 +00:00
|
|
|
$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
|
2012-07-11 18:11:41 +00:00
|
|
|
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
|
2012-08-14 18:05:45 +00:00
|
|
|
|
2012-06-10 17:15:02 +00:00
|
|
|
} else {
|
2012-08-14 18:05:45 +00:00
|
|
|
|
2012-07-11 18:11:41 +00:00
|
|
|
// Convert pipes to commas and display values
|
2013-10-24 18:36:22 +00:00
|
|
|
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
|
2012-07-11 18:11:41 +00:00
|
|
|
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
|
2012-08-14 18:05:45 +00:00
|
|
|
|
2012-06-10 17:15:02 +00:00
|
|
|
}
|
2012-04-13 17:33:51 +00:00
|
|
|
?></td>
|
|
|
|
</tr>
|
|
|
|
<?php endforeach; ?>
|
2014-09-22 16:37:57 +00:00
|
|
|
|
2014-02-25 15:33:02 +00:00
|
|
|
</table>
|
|
|
|
<?php
|
|
|
|
if ( $has_row ) {
|
|
|
|
echo ob_get_clean();
|
|
|
|
} else {
|
|
|
|
ob_end_clean();
|
2014-09-22 16:37:57 +00:00
|
|
|
}
|