• Is it possible to calculate the shipping cost based on the location the customer picked?
    This could easily be implemented with Google’s Distance API.

Viewing 1 replies (of 1 total)
  • Plugin Author Sarankumar

    (@sarankumar)

    Hello @mschweini ,

    Yes you can calculate shipping using custom code. When a user is select location/change long/lat using the map it triggers ajax update. so using woocommerce_checkout_update_order_review this action hook you can modify the shipping cost.
    a sample code may look like this

    
    add_action('woocommerce_checkout_update_order_review','sg_modify_shipping_cost',10,1);
    
    function sg_modify_shipping_cost( $posted_data ){
    
    // print all posted data to debugg.log. This contain long/lat
    error_log(print_r($posted_data,true));
    
    // code for modifying shipping cost. 
    
    }
    • This reply was modified 3 years, 11 months ago by Sarankumar.
Viewing 1 replies (of 1 total)
  • The topic ‘calculate shipping based on distance?’ is closed to new replies.