autoship_order_customer_dashboard_icon_column_conten​t (function)

(src/orders.php) Used to populate the custom Autoship column in My Account > Orders. Takes the (WooCommerce) $order as a parameter.

Function

/**
* Populates the Custom Autoship Column on the WooCommerce My Account > Orders Dash
*
* @param WC_Order $order The current row's WC Order
*/
function autoship_order_customer_dashboard_icon_column_content( $order ){

  if ( !$order )
  return;

  $tooltip      = array();
  $external_data= array(
    'source'        => '',
    'class'         => '',
    'origin_id'     => '',
    'scheduled_ids' => '',
    'error'         => ''
  );

  // Get the Source flag.
  $external_data['source']        = autoship_get_scheduled_order_related_flag( $order );

  // Get the Scheduled order id if it exists
  $external_data['origin_id']     = autoship_get_order_scheduled_order_origin_id( $order );

  // Get the Scheduled orders generated from this order if they exist.
  $external_data['scheduled_ids'] = autoship_get_order_created_scheduled_orders_key( $order );

  if ( empty( $external_data['origin_id'] ) && empty( $external_data['scheduled_ids'] ) && empty( $external_data['source'] ))
  return;

  $external_data['notices'] = array();

  $scheduled_order_label  = autoship_search_for_translate_text( 'Scheduled Order' );
  $scheduled_orders_label = autoship_search_for_translate_text( 'Scheduled Orders' );

  // If this is an Order generated from a Scheduled Order
  if ( !empty( $external_data['origin_id'] ) ){

    $external_data['source']    = 'result';
    $external_data['class']     = 'created';
    $schedule    = $order->get_meta( 'Schedule' , true);

  	$external_data['notices'][] = wc_sanitize_tooltip( sprintf( __( '%s %d','autoship' ), $scheduled_order_label, $external_data['origin_id'] ) );
  	$external_data['notices'][] = wc_sanitize_tooltip( sprintf( __( 'Scheduled for %s','autoship' ), $schedule ) );

  // If this is an order from which Scheduled Orders are Generated
  } else if ( !empty( $external_data['scheduled_ids'] ) ) {

    $external_data['source']    = 'source';
    $external_data['class']     = 'scheduled';
    $external_data['notices'][] = wc_sanitize_tooltip( sprintf( __( 'Created %s(s) %s','autoship' ), $scheduled_order_label, implode( ', ', $external_data['scheduled_ids'] ) ) );

  // Otherwise do we know if this is even a source or result?
  } else if ( !empty( $external_data['source'] ) ) {

    $external_data['class']     = 'source' === $external_data['source'] ? 'maybe-scheduled' : 'maybe-created';
    $external_data['notices'][] = 'source' === $external_data['source'] ?
    sprintf( __( 'This order contains Items with associated Schedules and may have produced %s.','autoship' ), $scheduled_orders_label ) :
    sprintf( __( 'This order might have been generated by a %s.','autoship' ), $scheduled_order_label );

    do_action( 'autoship_order_customer_dashboard_icon_column_content_maybe_scheduled_order', $external_data, $order );

    return;

  }

  $scheduled_orders_url = autoship_get_scheduled_orders_url();

  $external_data['notices'] = apply_filters( 'autoship_populate_order_customer_dashboard_icon_tooltip_components', $external_data['notices'], $external_data, $order );
  printf( '<a href="%s"><mark class="order-origin-icon %s autoship-tips" data-tip="%s"><span></span></mark></a>', $scheduled_orders_url, $external_data['class'], apply_filters( 'autoship_populate_order_customer_dashboard_icon_tooltip', wp_kses_post( implode( "<br/>", $external_data['notices'] ) ), $external_data, $order ) );

}