Answers for "woocommerce add new status order"

PHP
0

woocommerce_order_status_completed

add_action( 'woocommerce_order_status_completed', 'update_frm_entry_after_wc_order_completed' );
function update_frm_entry_after_wc_order_completed( $order_id ) {
	$order = new WC_Order( $order_id );
	$items = $order->get_items();
	foreach ( $items as $item_id => $product ) {
		if ( isset( $product['formidable_form_data'] ) && is_numeric( $product['formidable_form_data'] ) ) {
			$entry_id = $product['formidable_form_data'];
			$entry = FrmEntry::getOne( $entry_id );

			if ( $entry && $entry->form_id == 25 ) {
				$field_id = 100;//Replace 100 with the field ID to update
				$new_value = 'Complete';
				FrmEntryMeta::update_entry_meta( $entry_id, $field_id, null, $new_value );
			}
		}
	}
}
Posted by: Guest on April-14-2021
0

add new woocommerce order status programmatically

add_action( 'init', 'register_my_new_order_statuses' );
function register_my_new_order_statuses() {
    register_post_status( 'wc-order-shipped', array(
        'label'                     => _x( 'Shipped', 'Order status', 'woocommerce' ),
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped<span class="count">(%s)</span>', 'woocommerce' )
    ) );
}

add_filter( 'wc_order_statuses', 'my_new_wc_order_statuses' );
// Register in wc_order_statuses.
function my_new_wc_order_statuses( $order_statuses ) {
    $order_statuses['wc-order-shipped'] = _x( 'Shipped', 'Order status', 'woocommerce' );
    return $order_statuses;
}
Posted by: Guest on July-23-2021
0

woocommerce_order_status_completed

add_action( 'woocommerce_order_status_completed', 'update_frm_entry_after_wc_order_completed' );
function update_frm_entry_after_wc_order_completed( $order_id ) {
	$order = new WC_Order( $order_id );
	$items = $order->get_items();
	foreach ( $items as $item_id => $product ) {
		if ( isset( $product['formidable_form_data'] ) && is_numeric( $product['formidable_form_data'] ) ) {
			$entry_id = $product['formidable_form_data'];
			$entry = FrmEntry::getOne( $entry_id );

			if ( $entry && $entry->form_id == 25 ) {
				$field_id = 100;//Replace 100 with the field ID to update
				$new_value = 'Complete';
				FrmEntryMeta::update_entry_meta( $entry_id, $field_id, null, $new_value );
			}
		}
	}
}
Posted by: Guest on April-14-2021
0

add new woocommerce order status programmatically

add_action( 'init', 'register_my_new_order_statuses' );
function register_my_new_order_statuses() {
    register_post_status( 'wc-order-shipped', array(
        'label'                     => _x( 'Shipped', 'Order status', 'woocommerce' ),
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped<span class="count">(%s)</span>', 'woocommerce' )
    ) );
}

add_filter( 'wc_order_statuses', 'my_new_wc_order_statuses' );
// Register in wc_order_statuses.
function my_new_wc_order_statuses( $order_statuses ) {
    $order_statuses['wc-order-shipped'] = _x( 'Shipped', 'Order status', 'woocommerce' );
    return $order_statuses;
}
Posted by: Guest on July-23-2021

Code answers related to "woocommerce add new status order"

Browse Popular Code Answers by Language