我以为这会很容易,但是我被困住了.我要做的就是在产品页面上的变化价格之后分别添加一个词.我找到的解决方案将其添加到类别页面和产品页面的两个位置.
I thought this would have been easy, but I am stuck. All I am trying to do is add the word each after the variation price on a product page. The solution I have found adds it on the category page and in two places on the product page.
代码是:
/* Adds a text Each - after price */ function change_product_price( $price ) { $price .= ' each'; return $price; } add_filter( 'woocommerce_get_price_html', 'change_product_price' );
从上面的图片中,我只需要将每个添加到价格上的添加到购物车按钮上方,而不需要其他的价格,如上面的照片中的划线部分.
From the picture above, I only need the each added to the price above the add to cart button, but not the other pacles like the crossed out section in the photo above.
感谢您提供的任何指导.
Thank you for any guidance you can provide.
推荐答案以下代码将在产品变化价格后添加后缀:
The following code will add a suffix to the product variations price:
add_filter('woocommerce_available_variation', 'variation_price_custom_suffix', 10, 3 ); function variation_price_custom_suffix( $variation_data, $product, $variation ) { $variation_data['price_html'] .= ' <span class="price-suffix">' . __("each", "woocommerce") . '</span>'; return $variation_data; }代码进入您的活动子主题(活动主题)的function.php文件中.经过测试,可以正常工作.
Code goes in function.php file of your active child theme (active theme). Tested and works.
更多推荐
在Woocommerce中将自定义文本添加到变动价格
发布评论