有什么方法可以使用此代码来禁用特定的运输方式吗?例如,如果我想使用“统一费率”方法,并且如果商店关门,我希望这种方法不出现。
我尝试用实例 ID“6”的 woocommerce_load_shipping_methods 替换 is_purchasable Hook ,但这不起作用。
下面是用于禁用购买的代码,但不适用于禁用运输方式。
add_filter( 'woocommerce_is_purchasable', 'prefix_woocommerce_is_purchasable', 10, 2 );
function prefix_woocommerce_is_purchasable( $is_purchasable, $product ) {
// Get the store id.
$store_id = get_post_field( 'post_author', $product->get_id() );
// Get the store info.
$store_info = dokan_get_store_info( $store_id );
// Get the store time enabled or not.
$is_dokan_store_time_enabled = $store_info['dokan_store_time_enabled'];
// If the store time is enabled, check whether the store is open or not.
// Else the store is open.
if ( 'yes' === $is_dokan_store_time_enabled ) {
$is_purchasable = dokan_is_store_open( $store_id );
} else {
$is_purchasable = true;
}
return $is_purchasable;
}
最佳答案
您可以在子主题的 functions.php 文件中尝试此代码。
remove_filter( 'woocommerce_cart_shipping_packages',
'dokan_custom_split_shipping_packages' );
使用此代码将禁用 Dokan 啜饮。管理员将从后端管理运输(WooCommerce Shipping)
关于php - 如果商店关门,则禁用 Dokan 上的送货方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62612559/