Home Set custom shipping rates programmatically in Woocommerce 3
Reply: 0

Set custom shipping rates programmatically in Woocommerce 3

user894
1#
user894 Published in August 16, 2018, 6:17 am

I have searched and found a number of examples of how to change the shipping rates. Basically I am looking to do the same, but I want to use a 3rd party API.

I have set up a custom plugin with a functions.php and activated it. I think used something simple like this:

add_filter('woocommerce_package_rates','test_overwrite',10,2);
function test_overwrite($rates,$package) {

    echo "<h2>Can you see me</h2>";
    foreach ($rates as $rate) {
        //Set the price
        $rate->cost = 1000;
        //Set the TAX
        $rate->taxes[1] = 1000 * 0.2;
    }
    return $rates;
}

However when I run either the checkout, or basket, the filter does not seem to run because I cannot see the echo. I also tried print_r().

Am I missing something as to why I cannot run this filter ?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.373195 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO