WC_SHIPSTATION_SHIPPED::shipping_completed( $order,  $argu )

Validation function when the trigger action is hit


Parameters Parameters

$order

(Required)

$argu

(Required)


Source Source

File: src/integrations/woocommerce/triggers/wc-shipstation-shipped.php

	public function shipping_completed( $order, $argu ) {

		if ( ! $order ) {
			return;
		}
		$user_id = $order->get_user_id();
		if ( 0 === $user_id ) {
			// Its a logged in recipe and
			// user ID is 0. Skip process
			return;
		}
		// Get real order ID from order object.
		$order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id();
		$pass_args = [
			'code'           => $this->trigger_code,
			'meta'           => $this->trigger_meta,
			'user_id'        => $user_id,
			'post_id'        => $order_id,
			'ignore_post_id' => true,
			'is_signed_in'   => $user_id,
		];
		$args = Automator()->maybe_add_trigger_entry( $pass_args, false );
		if ( $args ) {
			foreach ( $args as $result ) {
				if ( true === $result['result'] ) {
					// Add token for options
					Automator()->insert_trigger_meta(
						[
							'user_id'        => $user_id,
							'trigger_id'     => $result['args']['trigger_id'],
							'meta_key'       => $this->trigger_meta . '_TRACKING_NUMBER',
							'meta_value'     => $argu['tracking_number'],
							'trigger_log_id' => $result['args']['get_trigger_id'],
							'run_number'     => $result['args']['run_number'],
						]
					);
					// Add token for options
					Automator()->insert_trigger_meta(
						[
							'user_id'        => $user_id,
							'trigger_id'     => $result['args']['trigger_id'],
							'meta_key'       => $this->trigger_meta . '_CARRIER',
							'meta_value'     => $argu['carrier'],
							'trigger_log_id' => $result['args']['get_trigger_id'],
							'run_number'     => $result['args']['run_number'],
						]
					);
					// Add token for options
					Automator()->insert_trigger_meta(
						[
							'user_id'        => $user_id,
							'trigger_id'     => $result['args']['trigger_id'],
							'meta_key'       => $this->trigger_meta . '_SHIP_DATE',
							'meta_value'     => $argu['ship_date'],
							'trigger_log_id' => $result['args']['get_trigger_id'],
							'run_number'     => $result['args']['run_number'],
						]
					);
					// Add token for options
					Automator()->insert_trigger_meta(
						[
							'user_id'        => $user_id,
							'trigger_id'     => $result['args']['trigger_id'],
							'meta_key'       => 'order_id',
							'meta_value'     => $order_id,
							'trigger_log_id' => $result['args']['get_trigger_id'],
							'run_number'     => $result['args']['run_number'],
						]
					);
					Automator()->maybe_trigger_complete( $result['args'] );
				}
			}
		}
		return;
	}