Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter WhiteRoyal15

    (@whiteroyal15)

    I thought I would let you guys know I manage to solve the email formatting. I am not sure how to put this as a hook so I just overwrote the woocommerce file by copying the original to my theme folder.

    Basically what this code does is that it reformat the item meta display to my own layout by finding a specific keyword in the $meta[key] array.

    Hopefully this helps someone.

    // Variation
    if ( ! empty( $item_meta->meta ) ) {
    	$formatted_meta = $item_meta->get_formatted('_');
    
    	if ( ! empty( $formatted_meta ) ) {
          $meta_list = array();
    
          foreach ( $formatted_meta as $meta ) {
    
          	$keywords = array('YOUR_OWN_KEYWORD');
          	$meta_key = sanitize_html_class( sanitize_text_field( $meta['key'] ) );
          	$variationSections = false;
    
    		foreach($keywords as $keyword) {
    	        if (stripos($meta_key,$keyword) !== false) {
    				$meta_list[] = '<br/>';
    			}
    	    }
    
    		$meta_list[] = '
    			<div class="variation-' . $meta_key . '">
    			<span>'. wp_kses_post( $meta['label'] ) . ':</span>
    			<span>'. wp_kses_post( make_clickable( $meta['value'] ) ) . '</span>
    			</div>
    		';
    
          } // endforeach
    
          if ( ! empty( $meta_list ) ) {
            $output .= '<div class="variation">' . implode( '', $meta_list ) . '</div>';
          }
          $output = apply_filters( 'woocommerce_order_items_meta_display', $output, $this );
          echo $output;
        }
    }
    Thread Starter WhiteRoyal15

    (@whiteroyal15)

    Hi @girlieworks, I have copied it to my theme folder but my problem is I do not know how to go about the changes.

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