Add support for WooCommerce Automatic Order Printing plugin

Whether a third party plugin gets notified when WP-Lister creates an order in WooCommerce depends on how that plugin hooks into WooCommerce. It not uncommon that orders created by WP-Lister won't get processed by a third party plugin, because WP-Lister doesn't "simulate" the checkout process when it creates orders in WooCommerce, which is what some plugins expect.

Instead, WP-Lister creates the order in WooCommerce directly, which means that any checkout related action or filter hooks are not triggered. That's why there is a dedicated action hook that WP-Lister fires once it has created an order - it's called  wplister_after_create_order_with_nonexisting_items. This name should remind developers that an order created by WP-Lister can very well contain items which don't exist in WooCommerce. (More details below)

The following code snippet demonstrates how this hook can be used to implement support for a  3rd party plugin that does hook into the checkout process to automatically print orders. Developers can use this example to add support for their plugins:

// add support for WooCommerce Print Orders plugin 2.1.2 ( / woocommerce-printorders)
function my_wplister_order_creation_handler( $order_id ) {
    global $woocommerce_ext_printorders;

    // do nothing if plugin is not installed or internal structure doesn't match
    if ( ! class_exists('WooCommerce_Ext_PrintOrders') ) return;
    if ( ! $woocommerce_ext_printorders instanceof WooCommerce_Ext_PrintOrders ) return;
    if ( ! method_exists( $woocommerce_ext_printorders, 'woocommerce_payment_complete' ) ) return;

    // call WooCommerce_Ext_PrintOrders::woocommerce_payment_complete() to trigger print job
    $woocommerce_ext_printorders->woocommerce_payment_complete( $order_id );

add_action( 'wplister_after_create_order_with_nonexisting_items', 'my_wplister_order_creation_handler' );

// The above code is for WP-Lister for eBay. To support WP-Lister for Amazon as well, uncomment this line:
// add_action( 'wpla_after_create_order_with_nonexisting_items', 'my_wplister_order_creation_handler' );

This code snippet should be added to your theme's functions.php file.

What Happens to Orders that Contain Products which Don't exist in Woocommerce

Technically, WP-Lister could create WooCommerce orders for products which don't exist in WooCommerce itself. This would happen if you sell some additional listings on eBay which haven't been listed via WP-Lister (nor been imported to WordPress). Not all 3rd party plugins are able to handle an order that contains non-existing products, some plugins would simple break at that point, but if all your eBay listings do exist in WooCommerce and WP-Lister, you won't have to worry about this. 

Still need help? Contact Us Contact Us