[英]add product value to add to cart button
I want to show product value ( version ) to my add to cart button in the single product page我想在单个产品页面中的添加到购物车按钮中显示产品价值(版本)
i found the file that must be edit: woocommerce\templates\single-product\add-to-cart\external.php我找到了必须编辑的文件:woocommerce\templates\single-product\add-to-cart\external.php
<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html( $button_text ); ?> </button>
i try to change it to:我尝试将其更改为:
<button type="submit" class="single_add_to_cart_button button alt"><?php echo wp_kses_post( $product_attribute['value'] ); ?> </button>
but now nothing shows on my add to cart button但现在我的添加到购物车按钮上没有显示
Just try adding this in functions.php
file of your active theme只需尝试在您的活动主题的
functions.php
文件中添加它
add_action( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_product_single_add_to_cart_text', 10, 2 );
function woocommerce_product_single_add_to_cart_text( $add_to_cart, $product ) {
return $add_to_cart."--".$product->get_price();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.