0 レビュー
1 回答
php-更新後にフォームをインクリメント
WordPressEコマースプラグインをインストールしています。
チェックアウトページには、数量フィールドと更新ボタンの入力フォームがあります。
必要な数量を入力して製品価格を更新できるように
フォームはすべての製品で次のようになります:
<td class="wpsc_product_quantity wpsc_product_quantity_<?php echo wpsc_the_cart_item_key(); ?>">
<form action="<?php echo esc_url( get_option( 'shopping_cart_url' ) ); ?>" method="post" class="adjustform qty">
<input class="span1" type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<input class="btn btn-new btn-new-red" type="submit" value="u" name="submit" />
</form>
</td>
私の仕事は、このフォームを+1または-1で送信する「プラス」と「マイナス」のような2つのボタンを作成することです。
このフォームを使用してphpまたはjavascriptで作成できますか?
私が欲しいものを通常の方法で説明したことを願っています
わからない
0
レビュー
答え :
解決策: <script language="javascript">
function changeQuantity(v){
document.getElementById('quantity').value=parseInt(v)+parseInt(document.getElementById('quantity').value);
}
</script>
<td class="wpsc_product_quantity wpsc_product_quantity_<?php echo wpsc_the_cart_item_key(); ?>">
<form action="<?php echo esc_url(get_option('shopping_cart_url')); ?>" method="post" class="adjustform qty">
<!-- Add id -->
<input class="span1" type="text" id="quantity" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<input class="btn btn-new btn-new-red" type="submit" value="u" name="submit" />
<!-- New added code-->
<a href="JavaScript:void(0);" onclick="changeQuantity(1);">Plus</a> <a href="JavaScript:void(0);" onclick="changeQuantity(-1);">Minus</a>
</form>
</td>
<script language="javascript">
function changeQuantity(v){
document.getElementById('quantity').value=parseInt(v)+parseInt(document.getElementById('quantity').value);
}
</script>
<td class="wpsc_product_quantity wpsc_product_quantity_<?php echo wpsc_the_cart_item_key(); ?>">
<form action="<?php echo esc_url(get_option('shopping_cart_url')); ?>" method="post" class="adjustform qty">
<!-- Add id -->
<input class="span1" type="text" id="quantity" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<input class="btn btn-new btn-new-red" type="submit" value="u" name="submit" />
<!-- New added code-->
<a href="JavaScript:void(0);" onclick="changeQuantity(1);">Plus</a> <a href="JavaScript:void(0);" onclick="changeQuantity(-1);">Minus</a>
</form>
</td>
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。