我想禁用免费送货,直到在WooCommerce中的某个日期只使用PHP.
add_filter( 'woocommerce_package_rates', 'disable_free_shipping_until_certain_date', 10, 2 );
function disable_free_shipping_until_certain_date($rates, $package) {
$current_date = date("Y-m-d");
$disable_date = strtotime('2024-02-25');
$disable_date = date('Y-m-d',$disable_date);
if($current_date < $disable_date){
unset( $rates['free_shipping'] );
}
return $rates;
}
这是我制作的PHP代码片段,但它不起作用.
为什么我无法使其工作?
我需要更改什么?