特定のユーザーを対象とした独自のカスタムフィールドを使用して、特定の製品をテーブルリストビューに表示したい。私自身のコードを開始したプラグインでこれを達成できませんでした。このユーザー/卸売業者のみがこのページを表示します。WooCommerceカスタムテンプレート行の最終製品のみをカートに追加する
しかし、これまでのコードでは、私は「カートに追加」ボタンの送信に固執しました。どの製品を追加しようとしても、その行の最後の製品だけが送信されます。 は、ここでは、コードです:私はwoocommerce_template_loop_add_to_cart($ LOOP->ポスト、$製品)を使用しようとしました
<h1> PRODUCT TABLE LIST </h1>
<table>
<thead>
<tr>
<th></th>
<th>Product</th>
<th>Note Box</th>
<th>Price</th>
<th>Choose Quantiy</th>
<th>Product Total Quantity</th>
<th></th>
</tr>
</thead>
<tbody class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 15,
'product_cat' => '',
'post__in' => array(481, 478, 934),
'orderby' => 'title');
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post(); global $product; ?>
<tr class="product-<?php echo esc_attr($product->id); ?>">
<a href="<?php echo get_permalink($loop->post->ID) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">
<td>
<?php woocommerce_show_product_sale_flash($post, $product); ?>
<?php if (has_post_thumbnail($loop->post->ID)) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="300px" height="300px" />'; ?>
</td>
<td>
<h3><?php the_title(); ?></h3>
</td>
<td>
<input type="text" placeholder="Choose up to 16 letters or Numbers" />
</td>
<td>
<span class="price">
<?php echo $product->get_price_html(); ?>
</span>
</td>
</a>
<td>
<table>
<tr>
<th>SC1</th>
<td><input type="number" name="quantity" min="1" max="100"></td>
</tr>
<tr>
<th>KW1</th>
<td><input type="number" name="quantity" min="1" max="100"></td>
</tr>
</table>
</td>
<td><input name="quantity" data-min="1" data-max="0" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" type="number"></td>
<td>
<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>
</td>
</tr>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</tbody>
</table>
が、それは数量値を提出していません。
' 'しかし、数量とカートに追加ボタンの両方が同じ表のセル内にあります '' –