Sunday, September 25, 2022
HomeWordPress Developmentwoocommerce offtopic - Cover a delivery methodology if cart complete is greater...

woocommerce offtopic – Cover a delivery methodology if cart complete is greater than an quantity


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;
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments