简体   繁体   English

添加产品价值以添加到购物车按钮

[英]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.

相关问题 隐藏 Woocommerce 产品变体中特定属性值的添加到购物车按钮 - Hide Add to Cart button in Woocommerce product variations for a specific attribute value 如何将产品再次添加到购物车或“添加到购物车”按钮不起作用? - How to add the product again to the cart or add to cart button not working? 如果产品在购物车中,则在woocommerce中添加类以添加到购物车按钮 - if product is in cart add class to add to cart button in woocommerce 自定义添加到购物车按钮,将多个产品添加到购物车中,数量:woocommerce - Custom add to cart button to add multiple product into cart with quantity :woocommerce Woocommerce - 移动添加到购物车按钮变量产品 - Woocommerce - Move add to cart button variable product WooCommerce 3 中产品变化的 Ajax 添加到购物车按钮 - Ajax add to cart button for product variation in WooCommerce 3 添加到购物车按钮不显示在Woocommerce中的产品旁边 - Add to Cart Button not showing next to product in Woocommerce Woocommerce的“产品URL”与“添加到购物车”按钮重叠 - Woocommerce “Product URL” is overlaping with “Add to Cart” button 随处删除产品添加到购物车按钮 - Remove product add to cart button everywhere woocommerce 添加到单个产品页面上的购物车按钮 - woocommerce add to cart button on single product page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM