• Resolved kingbuzz0

    (@kingbuzz0)


    Hi Dan,

    First, thanks for the plugin.

    When an order is manually created and an invoice to pay is sent to a customer it seems to skip the cart and checkout part of the flow. If the user has either no address or an non valid shipping method, the user is able skip past any shipping zone restriction. They do not see any of these errors and they are premitted to send payment for the order.

    Is it possible to add an additional error message option for when the user when is_checkout_pay_page() is true? Ideally what I would like to see is the error message and link or redirect to the user’s account address page. I have a manual snippet hack to do this, but I am not getting the error to show as I like it. I am pretty new to WP functions, so I am sure it’s obvious why this isn’t working for me, but thought it would be good functionality to add to your plugin.

    function prevent_checkout_access_no_shipping() {
        // Check that WC is enabled and loaded
        if( function_exists( 'is_checkout' ) && is_checkout_pay_page() ) {
           // get shipping packages and their rate counts
            $packages = WC()->cart->get_shipping_packages();
            foreach( $packages as $key => $pkg ) {
                $calculate_shipping = WC()->shipping->calculate_shipping_for_package( $pkg );
                if( empty( $calculate_shipping['rates'] ) ) {
    				wc_print_notice ('no valid shipping address', 'error');
    				wp_redirect(esc_url (wc_get_endpoint_url('edit-address', '', wc_get_page_permalink('myaccount'))) );							      
                }
            }
        }
    }
Viewing 1 replies (of 1 total)
  • Plugin Author Dan

    (@dangoodman)

    Hi @kingbuzz0,

    Thank you for the details and the workaround.

    I think backend orders are out of the scope of this small plugin. I also didn’t hear other requests for that function so far. So, it should not be added to the plugin, at this moment at least.

Viewing 1 replies (of 1 total)

The topic ‘Manually Created Orders’ is closed to new replies.