Title: AddOn GET
Last modified: April 12, 2021

---

# AddOn GET

 *  [thx4jh](https://wordpress.org/support/users/thx4jh/)
 * (@thx4jh)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/addon-get/)
 * How can i get the addons for an automated json export.
 * i need to export the selected topping with the product.
 * where can i get it? how is it saved within the order?
 * best regards.
 * 🙂

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

 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/addon-get/#post-14309307)
 * Hello,
 * The selected product options are saved as order item meta:
 *     ```
       wc_add_order_item_meta($item_id, $value['name'], $value['value']);
       ```
   
 * To make it easier you can replace the code:
 *     ```
       foreach ($selectedValues as $value){
         wc_add_order_item_meta($item_id, $value['name'], $value['value']);
       }
       ```
   
 * with:
 *     ```
       $names = array();
       foreach ($selectedValues as $value){
         wc_add_order_item_meta($item_id, $value['name'], $value['value']);
         $names[] = $value['name'];
       }
       wc_add_order_item_meta($item_id, '_pofw_option_names', implode('|' ,$names));
       ```
   
 * Then you can get selected options of some order with this code:
 *     ```
       $order = wc_get_order($post->ID);
       foreach ($order->get_items() as $item_id => $item) {
   
         if (!isset($item['item_meta']['_pofw_option_names'])){
           continue;
         }
   
         $meta = $item['item_meta'];
         $optionNames = explode('|', $item['item_meta']['_pofw_option_names']);
   
         foreach ($optionNames as $name){
           if (isset($item['item_meta'][$name]))
             echo $name .' : '. $item['item_meta'][$name] . '<br/>';
         }
   
       }
       ```
   
 * Stanislav
 *  Thread Starter [thx4jh](https://wordpress.org/support/users/thx4jh/)
 * (@thx4jh)
 * [5 years ago](https://wordpress.org/support/topic/addon-get/#post-14456244)
 * heyhey. in which file do i find the code to replace it? thx! is there an option
   to export the “topping” as standalone? so pommes 2 money and ketchup 0,5 money?
 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [5 years ago](https://wordpress.org/support/topic/addon-get/#post-14457944)
 * Hello,
 * >in which file do i find the code to replace it
 * My previous message is about the file:
    wp-content/plugins/product-options-for-
   woocommerce/Model/Observer.php
 * You can get the price of the selected option value with code like this:
 *     ```
       foreach ($this->getProductOptions($productId) as $oId => $option){
             if (!isset($selectedValues[$oId])){
               continue;
             }
   
             $selectedValue = $selectedValues[$oId];
   
             $value = '';        
             if ($option['type'] == 'drop_down' || $option['type'] == 'radio'){
               if (is_array($selectedValue)){
                 continue;
               }
               $vId = (int) $selectedValue;
               if (isset($option['values'][$vId])){
                 $valueTitle = $option['values'][$vId]['title'];
                 $valuePrice = $option['values'][$vId]['price'];
               }
             }
       }
       ```
   
 * Stanislav

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

The topic ‘AddOn GET’ is closed to new replies.

 * ![](https://ps.w.org/product-options-for-woocommerce/assets/icon-256x256.png?
   rev=1892402)
 * [Simple Product Options for WooCommerce](https://wordpress.org/plugins/product-options-for-woocommerce/)
 * [Support Threads](https://wordpress.org/support/plugin/product-options-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/product-options-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/product-options-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/product-options-for-woocommerce/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/addon-get/#post-14457944)
 * Status: not resolved