In Woocommerce, I’m attempting to take away the ‘flat price’ delivery methodology when the cart complete is greater than 500, utilizing the woocommerce_package_rates
. However it isn’t working, when I attempt to debug it by logging errors within the console, I do not see something print there both.
add_filter( 'woocommerce_package_rates', 'custom_package_rates', 10, 2 );
operate custom_package_rates( $charges, $package deal ) {
$complete = WC()->cart->cart_contents_total;
echo $complete;
if( $complete > 500 ) {
unset( $charges['flat_rate:2'] );
}
// debug
$log_msgs[]=json_encode($charges);
foreach($log_msgs as $msg) {
echo "<script>console.log($msg);</script>";
}
// return
return $charges;
}