• Resolved valixxtv

    (@valixxtv)


    Hey.

    I’ve found an article to merge two columns into one. Is the following code correct?

    Product Variation should be merged with a custom column called “_pa_farbe-ts”.

    add_filter('woe_get_order_value_product_variation_1',function ($value, $order,$fieldname) {
    	return get_post_meta($order->id,'_product_variation_1',true).' '.get_post_meta($order->id,'_pa_farbe-ts',true);
    },10,2);
    
    ?>

    Thank you.

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

    (@algolplus)

    hi

    almost correct.

    Could you visit section “Setup Fields” , scroll down to “Products” , click button “Setup Fields”, in which drop down will you see “_pa_farbe-ts” ? Taxonomy OR meta key ?

    thanks, Alex

    Thread Starter valixxtv

    (@valixxtv)

    Hey thanks for answering.

    It is in both but different.

    Taxonomy: __pa_farbe-ts
    Meta Key: pa_farbe-ts

    But the field below is the taxonomy one.

    Plugin Author algol.plus

    (@algolplus)

    ok, try this code

    add_filter('woe_get_order_product_value_product_variation',function ($value, $order, $item, $product, $item_meta) {
        $taxonomies = wc_get_product_terms( $item['product_id'], 'pa_farbe-ts', array( 'fields' => 'names' ) );
        if( $taxonomies ) { // is array for the product 
    		$value .= implode( ', ', $taxonomies );
        }
    	return $value;
    },10,5);
    
    Thread Starter valixxtv

    (@valixxtv)

    So far it works with a small issue. Thank you very much.

    Is there a way to insert a whitespace? It shouldn’t be like “hellotext”, but “hello text”.

    • This reply was modified 8 years, 8 months ago by valixxtv.
    Plugin Author algol.plus

    (@algolplus)

    try use

    $value .= ‘ ‘.implode( ‘, ‘, $taxonomies );

    Thread Starter valixxtv

    (@valixxtv)

    Thank you very much for your help!

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Merge two columns.’ is closed to new replies.