php - 如果商店关闭,请在 Dokan 上禁用送货方式
问题描述
有什么方法可以使用此代码禁用特定的运输方式?例如,如果我想使用“统一费率”方法,并且如果商店关门,我希望这种方法不出现。
我试图用实例 id 为“6”的 woocommerce_load_shipping_methods 替换 is_purchasable 挂钩,但这没有用。
以下是用于禁用购买的代码,但不是运输方式。
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)
推荐阅读
- windows-xp - 程序入口点 sprintf_s 不能位于 DLL 中
- sql - 为什么我的代码错误(mssql:违反主键约束“PK_SMSBlast2”。无法在对象“dbo.SMSBlast2”中插入重复键)?
- javascript - 使用 JavaScript 对 HTML 中的 Python/Flask 动态呈现的表格进行排序
- azure - 在 Azure Data-lake Analytics 中有两个文件夹的目的是什么
- asp.net - ASP.NET 会话限制最佳实践
- .net - 为什么.Net DataTable.PrimaryKey 忽略列序列的更改?
- python - 找出数组中差值小于或等于 K 的所有数字
- c - 如何获取双指针数组的大小?
- php - Laravel 分页数据透视表
- kubernetes - 在 istio VirtualService 中使用主机 `*-pim.webapi.com` 和 `pim.webapi.com` 失败