public function order_update_packages()
 {
     $order = $this;
     $wc_order = $this->order;
     $cart = [];
     //build a cart like array
     foreach ($wc_order->get_items() as $item_id => $item) {
         if (!isset($item['product_id'])) {
             continue;
         }
         $cart[] = ['data' => get_product($item['product_id']), 'quantity' => $item['qty']];
     }
     // var_dump( get_class_methods( $wc_order ) );
     $shipping_method = new WC_Shipping_Method_Bring();
     $packages = $shipping_method->pack_order($cart);
     $order->checkout_update_packages(json_encode($packages));
 }
 public function process_admin_options()
 {
     parent::process_admin_options();
     // Process services table
     $services = Fraktguiden_Helper::get_services_data();
     $field_key = $this->get_field_key('services');
     $vars = ['custom_prices', 'free_shipping_checks', 'free_shipping_thresholds'];
     foreach ($vars as $var) {
         ${$var} = [];
     }
     // Only process options for enabled services
     foreach ($services as $key => $service) {
         foreach ($vars as $var) {
             $data_key = "{$field_key}_{$var}";
             if (isset($_POST[$data_key][$key])) {
                 ${$var}[$key] = $_POST[$data_key][$key];
             }
         }
     }
     foreach ($vars as $var) {
         $data_key = "{$field_key}_{$var}";
         update_option($data_key, ${$var});
     }
 }