• Resolved dimaregabriele

    (@dimaregabriele)


    good morning

    I installed the WooCommerce Checkout Add-ons plugin, and created a new field that I see in the orders table. I would like to know how I can export this field, in Set up fields to export I don’t see it.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hello

    1. please, create fake order and fill new field.
    2. use button “Add field” in section “Setup fields”, you should see new key n the dropdown.

    thanks, Alex

    Thread Starter dimaregabriele

    (@dimaregabriele)

    I don’t see the corresponding metakey ..

    Plugin Author algol.plus

    (@algolplus)

    my bad, please check this page https://algolplus.com/plugins/snippets-plugins/

    read note at top of the page!

    Thread Starter dimaregabriele

    (@dimaregabriele)

    I have already added that code in the child theme.

    Thread Starter dimaregabriele

    (@dimaregabriele)

    how should I adjust this line?

    var $fields = array('Student Name','Student Grade Lavel','Teacher Name');// edit this line!!

    Plugin Author algol.plus

    (@algolplus)

    please, put field labels in this line

    Thread Starter dimaregabriele

    (@dimaregabriele)

    my column is called “Regalo” .

    Thread Starter dimaregabriele

    (@dimaregabriele)

    i put this code in child function theme

    // "Checkout Add-ons" plugin
    class WOE_Checkout_Addons_Mod {
    	var $fields = array('Regalo');// edit this line!!
    	function __construct() {
    		add_filter('woe_get_order_fields', array($this,'add_order_fields') );
    		add_action('woe_order_export_started', array($this,'get_fee_details') );
    		add_filter('woe_fetch_order_row', array($this,'fill_new_columns'), 10, 2);
    	}
    	
    	function add_order_fields($fields) {
    		foreach($this->fields as $pos=>$name) {
    			$fields['fee_addon_'.$pos] = array('segment'=>'other','label'=>$name, 'colname'=>$name,'checked'=>1);
    		}	
    		return $fields;
    	}
    	
    	function get_fee_details($order_id) {
    		$this->fee_data = array();
    		
    		$order = new WC_Order($order_id);
    		foreach($order->get_items("fee") as $item_id=>$item) {
    			$pos = array_search($item['name'],$this->fields);
    			if( $pos  !== false) {
    				$item_meta = $order->get_item_meta( $item_id );
    				$this->fee_data[$pos] = join(", ", $item_meta['_wc_checkout_add_on_value']); // many values?
    			}
    		}
    		return $order_id; 
    	}
    	
    	// add new values to row
    	function fill_new_columns($row,$order_id) {
    		foreach($this->fields as $pos=>$name) {
    			if(isset($row['fee_addon_'.$pos]) AND isset($this->fee_data[$pos]) )
    				$row['fee_addon_'.$pos] = $this->fee_data[$pos] ;
    		}		
    		return $row;
    	}
    }
    new WOE_Checkout_Addons_Mod();
    
    Plugin Author algol.plus

    (@algolplus)

    please, check section >Setup Fields>Others.

    Thread Starter dimaregabriele

    (@dimaregabriele)

    ok thanks! sorry

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘export custom column’ is closed to new replies.