Skip to content

Commit 352ebb9

Browse files
authored
Add option to Change the created_via field.
Can be useful when WooCommerce is being used from multiply sources. For example, with plugins like Point of Sale for WooCommerce.
1 parent a044edf commit 352ebb9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

includes/mutation/class-order-create.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ public static function get_input_fields() {
108108
'type' => 'Boolean',
109109
'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'wp-graphql-woocommerce' ),
110110
),
111+
'createdVia' => array(
112+
'type' => 'String',
113+
'description' => __( 'Order created via', 'wp-graphql-woocommerce' ),
114+
),
111115
);
112116

113117
return $input_fields;
@@ -169,7 +173,7 @@ public static function mutate_and_get_payload() {
169173
throw new UserError( __( 'Customer ID is invalid.', 'wp-graphql-woocommerce' ) );
170174
}
171175

172-
$order->set_created_via( 'graphql-api' );
176+
$order->set_created_via( ! empty( $input['createdVia'] ) ? $input['createdVia'] : 'graphql-api' );
173177
$order->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) );
174178
$order->calculate_totals( true );
175179

0 commit comments

Comments
 (0)