Skip to content

Instantly share code, notes, and snippets.

@marcusig
Last active November 8, 2022 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusig/a513ab46004ac7141874a3e1e09ac662 to your computer and use it in GitHub Desktop.
Save marcusig/a513ab46004ac7141874a3e1e09ac662 to your computer and use it in GitHub Desktop.
Remove HTML from the configuration export, and add the image link
<?php
// Trip the HTML from the configuration
add_filter( 'woe_get_order_product_value_Configuration', function( $value, $order, $item ) {
// Handle "dynamic data" orders
if ( strpos( $value, 'order-configuration-details' ) && function_exists( 'mkl_pc' ) && mkl_pc( 'admin' ) ) {
$meta = new stdClass();
$meta->value = $value;
$value = mkl_pc( 'admin' )->order->format_meta( $value, $meta, $item );
}
// Add line breaks and Remove html
if ( strpos( $value, 'order-configuration' ) ) {
$value = str_replace( '<div', "\n\r<div", $value );
$value = trim( strip_tags( $value ) );
}
return $value;
}, 20, 3 );
// Add the image in an other column
add_filter( 'woe_get_order_product_value__config_image', function( $value, $order, $item ) {
if ( function_exists( 'mkl_pc' ) ) {
$img = mkl_pc( 'frontend' )->order->get_order_item_image( $item, 'url' );
if ( $img ) {
$value = $img;
}
}
return $value;
}, 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment