• Resolved Frankzappafication

    (@frankzappafication)


    I would like the products to be in One Column how do I do this as currently Quantity, Shipping, SKUK, Product Shipping Class, Quantity is all in different fields

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

    (@algolplus)

    Hi

    Could you visit the page https://algolplus.com/plugins/code-samples/ ?
    There is a code “add product field “Quantity x Name”

    if you provide sample string , I can adjust this code for you.

    Thread Starter Frankzappafication

    (@frankzappafication)

    Hi that is almost there, however for Filemaker I require the order details to be one line & field “Product Quantity: x, Product SKU: x, Product Name: x, Product Variation: x, Product Size: x, Product Unit Price: x, Product Total Price: x | Product Quantity: x, Product SKU: x, Product Name: x, Product Variation: x, Product Size: x, Product Unit Price: x, Product Total Price: x | etc…”

    Thanks

    Thread Starter Frankzappafication

    (@frankzappafication)

    Oops and thanks I really do appreciate the help…

    Plugin Author algol.plus

    (@algolplus)

    see my comments inside!

    // All products in one cell as 
    // Product Quantity: x, Product SKU: x, Product Name: x, Product Variation: x, Product Size: x, Product Unit Price: x, Product Total Price: x | another item...
    add_filter('woe_get_order_product_fields', function ($fields,$format) {
    	$fields['all_in_one'] = array( 'label' => 'All products in one cell', 'colname' => 'All products in one cell', 'checked' => 1 );
    	return $fields;
    }, 10, 2);
    add_filter('woe_fetch_order_products', function ($products, $order, $labels, $format, $static_vals) {
    	$lines = array();
    	foreach ( $order->get_items('line_item') as $item_id=>$item ) {
    		$product   = $order->get_product_from_item( $item );
    		$product = apply_filters( "woe_get_order_product", $product );
    		$item_meta = get_metadata( 'order_item', $item_id );
    		
    		$l = array();
    		$l[]= 'Product Quantity: '.$item['qty'];
    		$l[]= 'Product SKU: '.$product->sku;
    		$l[]= 'Product Name: '.$item['name'];
    		$l[]= 'Product Variation: '.$item['Color']; // adjust this line
    		$l[]= 'Product Size: '.$item['Size'];// adjust this line
    		$l[]= 'Product Unit Price: '.wc_format_decimal($order->get_item_total( $item, false, true ), 2) ;
    		$l[]= 'Product Total Price: '.wc_format_decimal($item['subtotal'],2);
    		$lines[]= join(",",$l);
    	}	
    	
    	$item = array('all_in_one'=>join(" | ",$lines));
    	return array($item);
    }, 10, 5);
    
    Thread Starter Frankzappafication

    (@frankzappafication)

    this is great… really fantastic! thank you!

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Merge Product Order Fields’ is closed to new replies.