Skip to content

Commit

Permalink
Add option to Change the created_via field.
Browse files Browse the repository at this point in the history
Can be useful when WooCommerce is being used from multiply sources. For example, with plugins like Point of Sale for WooCommerce.
  • Loading branch information
scottyzen committed Feb 19, 2022
1 parent a044edf commit 352ebb9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/mutation/class-order-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public static function get_input_fields() {
'type' => 'Boolean',
'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'wp-graphql-woocommerce' ),
),
'createdVia' => array(
'type' => 'String',
'description' => __( 'Order created via', 'wp-graphql-woocommerce' ),
),
);

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

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

Expand Down

0 comments on commit 352ebb9

Please sign in to comment.