Skip to content

Instantly share code, notes, and snippets.

@marcusig
Created June 27, 2022 13:03
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/adfd658e4548677a15059cb810b9ccb9 to your computer and use it in GitHub Desktop.
Save marcusig/adfd658e4548677a15059cb810b9ccb9 to your computer and use it in GitHub Desktop.
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