本文整理汇总了PHP中woocommerce_quantity_input函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_quantity_input函数的具体用法?PHP woocommerce_quantity_input怎么用?PHP woocommerce_quantity_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_quantity_input函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_action
<?php
do_action('woocommerce_before_add_to_cart_button');
?>
<div class="single_variation_wrap" style="display:none;">
<?php
do_action('woocommerce_before_single_variation');
?>
<div class="single_variation"></div>
<div class="variations_button">
<?php
woocommerce_quantity_input(array('input_value' => isset($_POST['quantity']) ? wc_stock_amount($_POST['quantity']) : 1));
?>
<button type="submit" class="single_add_to_cart_button button alt"><?php
echo $product->single_add_to_cart_text();
?>
</button>
</div>
<input type="hidden" name="add-to-cart" value="<?php
echo absint($product->id);
?>
" />
<input type="hidden" name="product_id" value="<?php
echo absint($product->id);
?>
" />
示例2: sf_single_variation_add_to_cart_button
function sf_single_variation_add_to_cart_button()
{
global $product;
$loading_text = __('Adding...', 'swiftframework');
$added_text = __('Item added', 'swiftframework');
?>
<div class="variations_button">
<?php
woocommerce_quantity_input(array('input_value' => isset($_POST['quantity']) ? wc_stock_amount($_POST['quantity']) : 1));
?>
<button type="submit" data-product_id="<?php
echo esc_attr($product->id);
?>
" data-quantity="1" data-default_text="<?php
echo esc_attr($product->single_add_to_cart_text());
?>
" data-default_icon="sf-icon-add-to-cart" data-loading_text="<?php
echo esc_attr($loading_text);
?>
" data-added_text="<?php
echo esc_attr($added_text);
?>
" class="single_add_to_cart_button button alt"><?php
echo apply_filters('sf_add_to_cart_icon', '<i class="sf-icon-add-to-cart"></i>');
?>
<span><?php
echo esc_attr($product->single_add_to_cart_text());
?>
</span></button>
<input type="hidden" name="add-to-cart" value="<?php
echo absint($product->id);
?>
" />
<input type="hidden" name="product_id" value="<?php
echo absint($product->id);
?>
" />
<input type="hidden" name="variation_id" class="variation_id" value="" />
<?php
echo sf_wishlist_button();
?>
</div>
<?php
}
示例3: woocommerce_single_variation_add_to_cart_button
/**
* Override the Output the add to cart button for variations.
*/
function woocommerce_single_variation_add_to_cart_button()
{
global $product;
?>
<div class="variations_button">
<button type="submit" class="single_add_to_cart_button button alt"><?php
echo esc_html($product->single_add_to_cart_text());
?>
</button>
<input type="hidden" name="add-to-cart" value="<?php
echo absint($product->id);
?>
" />
<input type="hidden" name="product_id" value="<?php
echo absint($product->id);
?>
" />
<input type="hidden" name="variation_id" class="variation_id" value="" />
<?php
woocommerce_quantity_input(array('input_value' => isset($_POST['quantity']) ? wc_stock_amount($_POST['quantity']) : 1));
?>
</div>
<?php
}
示例4: strtotime
}
$start_date = null;
if (!empty($ticket->start_date)) {
$start_date = strtotime($ticket->start_date . $gmt_offset);
}
if ((empty($start_date) || time() > $start_date) && (empty($end_date) || time() < $end_date)) {
$is_there_any_product = true;
echo sprintf('<input type="hidden" name="product_id[]" value="%d">', $ticket->ID);
echo '<tr>';
echo '<td class="woocommerce">';
if ($product->is_in_stock()) {
// Max quantity will be left open if backorders allowed, restricted to 1 if the product is
// constrained to be sold individually or else set to the available stock quantity
$max_quantity = $product->backorders_allowed() ? '' : $product->get_stock_quantity();
$max_quantity = $product->is_sold_individually() ? 1 : $max_quantity;
woocommerce_quantity_input(array('input_name' => 'quantity_' . $ticket->ID, 'input_value' => 0, 'min_value' => 0, 'max_value' => $max_quantity));
$is_there_any_product_to_sell = true;
} else {
echo '<span class="tickets_nostock">' . esc_html__('Out of stock!', 'tribe-wootickets') . '</span>';
}
echo '</td>';
echo '<td nowrap="nowrap" class="tickets_name">';
echo $ticket->name;
echo '</td>';
echo '<td class="tickets_price">';
echo $this->get_price_html($product);
//echo '<a class="member_discount nav_login" href="';
//echo esc_url(home_url('/'));
//echo 'wp-admin';
//echo '">Login for member discount</a>';
if (!is_user_logged_in()) {
示例5: khore_woocommerce_before_shop_loop_item
function khore_woocommerce_before_shop_loop_item()
{
global $post;
echo '<td class="title">';
do_action('woocommerce_before_shop_loop_item_title');
echo '<h3>' . get_the_title() . '</h3>';
do_action('woocommerce_after_shop_loop_item_title');
echo '</td>';
echo '<td class="description">';
echo '<span class="short-description">' . $post->post_excerpt . '</span>';
echo '</td>';
echo '<td class="price">';
woocommerce_template_loop_price();
echo '</td>';
echo '<td class="quantity">';
woocommerce_quantity_input();
echo '<input type="hidden" name="product_id" value="' . $post->ID . '" />';
echo '</td>';
}
示例6: do_action
<?php
do_action('woocommerce_before_add_to_cart_form');
?>
<form action="<?php
echo esc_url($product->add_to_cart_url());
?>
" class="qty-product-single clearfix 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' => 1, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity()));
}
?>
<button type="submit" class="single_add_to_cart_button button3 fr alt"><?php
echo apply_filters('single_add_to_cart_text', __('Add to cart', 'qns'), $product->product_type);
?>
</button>
<?php
do_action('woocommerce_after_add_to_cart_button');
?>
</form>
<?php
示例7: do_action
<?php
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 type="hidden" name="add-to-cart" value="<?php
echo esc_attr($product->id);
?>
" />
<button type="submit" class="single_add_to_cart_button button alt btn btn-default"><?php
echo wp_kses_post($product->single_add_to_cart_text());
?>
</button>
<?php
do_action('woocommerce_after_add_to_cart_button');
示例8: cr_single_variation_add_to_cart_button
/**
* Output the add to cart button for variations.
*/
function cr_single_variation_add_to_cart_button()
{
global $product;
?>
<div class="variations_button point-of-action">
<div class="quantity">
<label>Qty:</label>
<?php
woocommerce_quantity_input(array('input_value' => isset($_POST['quantity']) ? wc_stock_amount($_POST['quantity']) : 1));
?>
</div>
<div class="add-to-cart">
<button type="submit" class="single_add_to_cart_button button alt btn btn-primary"><i class="fa fa-shopping-cart"></i> <?php
echo esc_html($product->single_add_to_cart_text());
?>
</button>
</div>
<input type="hidden" name="add-to-cart" value="<?php
echo absint($product->id);
?>
" />
<input type="hidden" name="product_id" value="<?php
echo absint($product->id);
?>
" />
<input type="hidden" name="variation_id" class="variation_id" value="" />
</div>
<?php
}
示例9: setup_postdata
setup_postdata($post);
?>
<tr>
<td>
<?php
if ($product->is_sold_individually() || !$product->is_purchasable()) {
?>
<?php
woocommerce_template_loop_add_to_cart();
?>
<?php
} else {
?>
<?php
$quantites_required = true;
woocommerce_quantity_input(array('input_name' => 'quantity[' . $product_id . ']', 'input_value' => isset($_POST['quantity'][$product_id]) ? wc_stock_amount($_POST['quantity'][$product_id]) : 0, 'min_value' => apply_filters('woocommerce_quantity_input_min', 0, $product), 'max_value' => apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product)));
?>
<?php
}
?>
</td>
<td class="label">
<label for="product-<?php
echo $product_id;
?>
">
<?php
echo $product->is_visible() ? '<a href="' . esc_url(apply_filters('woocommerce_grouped_product_list_link', get_permalink(), $product_id)) . '">' . esc_html(get_the_title()) . '</a>' : esc_html(get_the_title());
?>
</label>
示例10: do_action
<?php
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));
}
?>
<input type="hidden" name="add-to-cart" value="<?php
echo esc_attr($product->id);
?>
" />
<button type="submit" class="single_add_to_cart_button button alt"><?php
echo esc_html($product->single_add_to_cart_text());
?>
</button>
<?php
do_action('woocommerce_after_add_to_cart_button');
示例11: array
$item_data[] = array('key' => $label, 'value' => $value);
}
}
// Output flat or in list format
if (sizeof($item_data) > 0) {
foreach ($item_data as $data) {
echo esc_html($data['key']) . ': ' . wp_kses_post($data['value']) . "\n";
}
}
?>
</td>
<td class="product-quantity">
<?php
$product_quantity = woocommerce_quantity_input(array('input_name' => "raq[{$key}][qty]", 'input_value' => $raq['quantity'], 'max_value' => apply_filters('ywraq_quantity_max_value', $_product->backorders_allowed() ? '' : $_product->get_stock_quantity()), 'min_value' => '0'), $_product, false);
echo $product_quantity;
?>
</td>
<td class="product-subtotal">
<?php
echo apply_filters('yith_ywraq_hide_price_template', WC()->cart->get_product_subtotal($_product, $raq['quantity']));
?>
</td>
</tr>
<?php
}
?>
示例12: setup_postdata
setup_postdata($post);
?>
<tr>
<td>
<?php
if ($product->is_sold_individually() || !$product->is_purchasable()) {
?>
<?php
mango_add_to_cart($product_id);
?>
<?php
} else {
?>
<?php
$quantites_required = true;
woocommerce_quantity_input(array('input_name' => 'quantity[' . $product_id . ']', 'input_value' => '0', 'min_value' => apply_filters('woocommerce_quantity_input_min', 0, $product), 'max_value' => apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product)));
?>
<?php
}
?>
</td>
<td class="label margin_top_20">
<label class="input-desc" for="product-<?php
echo $product_id;
?>
">
<?php
echo $product->is_visible() ? '<a href="' . get_permalink() . '">' . get_the_title() . '</a>' : get_the_title();
?>
</label>
示例13: strtotime
if (!empty($ticket->end_date)) {
$end_date = strtotime($ticket->end_date . $gmt_offset);
} else {
$end_date = strtotime(tribe_get_end_date(get_the_ID(), false, 'Y-m-d G:i') . $gmt_offset);
}
$start_date = null;
if (!empty($ticket->start_date)) {
$start_date = strtotime($ticket->start_date . $gmt_offset);
}
if ((empty($start_date) || time() > $start_date) && (empty($end_date) || time() < $end_date)) {
$is_there_any_product = true;
echo sprintf("<input type='hidden' name='product_id[]' value='%d'>", $ticket->ID);
echo "<tr>";
echo "<td class='woocommerce'>";
if ($product->is_in_stock()) {
woocommerce_quantity_input(array('input_name' => 'quantity_' . $ticket->ID, 'input_value' => 0, 'min_value' => 0, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity()));
$is_there_any_product_to_sell = true;
} else {
echo "<span class='tickets_nostock'>" . esc_html__('Out of stock!', 'tribe-wootickets') . "</span>";
}
echo "</td>";
echo "<td nowrap='nowrap' class='tickets_name'>";
echo $ticket->name;
echo "</td>";
echo "<td class='tickets_price'>";
echo $this->get_price_html($product);
echo "</td>";
echo "<td class='tickets_description'>";
echo $ticket->description;
echo "</td>";
echo "</tr>";
示例14: catalog_visibility_options_pricing_calculator_quantity_input
/**
* Add the pricing calculator and quantity input if the user can view the price
*
* @since 3.7.0
*/
public function catalog_visibility_options_pricing_calculator_quantity_input()
{
global $product;
// bail if the calculator is not enabled for this product
if (!$product || !WC_Price_Calculator_Product::calculator_enabled($product)) {
return;
}
// bail if current user can't view the price
if (class_exists('WC_Catalog_Restrictions_Filters') && !WC_Catalog_Restrictions_Filters::instance()->user_can_view_price($product)) {
return;
}
// render pricing calculator
wc_measurement_price_calculator()->get_product_page_instance()->render_price_calculator();
// render quantity input
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)));
}
}
示例15: klarna_checkout_get_cart_contents_html
/**
* Gets cart contents as formatted HTML.
* Used in KCO widget.
*
* @since 2.0
**/
function klarna_checkout_get_cart_contents_html($atts)
{
global $woocommerce;
ob_start();
if (!defined('WOOCOMMERCE_CART')) {
define('WOOCOMMERCE_CART', true);
}
$woocommerce->cart->calculate_shipping();
$woocommerce->cart->calculate_fees();
$woocommerce->cart->calculate_totals();
$hide_columns = array();
if ('' != $atts['hide_columns']) {
$hide_columns = explode(',', $atts['hide_columns']);
}
?>
<div>
<table id="klarna-checkout-cart">
<tbody>
<tr>
<?php
if (!in_array('remove', $hide_columns)) {
?>
<th class="product-remove kco-leftalign"></th>
<?php
}
?>
<th class="product-name kco-leftalign"><?php
_e('Product', 'woocommerce-gateway-klarna');
?>
</th>
<?php
if (!in_array('price', $hide_columns)) {
?>
<th class="product-price kco-centeralign"><?php
_e('Price', 'woocommerce-gateway-klarna');
?>
</th>
<?php
}
?>
<th class="product-quantity kco-centeralign"><?php
_e('Quantity', 'woocommerce-gateway-klarna');
?>
</th>
<th class="product-total kco-rightalign"><?php
_e('Total', 'woocommerce-gateway-klarna');
?>
</th>
</tr>
<?php
// Cart items
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) {
$_product = $cart_item['data'];
echo '<tr>';
if (!in_array('remove', $hide_columns)) {
echo '<td class="kco-product-remove kco-leftalign"><a href="#">x</a></td>';
}
echo '<td class="product-name kco-leftalign">';
if (!$_product->is_visible()) {
echo apply_filters('woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key) . ' ';
} else {
echo apply_filters('woocommerce_cart_item_name', sprintf('<a href="%s">%s </a>', $_product->get_permalink($cart_item), $_product->get_title()), $cart_item, $cart_item_key);
}
// Meta data
echo $woocommerce->cart->get_item_data($cart_item);
echo '</td>';
if (!in_array('price', $hide_columns)) {
echo '<td class="product-price kco-centeralign"><span class="amount">';
echo $woocommerce->cart->get_product_price($_product);
echo '</span></td>';
}
echo '<td class="product-quantity kco-centeralign" data-cart_item_key="' . $cart_item_key . '">';
if ($_product->is_sold_individually()) {
$product_quantity = sprintf('1 <input type="hidden" name="cart[%s][qty]" value="1" />', esc_attr($cart_item_key));
} else {
$product_quantity = woocommerce_quantity_input(array('input_name' => "cart[{$cart_item_key}][qty]", 'input_value' => $cart_item['quantity'], 'max_value' => $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), 'min_value' => '1'), $_product, false);
}
echo apply_filters('woocommerce_cart_item_quantity', $product_quantity, $cart_item_key);
echo '</td>';
echo '<td class="product-total kco-rightalign"><span class="amount">';
echo apply_filters('woocommerce_cart_item_subtotal', $woocommerce->cart->get_product_subtotal($_product, $cart_item['quantity']), $cart_item, $cart_item_key);
echo '</span></td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<?php
return ob_get_clean();
}