Support » Plugin: Advanced Shipment Tracking for WooCommerce » Automatically Add Tracking

  • Resolved jeremypreed

    (@jeremypreed)


    Hi,

    This plugin seems great. I’m using the ali2woo plugin (https://ali2woo.com/) to automatically sync tracking numbers from aliexpress orders. It will add a tracking number to an order and change the status to completed.

    Is there a way to automate your plugin when tracking is synced so the completed status email has the tracking number / provider? It seems the two plugins store tracking numbers using different meta keys. I’m a developer and I’m open to writing a custom action/hook/filter to link the two together so the completed email that gets sent is automated with this plugins tracking meta. Are there any existing hooks/actions/filters I can use to automatically trigger Woo Advanced Shipping Tracking when a tracking number is added from ali2woo?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jeremypreed

    (@jeremypreed)

    I’ve answered my own question. Here’s what I added to my theme’s functions.php to solve my problem below. Please let me know if you suggest a better solution.

    
    // Update Advanced Shipment Tracking when Ali2Woo tracking numbers are added
    function update_order_tracking( $order_id, $tracking_code ) {
    
    	$st = WC_Advanced_Shipment_Tracking_Actions::get_instance();
    	$default_provider = get_option("wc_ast_default_provider" );
    	
    	$args = array(
    		'tracking_provider'        => $default_provider,
    		'tracking_number'          => $tracking_code,
    		'date_shipped'             => date_i18n( 'Y-m-d', current_time( 'timestamp' ) ),				
    	);
    	
    	$st->add_tracking_item( $order_id, $args );
    
    }
    add_action( 'wcae_after_add_tracking_code', 'update_order_tracking', 10, 2 );
    
    • This reply was modified 2 years, 1 month ago by jeremypreed.
    Plugin Author Zorem

    (@zorem)

    Awesome! I will add your code to our documentation for other users who would like to have compatibility with the All2Woo plugin
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Automatically Add Tracking’ is closed to new replies.