php - 如果商店关门,则禁用 Dokan 上的送货方式

标签 php wordpress woocommerce dokan

有什么方法可以使用此代码来禁用特定的运输方式吗?例如,如果我想使用“统一费率”方法,并且如果商店关门,我希望这种方法不出现。

我尝试用实例 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/

相关文章:

php - 在具有串联 PHP 变量的 SQL 语法中使用 REGEXP

javascript - 使用 div 内的 GET 参数显示外部 php 文件的内容

php - Chrome 驱动程序在 Laravel Dusk 中失败 - "Failed to open stream: HTTP request failed! 404 Not Found"

php - 如何设置多个重力形式值而不需要为每个重力形式值执行新的数据库查询?

php - 显示字符串反序列化 wordpress

php - 在类别页面中显示最低的简单产品价格

php - 使用 Woocommerce 方法保存产品属性不同步到前端

php - CakePHP 3 : Accessing trait from controller

mysql - 将 WP 站点手动移动到新主机和域时如何调整 URL 设置?

wordpress - 重复/复制订单 Woocommerce