WooCommerce Shipping API functions

2019-09-03 08:17发布

I have WooCommerce Conditional shipping & Payment, Table rate plugin installed. I am trying to create an API functions for mobile to get shipping methods from WordPress WooCommerce.

i have the 2 plugin install with the settings below Woocommerce conditional shipping & payment enter image description here

and table rate shipping

enter image description here

let say i can get the basic default woocommerce shippings and calculation correct. but how can i get the condition restrictions from the 2 plugin? i have no idea which methods in these 2 plugin to use to get the conditions. enter image description here

If Anyone have done this before or have some clues please helps Thanks.

1条回答
干净又极端
2楼-- · 2019-09-03 08:59

Simply this 3 line of code it will get available shipping methods for you from cart items

    global $woocommerce;
    $cart = wc()->cart->get_shipping_packages();
    $shippingMethods =  wc()->shipping->calculate_shipping_for_package($cart);
    return $sm;
查看更多
登录 后发表回答