-
WooCommerceで特定のタグを持っていない商品の購入を無効にします。
このコードを編集したいのですが
/* * Disable buying products from specific category and tag * * @author Misha Rudrastyh * @url https://rudrastyh.com/woocommerce/make-products-non-purchasable.html#specific-categories */ add_filter( 'woocommerce_is_purchasable', 'misha_catalog_mode_on_for_category', 10, 2 ); function misha_catalog_mode_on_for_category( $is_purchasable, $product ) { // Second – check product tags if( has_term( 'available', 'product_tag', $product->get_id() ) ) { $is_purchasable = true; } return $is_purchasable; }
i want to enable add to cart button only for the post has tag called available and make add to cart button hidden on rest of ther products on woocommerce
can anyone edit this code
thanks in advanced
i have tried to enable add to cart button on the selected products with tag available bu i couldn’t , actually used a plugin of woocommerce called hide price and add to cart button
ルドラスティドットコム
プラグインを使用せずに、WooCommerceストアで商品の購入を完全に無効にする方法、または特定のIDを持つ商品や特定のカテゴリの商品のみを無効にする方法。
-
WooCommerceでavailableタグを持つ商品以外を購入不可能にするには、購入可能をfalseにしてから、条件が満たされた場合のみtrueにする必要があります。
/*
* 特定のカテゴリーやタグから商品を購入できないようにします。
*
* 著者:ミーシャ・ルドラスティ
* @url https://rudrastyh.com/woocommerce/make-products-non-purchasable.html#specific-categories
*/
add_filter( ‘woocommerce_is_purchasable’, ‘misha_catalog_mode_on_for_category’, 10, 2 );
function misha_catalog_mode_on_for_category( $is_purchasable, $product ) {
$is_purchasable = false;
// Second – check product tags
if( has_term( ‘available’, ‘product_tag’, $product->get_id() ) ) {
$is_purchasable = true;
}
return $is_purchasable;
}
9月前</span
-