37

商品詳細ページのWoocommerceの「数量」フィールド(カートに追加する前に数量を入力する)を非表示にし、「カートに追加」ボタンのみを表示する必要があります。これにより、数量が1になります。カートの中。その理由は、重力フォームに基づいて数量を収集するためです。

4

12 に答える 12

65
  • 商品を編集します。
  • 「在庫」をクリックします。
  • 「個別販売」にチェックを入れる
于 2013-12-16T03:11:19.653 に答える
4

商品の単一ページでそれを行う簡単な方法を見つけ、数量カウンターをカートに入れました。次のコードを functions.php に入れるだけです

add_action( 'wp_head', 'quantity_wp_head' );
function quantity_wp_head() {
if ( is_product() ) {
    ?>
<style type="text/css">.quantity, .buttons_added { width:0; height:0; display: none; visibility: hidden; }</style>
<?php }
}    

ここで woocommerce のドキュメントを確認できます: http://docs.woothemes.com/document/remov-product-content-based-on-category/

于 2014-12-09T12:59:57.763 に答える
3

あなたのために働くかもしれない数量セレクターを削除するための無料のプラグインがあります. http://wordpress.org/extend/plugins/woocommerce-remove-quantity-fields/

于 2013-02-08T18:23:48.263 に答える
2

プラグインは必要ありません。たとえば、css を使用して非表示にすることができます。しかし、woocommerce では 1 つの商品しか販売できず、同じ商品をカートに追加する選択はありません。woocommerce->設定を見てください。それはすべてそこにあります。

于 2013-07-31T15:59:19.000 に答える
0

編集する必要があるテンプレートは ですsingle-product/add-to-cart/variation-add-to-cart-button.php

したがって、このテンプレートを独自のテーマにコピーし、編集して数量フィールドを削除するだけです。次のようになります。

<?php
/**
 * Single variation cart button
 *
 * @see     http://docs.woothemes.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.5.0
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

global $product;
?>
<div class="woocommerce-variation-add-to-cart 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="0" />
</div>
于 2016-04-06T14:48:14.220 に答える