Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Export configuration data on separate lines - starting point
<?php
add_filter( "woe_fetch_order_products", function ($products, $order, $labels, $format, $static_vals) {
foreach( $order->get_items('line_item') as $pos => $item) {
if ( $config_data = $item->get_meta( '_configurator_data' ) ) {
foreach( $config_data as $selection ) {
// Get the item name. E.g. Farve, or Vaelg overdel
$layer_name = $selection->get_layer( 'name' );
// Get the item's selected choice. E.g. Lady top loose
$choice_name = $selection->get_choice( 'name' );
}
// Add a "product" line with the details collected above.
// See examples on https://docs.algolplus.com/algol_order_export/add-product-rows/
// $product[] = ...
}
}
return $products;
} , 10, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment