autoship_get_schedule_order_customer_data
( src/orders.php) This function retrieves the customer and payment information to be used across all orders. The function takes a WC Order object or WC Order Id ($order) as its parameter. This function includes the autoship_get_scheduled_order_customer_data filter.
Example
/** * Retrieves and Creates the QPilot customer if needed. * @see autoship_get_order_payment_data * * @param WC_Order|int $order A WC Order object or order id. * @return array An array containing the Autoship Scheduled * order data for the supplied WC Order */ function autoship_get_scheduled_order_customer_data ( $order ) { // Get order $order = wc_get_order( $order ); if ( ! $order ) { return array(); } // Get payment data $payment_data = autoship_get_order_payment_data( $order->get_id() ); // Get / create the customer $autoship_customer_id = autoship_get_autoship_customer_id( $order->get_user_id(), 'autoship_get_scheduled_order_customer_data' ); $scheduled_order_data = array( "CustomerId" => 0, "OriginalExternalId" => "wc-" . $order->get_id(), "Status" => "Active", "NextOccurrenceUtc" => '', "FrequencyType" => '', "Frequency" => '', "CurrencyIso" => $order->get_currency(), "ScheduledOrderItems" => array(), "Note" => $order->get_customer_note(), // Shipping "ShippingFirstName" => $order->get_shipping_first_name(), "ShippingLastName" => $order->get_shipping_last_name(), "ShippingStreet1" => $order->get_shipping_address_1(), "ShippingStreet2" => $order->get_shipping_address_2(), "ShippingCity" => $order->get_shipping_city(), "ShippingState" => $order->get_shipping_state(), "ShippingPostcode" => $order->get_shipping_postcode(), "ShippingCountry" => $order->get_shipping_country(), "Company" => $order->get_shipping_company(), "PhoneNumber" => $order->get_billing_phone(), ); if ( null != $payment_data ) { $payment_method_data = array( "Description" => $payment_data->description, "Type" => $payment_data->type, "GatewayCustomerId" => $payment_data->gateway_customer_id, "GatewayPaymentId" => $payment_data->gateway_payment_id, "BillingFirstName" => $order->get_billing_first_name(), "BillingLastName" => $order->get_billing_last_name(), "BillingStreet1" => $order->get_billing_address_1(), "BillingStreet2" => $order->get_billing_address_2(), "BillingCity" => $order->get_billing_city(), "BillingState" => $order->get_billing_state(), "BillingPostcode" => $order->get_billing_postcode(), "BillingCountry" => $order->get_billing_country() ); $scheduled_order_data["PaymentMethod"] = $payment_method_data; } return apply_filters( 'autoship_get_scheduled_order_customer_data', $scheduled_order_data, $order); }