/** * Returns formatted dimensions. * * @param $formatted True by default for legacy support - will be false/not set in future versions to return the array only. Use wc_format_dimensions for formatted versions instead. * @return string|array */ public function get_dimensions($formatted = true) { if ($formatted) { wc_deprecated_argument('WC_Product::get_dimensions', '2.7', 'By default, get_dimensions has an argument set to true so that HTML is returned. This is to support the legacy version of the method. To get HTML dimensions, instead use wc_format_dimensions() function. Pass false to this method to return an array of dimensions. This will be the new default behavior in future versions.'); return apply_filters('woocommerce_product_dimensions', wc_format_dimensions($this->get_dimensions(false)), $this); } return array('length' => $this->get_length(), 'width' => $this->get_width(), 'height' => $this->get_height()); }
/** * Returns an array of data for a variation. Used in the add to cart form. * @since 2.4.0 * @param WC_Product $variation Variation product object or ID * @return array */ public function get_available_variation($variation) { if (is_numeric($variation)) { $variation = wc_get_product($variation); } return apply_filters('woocommerce_available_variation', array_merge($variation->get_data(), array('attributes' => $variation->get_variation_attributes(), 'image' => wc_get_product_attachment_props($variation->get_image_id()), 'weight_html' => wc_format_weight($variation->get_weight()), 'dimensions_html' => wc_format_dimensions($variation->get_dimensions(false)), 'price_html' => apply_filters('woocommerce_show_variation_price', $variation->get_price() === "" || $this->get_variation_price('min') !== $this->get_variation_price('max'), $this, $variation) ? '<span class="price">' . $variation->get_price_html() . '</span>' : '', 'availability_html' => wc_get_stock_html($variation), 'variation_id' => $variation->get_id(), 'variation_is_visible' => $variation->variation_is_visible(), 'variation_is_active' => $variation->variation_is_active(), 'is_purchasable' => $variation->is_purchasable(), 'display_price' => wc_get_price_to_display($variation), 'display_regular_price' => wc_get_price_to_display($variation, array('price' => $variation->get_regular_price())), 'dimensions' => wc_format_dimensions($variation->get_dimensions(false)), 'min_qty' => 1, 'max_qty' => $variation->backorders_allowed() ? '' : $variation->get_stock_quantity(), 'backorders_allowed' => $variation->backorders_allowed(), 'is_in_stock' => $variation->is_in_stock(), 'is_downloadable' => $variation->is_downloadable(), 'is_virtual' => $variation->is_virtual(), 'is_sold_individually' => $variation->is_sold_individually() ? 'yes' : 'no', 'variation_description' => $variation->get_description())), $this, $variation); }
</td> </tr> <?php } ?> <?php if ($display_dimensions && $product->has_dimensions()) { ?> <tr> <th><?php _e('Dimensions', 'woocommerce'); ?> </th> <td class="product_dimensions"><?php echo esc_html(wc_format_dimensions($product->get_dimensions(false))); ?> </td> </tr> <?php } ?> <?php foreach ($attributes as $attribute) { ?> <tr> <th><?php echo wc_attribute_label($attribute->get_name()); ?> </th>