/** * 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); }
* the readme will list any important changes. * * @see https://docs.woocommerce.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates * @version 2.1.0 */ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } global $product; if (!$product->is_purchasable()) { return; } echo wc_get_stock_html($product); if ($product->is_in_stock()) { ?> <?php do_action('woocommerce_before_add_to_cart_form'); ?> <form class="cart" method="post" enctype='multipart/form-data'> <?php do_action('woocommerce_before_add_to_cart_button'); ?> <?php if (!$product->is_sold_individually()) { woocommerce_quantity_input(array('min_value' => apply_filters('woocommerce_quantity_input_min', 1, $product), 'max_value' => apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product), 'input_value' => isset($_POST['quantity']) ? wc_stock_amount($_POST['quantity']) : 1));
<label for="product-<?php echo $grouped_product->get_id(); ?> "> <?php echo $product->is_visible() ? '<a href="' . esc_url(apply_filters('woocommerce_grouped_product_list_link', get_permalink(), $grouped_product->get_id())) . '">' . get_the_title() . '</a>' : get_the_title(); ?> </label> </td> <?php do_action('woocommerce_grouped_product_list_before_price', $grouped_product); ?> <td class="price"> <?php echo $grouped_product->get_price_html(); echo wc_get_stock_html($grouped_product); ?> </td> </tr> <?php } wp_reset_postdata(); ?> </tbody> </table> <input type="hidden" name="add-to-cart" value="<?php echo esc_attr($product->get_id()); ?> " />