本文整理汇总了PHP中woocommerce_quantity_input函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_quantity_input函数的具体用法?PHP woocommerce_quantity_input怎么用?PHP woocommerce_quantity_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_quantity_input函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
?>
" />
开发者ID:jaredkc,项目名称:wc-variations-radio-buttons,代码行数:30,代码来源:variable.php
示例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
}
开发者ID:Infernosaint,项目名称:WPSetupTest2,代码行数:44,代码来源:sf-woocommerce.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
}
开发者ID:bqevin,项目名称:wp-shopeasy,代码行数:27,代码来源:template-tags-categories.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()) {
开发者ID:pellio11,项目名称:ns-select-project,代码行数:31,代码来源:tickets.php
示例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>';
}
开发者ID:digideskio,项目名称:stammtisch,代码行数:19,代码来源:januas.php
示例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
开发者ID:radoslavmihalus,项目名称:goga.sk,代码行数:31,代码来源:simple.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');
开发者ID:b0123498765,项目名称:fithealthyandwealthy,代码行数:31,代码来源:simple.php
示例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
}
开发者ID:WP-Panda,项目名称:m.video,代码行数:32,代码来源:woocommerce-config.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>
开发者ID:crazyyy,项目名称:smartmagel,代码行数:31,代码来源:grouped.php
示例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');
开发者ID:booklein,项目名称:wpbookle,代码行数:31,代码来源:simple.php
示例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
}
?>
开发者ID:yarwalker,项目名称:ecobyt,代码行数:30,代码来源:request-quote-view.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>
开发者ID:nickkoskowski,项目名称:Work-Depot,代码行数:31,代码来源:grouped.php
示例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>";
开发者ID:bennet-iwd,项目名称:gamblers-night,代码行数:31,代码来源:tickets.php
示例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)));
}
}
开发者ID:baden03,项目名称:access48,代码行数:23,代码来源:class-wc-price-calculator-compatibility.php
示例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();
}
开发者ID:NoviumDesign,项目名称:polefitness,代码行数:97,代码来源:class-klarna-shortcodes.php
示例16: set_simple_add_to_cart
public function set_simple_add_to_cart()
{
global $woocommerce, $product, $post;
if (!$product->is_purchasable()) {
return;
}
$availability = $product->get_availability();
/* CHECK IF DISPLAY IN_STOCK */
$show_if_stocked = get_post_meta($post->ID, self::ID . '_show_stock_product', true);
$stock_override = get_option(self::ID . '_show_stocks');
$is_virtual = get_post_meta($post->ID, '_virtual', true);
$show_stock = true;
if ($stock_override != '1' && $stock_override != 'yes') {
$show_stock = false;
}
if ($show_if_stocked == 'show') {
$show_stock = true;
} else {
$show_stock = false;
if ($stock_override == '1' || $stock_override == 'yes') {
$show_stock = true;
}
}
if ($is_virtual == '1' || $is_virtual == 'yes') {
$show_stock = false;
}
if ($show_stock) {
if ($availability['availability']) {
echo apply_filters('woocommerce_stock_html', '<p class="stock paywhatyouwant ' . esc_attr($availability['class']) . '">' . esc_html($availability['availability']) . '</p>', $availability['availability']);
}
}
if ($product->is_in_stock()) {
do_action('woocommerce_before_add_to_cart_form');
?>
<form class="cart paywhatyouwant" method="post" enctype='multipart/form-data'>
<?php
do_action('woocommerce_before_add_to_cart_button');
?>
<?php
if (!$product->is_sold_individually()) {
$itemproduct = 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));
woocommerce_quantity_input($itemproduct);
}
?>
<input type="hidden" name="add-to-cart" value="<?php
echo esc_attr($product->id);
?>
" />
<?php
$pwyw_amount = self::get_single_item_price();
/*<button type="submit" class="single_add_to_cart_button button alt"><?php echo $product->single_add_to_cart_text(); ?></button> */
echo '<input type="button" data-amount="' . $pwyw_amount . '" data-pid="' . $post->ID . '" onclick="pwyw_add_to_cart(' . $post->ID . ');" class="single_add_to_cart_button button alt pwyw_price_input" value="' . $product->add_to_cart_text() . '" >';
//echo '<input type="button" id="single_add_to_cart_button" data-pid="' . $post->ID . '" class="single_add_to_cart_button button alt" value="' . $product->add_to_cart_text() . '" >';
do_action('woocommerce_after_add_to_cart_button');
?>
</form>
<?php
do_action('woocommerce_after_add_to_cart_form');
}
self::set_product_meta();
}
开发者ID:arifur,项目名称:woocommerce-pay-what-you-want,代码行数:63,代码来源:woocommerce-pay-what-you-want.php
示例17: dvin_qlist_quantity_input
function dvin_qlist_quantity_input($input_name, $input_value, $args = array(), $product = null, $echo = true)
{
if (is_null($product)) {
$product = $GLOBALS['product'];
}
$product_quantity = woocommerce_quantity_input(array('input_name' => $input_name, 'input_value' => $input_value, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity(), 'min_value' => '1'), $product, false);
$output = apply_filters('woocommerce_cart_item_quantity', $product_quantity, '');
if ($echo) {
echo $output;
} else {
return $output;
}
}
开发者ID:berisberis,项目名称:betterquote,代码行数:13,代码来源:dvin-woocommerce-quotelist.php
示例18: single_variation
/**
* single variation template for variable_wccl
*
* @since 1.2
* @author Francesco Licandro
*/
public function single_variation()
{
global $product, $woocommerce;
if (version_compare(preg_replace('/-beta-([0-9]+)/', '', $woocommerce->version), '2.4', '>=')) {
return;
}
ob_start();
?>
<div class="single_variation"></div>
<div class="variations_button">
<?php
woocommerce_quantity_input();
?>
<button type="submit" class="single_add_to_cart_button button alt"><?php
echo apply_filters('single_add_to_cart_text', __('Add to cart', 'woocommerce'), $product->product_type);
?>
</button>
</div>
<input type="hidden" name="add-to-cart" value="<?php
echo $product->id;
?>
" />
<input type="hidden" name="product_id" value="<?php
echo esc_attr($product->ID);
?>
" />
<input type="hidden" name="variation_id" class="variation_id" value="" />
<?php
echo ob_get_clean();
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:40,代码来源:class.yith-wccl-frontend.php
示例19: foreach
echo $bundled_item_id;
?>
]" value="" /><?php
foreach ($attributes[$bundled_item_id] as $name => $options) {
?>
<input type="hidden" name="bundle_attribute_<?php
echo sanitize_title($name) . '[' . $bundled_item_id . ']';
?>
" value=""><?php
}
}
?>
<?php
}
if (!$product->is_sold_individually()) {
woocommerce_quantity_input(array('min_value' => 1));
}
?>
<button type="submit" class="button alt"><?php
echo apply_filters('single_add_to_cart_text', __('Add to cart', 'woocommerce'), $product->product_type);
?>
</button>
</div>
<input type="hidden" name="add-to-cart" value="<?php
echo $product->id;
?>
" />
</div>
<?php
do_action('woocommerce_after_add_to_cart_button');
开发者ID:CmdTab,项目名称:Homeword,代码行数:31,代码来源:bundle.php
示例20: wc_cp_cart_item_quantity
/**
* Composited item quantities may be changed between min_q and max_q.
*
* @param string $quantity
* @param string $cart_item_key
* @return string
*/
public function wc_cp_cart_item_quantity($quantity, $cart_item_key)
{
$cart_item = WC()->cart->cart_contents[$cart_item_key];
if (isset($cart_item['composite_data']) && !empty($cart_item['composite_parent'])) {
$component_id = $cart_item['composite_item'];
if ($cart_item['composite_data'][$component_id]['quantity_min'] === $cart_item['composite_data'][$component_id]['quantity_max']) {
$quantity = $cart_item['quantity'];
} elseif (isset($cart_item['composite_parent']) && isset(WC()->cart->cart_contents[$cart_item['composite_parent']])) {
$parent = WC()->cart->cart_contents[$cart_item['composite_parent']];
$parent_quantity = $parent['quantity'];
$max_stock = $cart_item['data']->backorders_allowed() ? '' : $cart_item['data']->get_stock_quantity();
if ($max_stock !== '') {
$max_qty = $cart_item['composite_data'][$component_id]['quantity_max'] !== '' ? min($max_stock, $parent_quantity * $cart_item['composite_data'][$component_id]['quantity_max']) : $max_stock;
} else {
$max_qty = $cart_item['composite_data'][$component_id]['quantity_max'] !== '' ? $parent_quantity * $cart_item['composite_data'][$component_id]['quantity_max'] : '';
}
$min_qty = $parent_quantity * $cart_item['composite_data'][$component_id]['quantity_min'];
if (($max_qty > $min_qty || $max_qty === '') && !$cart_item['data']->is_sold_individually()) {
$component_quantity = woocommerce_quantity_input(array('input_name' => "cart[{$cart_item_key}][qty]", 'input_value' => $cart_item['quantity'], 'min_value' => $min_qty, 'max_value' => $max_qty, 'step' => $parent_quantity), $cart_item['data'], false);
$quantity = $component_quantity;
} else {
$quantity = $cart_item['quantity'];
}
} else {
$quantity = $cart_item['quantity'];
}
}
return $quantity;
}
开发者ID:alexbaron50,项目名称:Rockk3rs-Lab-Test,代码行数:36,代码来源:class-wc-cp-cart.php
注:本文中的woocommerce_quantity_input函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论