大佬教程收集整理的这篇文章主要介绍了jquery – 当数量选择改变时,WooCommerce显示总价,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
所以这是我对如何做的想法.
jQuery(document).ready(function($){ $('.qty').on('change',function(){ // grab the price var price = $('[itemprop="price"]').attr('content'); var @R_980_10586@l_price = price * this.value; console.log(price,this.value,@R_980_10586@l_pricE); }); })
这在粘贴在控制台上时有效.但我不确定将此代码放在WooCommerce上的哪个位置.
add_action( 'woocommerce_single_product_sumMary','woocommerce_@R_980_10586@l_product_price',31 ); function woocommerce_@R_980_10586@l_product_price() { global $woocommerce,$product; // let's setup our divs echo sprintf('<div id="product_@R_980_10586@l_price" style="margin-bottom:20px;">%s %s</div>',__('Product @R_980_10586@l:','woocommerce'),'<span class="price">'.$product->get_price().'</span>'); ?> <script> jQuery(function($){ var price = <?PHP echo $product->get_price(); ?>,currency = '<?PHP echo get_woocommerce_currency_symbol(); ?>'; $('[name=quantity]').change(function(){ if (!(this.value < 1)) { var product_@R_980_10586@l = parseFloat(price * this.value); $('#product_@R_980_10586@l_price .price').html( currency + product_@R_980_10586@l.toFixed(2)); } }); }); </script> <?PHP }
来源:http://reigelgallarde.me/programming/show-product-price-times-selected-quantity-on-woocommecre-product-page/
以上是大佬教程为你收集整理的jquery – 当数量选择改变时,WooCommerce显示总价全部内容,希望文章能够帮你解决jquery – 当数量选择改变时,WooCommerce显示总价所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。