Created
June 27, 2022 13:03
-
-
Save marcusig/adfd658e4548677a15059cb810b9ccb9 to your computer and use it in GitHub Desktop.
Export configuration data on separate lines - starting point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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