Skip to content

Commit

Permalink
fixes static urls, added platform info
Browse files Browse the repository at this point in the history
  • Loading branch information
timoj committed May 28, 2018
1 parent a04984a commit 4c049fc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
24 changes: 17 additions & 7 deletions admin/controller/module/wuunder.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,16 @@ private function buildWuunderData($order_id)
'height' => $defHeight,
'weight' => $defWeight,
'delivery_address' => $customerAdr,
'pickup_address' => $pickupAdr
'pickup_address' => $pickupAdr,
'source' => array(
"product" => "Opencart 2 extension",
"version" => array(
"build" => "1.2.1",
"plugin" => "1.0"),
"platform" => array(
"name" => "OpenCart",
"build" => VERSION
))
);
}

Expand All @@ -268,16 +277,17 @@ public function generateBookingUrl()
$this->load->model('module/wuunder');
if (!$this->model_module_wuunder->checkLabelExists($order_id)) {
$booking_token = uniqid();
// $this->model_module_wuunder->insertBookingToken($order_id, $booking_token);

if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' && $_SERVER['HTTPS']) {
$protocol = "https://";
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
$base = HTTP_SERVER;
$catBase = HTTP_CATALOG;
} else {
$protocol = "http://";
$base = HTTPS_SERVER;
$catBase = HTTP_CATALOG;
}

$redirectUrl = urlencode($protocol . $this->request->server['SERVER_NAME'] . "/admin/index.php?route=sale/order&label=created&token=" . $this->session->data['token']);
$webhookUrl = urlencode($protocol . $this->request->server['SERVER_NAME'] . "/index.php?route=module/wuunder/webhook&order=" . $order_id . "&token=" . $booking_token);
$redirectUrl = urlencode($base . "index.php?route=sale/order&label=created&token=" . $this->session->data['token']);
$webhookUrl = urlencode($catBase . "index.php?route=module/wuunder/webhook&order=" . $order_id . "&token=" . $booking_token);

if (intval($this->config->get('wuunder_api'))) {
$apiUrl = 'https://api.wearewuunder.com/api/bookings?redirect_url=' . $redirectUrl . '&webhook_url=' . $webhookUrl;
Expand Down
13 changes: 7 additions & 6 deletions vqmod/xml/orders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@
$this->load->model('module/wuunder');
foreach ($results as $result) {
$label_info = $this->load->controller('module/wuunder/getLabelInfo', $result['order_id']);
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' && $_SERVER['HTTPS']) {
$protocol = "https://";
} else {
$protocol = "http://";
}
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
$base = HTTP_SERVER;
} else {
$base = HTTPS_SERVER;
}
$data['orders'][] = array(
'order_id' => $result['order_id'],
'label_id' => ($label_info ? $label_info['label_id'] : null),
'label_url' => ($label_info ? $label_info['label_url'] : null),
'label_tt_url' => ($label_info ? $label_info['label_tt_url'] : null),
'booking_url' => ($label_info ? $label_info['booking_url'] : null),
'base' => $base,
'order_status_code' => $this->model_module_wuunder->getOrderStatusCode($result['order_id']),
'generate_booking_url' => $protocol . $this->request->server['SERVER_NAME'] . "/admin/index.php?route=module/wuunder/generateBookingUrl&order=" . $result['order_id'] . "&token=" . $this->session->data['token'],
'generate_booking_url' => $base . "index.php?route=module/wuunder/generateBookingUrl&order=" . $result['order_id'] . "&token=" . $this->session->data['token'],
]]></add>
</operation>
<operation info="add warning info">
Expand Down
8 changes: 4 additions & 4 deletions vqmod/xml/orders_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
<ul class="wuunder-icons">
<?php if (is_null($order['label_id'])) {
if (is_null($order['booking_url']) || empty($order['booking_url'])) { ?>
<a href="<?php echo $order['generate_booking_url']; ?>" title="<?php echo $create_label; ?>"><img class="wuunder-icon" src="/admin/view/image/wuunder/create-label.png"/></a>
<a href="<?php echo $order['generate_booking_url']; ?>" title="<?php echo $create_label; ?>"><img class="wuunder-icon" src="<?php echo $order['base']; ?>view/image/wuunder/create-label.png"/></a>
<?php } else { ?>
<a href="<?php echo $order['booking_url']; ?>" title="<?php echo $create_label; ?>"><img class="wuunder-icon" src="/admin/view/image/wuunder/create-label.png" /></a>
<a href="<?php echo $order['booking_url']; ?>" title="<?php echo $create_label; ?>"><img class="wuunder-icon" src="<?php echo $order['base']; ?>view/image/wuunder/create-label.png" /></a>
<?php }
} else { ?>
<a href="<?php echo $order['label_url']; ?>" title="<?php echo $download_label; ?>" target="_blank"><img class="wuunder-icon" src="/admin/view/image/wuunder/print-label.png" /></a>
<a href="<?php echo $order['label_tt_url']; ?>" title="<?php echo $follow_shipment; ?>" target="_blank"><img class="wuunder-icon" src="/admin/view/image/wuunder/in-transit.png" /></a>
<a href="<?php echo $order['label_url']; ?>" title="<?php echo $download_label; ?>" target="_blank"><img class="wuunder-icon" src="<?php echo $order['base']; ?>view/image/wuunder/print-label.png" /></a>
<a href="<?php echo $order['label_tt_url']; ?>" title="<?php echo $follow_shipment; ?>" target="_blank"><img class="wuunder-icon" src="<?php echo $order['base']; ?>view/image/wuunder/in-transit.png" /></a>
<?php } ?>
</ul>
<a href="<?php echo $order['view']; ?>
Expand Down

0 comments on commit 4c049fc

Please sign in to comment.