/**
     * @param Bring_WC_Order_Adapter $order
     */
    static function render_packages($order)
    {
        $shipping_item_tip = __('Shipping item id', 'bring-fraktguiden');
        ?>
    <table class="bring-booking-packages">
      <thead>
      <tr>
        <th title="<?php 
        echo $shipping_item_tip;
        ?>
"><?php 
        _e('#', 'bring-fraktguiden');
        ?>
</th>
        <th><?php 
        _e('Product', 'bring-fraktguiden');
        ?>
</th>
        <th><?php 
        _e('Width', 'bring-fraktguiden');
        ?>
 (cm)</th>
        <th><?php 
        _e('Height', 'bring-fraktguiden');
        ?>
 (cm)</th>
        <th><?php 
        _e('Length', 'bring-fraktguiden');
        ?>
 (cm)</th>
        <th><?php 
        _e('Weight', 'bring-fraktguiden');
        ?>
 (kg)</th>
      </tr>
      </thead>
      <tbody>
      <?php 
        foreach ($order->get_packages_formatted(false, true) as $key => $package) {
            ?>
        <?php 
            $shipping_item_id = $package['shipping_item_info']['item_id'];
            $service_data = Fraktguiden_Helper::get_service_data_for_key($package['shipping_item_info']['shipping_method']['service']);
            ?>
        <tr>
          <td title="<?php 
            echo $shipping_item_tip;
            ?>
">
            <?php 
            echo $shipping_item_id;
            ?>
          </td>
          <td>
            <?php 
            echo $service_data[Fraktguiden_Helper::get_option('service_name')];
            ?>
            <?php 
            $pickup_point = $order->get_pickup_point_for_shipping_item($shipping_item_id);
            if (!empty($pickup_point)) {
                ?>
              <span class="tips"
                    data-tip="<?php 
                echo str_replace('|', '<br/>', $pickup_point['cached']);
                ?>
">
                [<?php 
                _e('Pickup Point', 'bring-fraktguiden');
                ?>
]
              </span>
              <?php 
            }
            ?>
          </td>
          <td>
            <?php 
            echo $package['dimensions']['widthInCm'];
            ?>
          </td>
          <td>
            <?php 
            echo $package['dimensions']['heightInCm'];
            ?>
          </td>
          <td>
            <?php 
            echo $package['dimensions']['lengthInCm'];
            ?>
          </td>
          <td>
            <?php 
            echo $package['weightInKg'];
            ?>
          </td>
        </tr>
      <?php 
        }
        ?>
      </tbody>
    </table>
    <?php 
    }
 /**
  * @param WC_Order $wc_order
  */
 static function send_booking($wc_order)
 {
     $order = new Bring_WC_Order_Adapter($wc_order);
     $order_id = $wc_order->id;
     $test_mode = self::is_test_mode();
     $api_key = self::get_api_key();
     $api_uid = self::get_api_uid();
     $client_url = self::get_client_url();
     $customer_number = isset($_REQUEST['_bring-customer-number']) ? $_REQUEST['_bring-customer-number'] : '';
     if (isset($_REQUEST['_bring-shipping-date']) && isset($_REQUEST['_bring-shipping-date-hour']) && isset($_REQUEST['_bring-shipping-date-minutes'])) {
         $shipping_date_time = $_REQUEST['_bring-shipping-date'] . 'T' . $_REQUEST['_bring-shipping-date-hour'] . ':' . $_REQUEST['_bring-shipping-date-minutes'] . ':00';
     } else {
         $shipping_date = self::create_shipping_date();
         $shipping_date_time = $shipping_date['date'] . "T" . $shipping_date['hour'] . ":" . $shipping_date['minute'] . ":00";
     }
     $additional_info = '';
     if (isset($_REQUEST['_bring_additional_info'])) {
         $additional_info = filter_var($_REQUEST['_bring_additional_info'], FILTER_SANITIZE_STRING);
     }
     $sender_address = self::get_sender_address($additional_info);
     $recipient_address = $order->get_recipient_address_formatted();
     // One booking request per. order shipping item.
     foreach ($order->get_fraktguiden_shipping_items() as $item_id => $shipping_method) {
         $service_id = Fraktguiden_Helper::parse_shipping_method_id($shipping_method['method_id'])['service'];
         $packages = $order->get_packages_formatted($item_id);
         $pickup_point = $order->get_pickup_point_for_shipping_item_formatted($item_id);
         $booking_request = new Bring_Booking_Request(new WP_Bring_Request());
         $booking_request->set_test_mode($test_mode)->set_content_type('application/json')->set_accept('application/json')->set_api_key($api_key)->set_api_uid($api_uid)->set_client_url($client_url);
         $consignment = new Bring_Booking_Consignment_Creator();
         $consignment->set_purchase_order($order_id)->set_shipping_date_time($shipping_date_time)->set_sender_address($sender_address)->set_recipient_address($recipient_address)->set_product_id($service_id)->set_customer_number($customer_number)->set_packages($packages);
         if (!empty($pickup_point)) {
             $consignment->set_pickup_point($pickup_point);
         }
         if (Fraktguiden_Helper::get_option('evarsling') == 'yes') {
             $product_services = ['recipientNotification' => ['email' => $recipient_address['contact']['email'], 'mobile' => $recipient_address['contact']['phoneNumber']]];
             $consignment->set_product_services($product_services);
         }
         $booking_request->add_consignment_data($consignment->create_data());
         // Start sending the booking
         if ($booking_request->is_valid()) {
             $original_order_status = $wc_order->get_status();
             // Set order status to awaiting shipping.
             $wc_order->update_status('wc-bring-shipment');
             // Send the booking.
             $response = $booking_request->send();
             // Save the response json to the order.
             $order->update_booking_response($response);
             // Download labels pdf
             if (!$order->has_booking_errors()) {
                 Bring_Booking_Labels::download_to_local($order);
             }
             // Create new status and order note.
             if (!$order->has_booking_errors()) {
                 // Check if the plugin has been configured to set a specific order status after success.
                 $status = Fraktguiden_Helper::get_option('auto_set_status_after_booking_success');
                 if ($status == 'none') {
                     // Set status back to the previous status
                     $status = $original_order_status;
                 }
                 $status_note = __("Booked with Bring" . "\n", 'bring-fraktguiden');
             } else {
                 // If there are errors, set the status back to the original status.
                 $status = $original_order_status;
                 $status_note = __("Booking errors. See the Bring Booking box for details." . "\n", 'bring-fraktguiden');
             }
             // Update status.
             $wc_order->update_status($status, $status_note);
         } else {
             // @todo: Not valid. show message?
         }
     }
 }