• Hello there,

    Here is how I want it.

    Once users have added an item in their cart they can go to their cart and can see postal code text field followed by submit button.

    When user enters postal code and presses submit button it leads them to checkout page.

    The checkout page displays available shipping methods only related to the postal code.

    When you go back to cart page you can also see available shipping methods.

    I want it like this, that when user enters postal code and presses enter, The cart page is refreshed and available methods are displayed.

    To achieve this, I need to initiate everything a checkout do.

    Currently, I’m using this code but it seems like that it is not doing everything a checkout page do to display all available shipping methods.

    if (isset($_GET['get_quote'])) {
    
    				$shipping_postcode=$_POST['shipping_postcode'];
    
    				WC()->customer->set_shipping_postcode($shipping_postcode);
    				WC()->customer->set_postcode($shipping_postcode);
    				WC()->shipping->calculate_shipping_for_package(WC()->cart->cart_contents);
    
    			}

    https://ww.wp.xz.cn/plugins/woocommerce/

The topic ‘Woocommerce Function To Get Available Methods’ is closed to new replies.