WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Privacy_Exporters::get_order_personal_data() protected WC 3.4.0

Get personal data (key/value pairs) for an order object.

{} Это метод класса: WC_Privacy_Exporters{}

Возвращает

Массив.

Использование

$result = WC_Privacy_Exporters::get_order_personal_data( $order );
$order(WC_Order) (обязательный)
Order object.

Список изменений

С версии 3.4.0 Введена.

Код WC_Privacy_Exporters::get_order_personal_data() WC 5.8.0

protected static function get_order_personal_data( $order ) {
	$personal_data   = array();
	$props_to_export = apply_filters(
		'woocommerce_privacy_export_order_personal_data_props',
		array(
			'order_number'               => __( 'Order Number', 'woocommerce' ),
			'date_created'               => __( 'Order Date', 'woocommerce' ),
			'total'                      => __( 'Order Total', 'woocommerce' ),
			'items'                      => __( 'Items Purchased', 'woocommerce' ),
			'customer_ip_address'        => __( 'IP Address', 'woocommerce' ),
			'customer_user_agent'        => __( 'Browser User Agent', 'woocommerce' ),
			'formatted_billing_address'  => __( 'Billing Address', 'woocommerce' ),
			'formatted_shipping_address' => __( 'Shipping Address', 'woocommerce' ),
			'billing_phone'              => __( 'Phone Number', 'woocommerce' ),
			'billing_email'              => __( 'Email Address', 'woocommerce' ),
			'shipping_phone'             => __( 'Shipping Phone Number', 'woocommerce' ),
		),
		$order
	);

	foreach ( $props_to_export as $prop => $name ) {
		$value = '';

		switch ( $prop ) {
			case 'items':
				$item_names = array();
				foreach ( $order->get_items() as $item ) {
					$item_names[] = $item->get_name() . ' x ' . $item->get_quantity();
				}
				$value = implode( ', ', $item_names );
				break;
			case 'date_created':
				$value = wc_format_datetime( $order->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) );
				break;
			case 'formatted_billing_address':
			case 'formatted_shipping_address':
				$value = preg_replace( '#<br\s*/?>#i', ', ', $order->{"get_$prop"}() );
				break;
			default:
				if ( is_callable( array( $order, 'get_' . $prop ) ) ) {
					$value = $order->{"get_$prop"}();
				}
				break;
		}

		$value = apply_filters( 'woocommerce_privacy_export_order_personal_data_prop', $value, $prop, $order );

		if ( $value ) {
			$personal_data[] = array(
				'name'  => $name,
				'value' => $value,
			);
		}
	}

	// Export meta data.
	$meta_to_export = apply_filters(
		'woocommerce_privacy_export_order_personal_data_meta',
		array(
			'Payer first name'     => __( 'Payer first name', 'woocommerce' ),
			'Payer last name'      => __( 'Payer last name', 'woocommerce' ),
			'Payer PayPal address' => __( 'Payer PayPal address', 'woocommerce' ),
			'Transaction ID'       => __( 'Transaction ID', 'woocommerce' ),
		)
	);

	if ( ! empty( $meta_to_export ) && is_array( $meta_to_export ) ) {
		foreach ( $meta_to_export as $meta_key => $name ) {
			$value = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta_value', $order->get_meta( $meta_key ), $meta_key, $order );

			if ( $value ) {
				$personal_data[] = array(
					'name'  => $name,
					'value' => $value,
				);
			}
		}
	}

	/**
	 * Allow extensions to register their own personal data for this order for the export.
	 *
	 * @since 3.4.0
	 * @param array    $personal_data Array of name value pairs to expose in the export.
	 * @param WC_Order $order An order object.
	 */
	$personal_data = apply_filters( 'woocommerce_privacy_export_order_personal_data', $personal_data, $order );

	return $personal_data;
}