Comments 1Mervin started the conversationJanuary 24, 2022 at 8:57amHi,Is there a way I can pull a custom_field that will tell me if order was done via agent or customer himself?I can accept answers as:- true/false (order via agent)- agent name (if agent made order, otherwise empty) 1,906WebWizards repliedJanuary 24, 2022 at 11:42amHi Mervin,Actually, yes, each order has a "salesking_order_placed_type" (order meta key) custom field:This can have the value of "placed_by_customer" or "placed_by_agent". 1Mervin repliedJanuary 24, 2022 at 12:20pmCool, thanks.Do you know of a way/custom code that would put following orders: salesking_order_placed_type = placed_by_customeras a custom order status? For example: on hold, or a custom one: under review 1,906WebWizards repliedJanuary 24, 2022 at 4:07pmI think you'd need to add this code to define your new order status first: add_action('init', function(){ register_post_status( 'wc-newstatus', array( 'label' => 'New Status', 'public' => true, 'show_in_admin_all_list' => false, 'show_in_admin_status_list' => true, // show count All (12) , Completed (9) , Credit purchase (2) ... 'label_count' => _n_noop( 'New status order (%s)', 'New status order (%s)' ) ) ); }); Then this code to set the status when an order is placed by customer: add_action( 'woocommerce_checkout_order_processed', function($order_id, $posted_data, $order){ $placed_by = get_post_meta($order_id,'salesking_order_placed_type', true); if ($placed_by === 'placed_by_customer'){ $order->update_status('wc-newstatus'); $order->save(); } }, 100, 3); Sign in to reply ...
Hi,
Is there a way I can pull a custom_field that will tell me if order was done via agent or customer himself?
I can accept answers as:
- true/false (order via agent)
- agent name (if agent made order, otherwise empty)
Hi Mervin,
Actually, yes, each order has a "salesking_order_placed_type" (order meta key) custom field:
This can have the value of "placed_by_customer" or "placed_by_agent".
Cool, thanks.
Do you know of a way/custom code that would put following orders:
as a custom order status? For example: on hold, or a custom one: under reviewI think you'd need to add this code to define your new order status first:
Then this code to set the status when an order is placed by customer: