• Hi there,

    I am using Woocommerce and WCFM Vendor Marketplace plugins and have added meta information to my items at the time of ordering like so:

    
    add_action( 'woocommerce_checkout_create_order_line_item', 'wcfm_add_vendor_order_line_item_meta', 10, 4 );
    function wcfm_add_vendor_order_line_item_meta( $item, $cart_item_key, $values, $order ) {
      $product = $values['data'];
      if ( $product ) {
        $product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
        $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
        $vendor_address = wcfm_get_vendor_store_address_by_vendor( $vendor_id );
        if ( $vendor_id ) {
          $_wcfm_vendor_VAT_id = wcfm_get_user_meta( $vendor_id, 'wcfm_vendor_VAT_id', true );
          if ( ! empty( $vat_id ) ) {
              $item->update_meta_data( '_wcfm_vendor_vat_id', $_wcfm_vendor_VAT_id );
              $item->update_meta_data( '_wcfm_vendor_address', $vendor_address );
          }
        }
      }
    }
    
    add_filter( 'woocommerce_order_item_display_meta_key', function( $display_key, $meta = '' ) {
      if( $display_key == '_wcfm_vendor_vat_id' ) {
        $display_key = __( 'VAT ID' );
      }
      if( $display_key == '_wcfm_vendor_address' ) {
        $display_key = __( 'VENDOR ADDRESS' );
      }
      return $display_key;
    }, 50, 2 );
    

    The intentions of this code is to add address information (country, state) about WCFM vendors as well as their tax information (VAT). However I am not seeing it populate as any of the export options. Can you help me with this?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom WCFM Field’ is closed to new replies.