admin管理员组文章数量:1122846
im using Woocommerce and searching for a way to hide the "Add to cart"-Button on
a single-Product page IF the product is for free - I'm making a big CSV-Import and some product-prices are set to zero - i just want to hide the "add to cart" button on these products, so these are not buyable.
already asked this on the support page, but no success
Greets
im using Woocommerce and searching for a way to hide the "Add to cart"-Button on
a single-Product page IF the product is for free - I'm making a big CSV-Import and some product-prices are set to zero - i just want to hide the "add to cart" button on these products, so these are not buyable.
already asked this on the support page, but no success
Greets
Share Improve this question asked Aug 8, 2013 at 8:47 user36383user36383 431 gold badge1 silver badge3 bronze badges 2 |2 Answers
Reset to default 9Look at the beginning of the add to cart templates in WooCommerce. At the beginning there is a check to determine whether the product is purchasable. Inside the is_purchasable()
method in the product class is a filter. By default the product is not purchasable if there is no price set at all, but that can be extended to cover products for which the price is set to 0.
function wpa_109409_is_purchasable( $purchasable, $product ){
if( $product->get_price() == 0 )
$purchasable = false;
return $purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'wpa_109409_is_purchasable', 10, 2 );
As far as I understood your problem.. woocommerce has an option when you don't put any price, there will be no button at all..
Your product becomes like just a regular gallery/catalog..
Should that's what you're looking for.. perhaps the easiest way would be then to edit your csv file.. just find and replace zeros with empty space..
本文标签: pluginsWoocommerceHide “add to cart” on free products
版权声明:本文标题:plugins - Woocommerce - Hide “add to cart” on free products 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310207a1934292.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
single-product.php
? – fischi Commented Aug 8, 2013 at 8:54