Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
1.2 kB
4
Indexable
Never
function b2bking_add_new_order_admin_list_column_content( $column, $order_id = 0 ) {
	  
	    global $woocommerce, $post;

	    if ($order_id === 0){
	    	if (isset($post)){
	    		if (isset($post->ID)){
	    			$order_id = $post->ID;
	    		}
	    	}
	    }
	   
	    if ( 'b2bking_check_is_b2b_order' === $column ) {

	    	if ($order_id !== 0){
	    		$order = wc_get_order( $order_id );
	    		$customer_id = $order->get_customer_id();
	    		$customer_b2b = get_user_meta($customer_id,'b2bking_b2buser', true);
	    		if ($customer_b2b === 'yes'){
	    		    echo '<p style="text-align:right;"><span class="dashicons dashicons-yes-alt"></span></p>';
	    		}	

	    		// set meta as well
	    		$is_b2b_meta = $order->get_meta('b2bking_is_b2b_order');
	    		if (empty($is_b2b_meta)){
	    			// set
	    			if ($customer_b2b === 'yes'){
	    				$order->update_meta_data( 'b2bking_is_b2b_order', 'yes' );
	    				$order->update_meta_data( 'b2bking_b2b_group', get_user_meta($customer_id,'b2bking_customergroup', true) );
	    			} else {
	    				$order->update_meta_data( 'b2bking_is_b2b_order', 'no' );
	    			}
	    			$order->save();
	    		}
	    	}
	       	        
	    }   
	}
Leave a Comment