WooCommerce Shipping API functions

戏子无情 提交于 2020-01-07 03:05:18

问题


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

and table rate shipping

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.

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


回答1:


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;


来源:https://stackoverflow.com/questions/33405929/woocommerce-shipping-api-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!