• I have a plugin that will duplicate an existing woocommerce order. However, with the upgrade to 2.6, I don’t know how to create a new shipping zone/instance to attach to the duplicated order. For example, when I invoke $wc_order->add_shipping( shipping_rate), I don’t know what parameters to pass to add_shipping method. Before, I can create a shipping rate object. But now, it should be a shipping zone, but I don’t know how to create it. Can you give an example of creating a shipping zone object? Would it be something like:
    $shipzone = new WC_Shipping_Method();
    $shipzone->label = “test zone”
    $shipzone->id = “testzone:3”
    $shipzone->cost = 1.99

    Any help is appreciated.

    https://wordpress.org/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    You want to create a new zone every time you duplicate an order? That seems very un-necessary.

    Just use the N/A field and enter a shipping price: http://cld.wthms.co/14oP3/3s8QWbl0. Shipping calculations aren’t done when manually creating an order anyhow.

    Thread Starter Alan.W

    (@alanw-1)

    Of course not, just want to create an *instance* of a shipping zone. The plugin is creating(duplicating) an order via API functions, not doing it manually. But it is a good suggestion, I can input the Shipping Method by hand, until I figure out how to do it programmaticly. Anyone on WC 2.6 that can help me out?

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Don’t really understand the problem to be honest. There’s not really much of a reason to initiate a new instance of a shipping zone / method. Just transfer over the cost of shipping and the name.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create a new shipping zone instance to attach to a WC_order’ is closed to new replies.