Skip to content

Commit

Permalink
Add tax class to settings. Update to v1.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
radua committed Sep 28, 2023
1 parent ad6e9eb commit 6cef85a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 9 deletions.
Binary file modified flagship.ocmod.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modification>
<code>flagship</code>
<name>FlagShip Modification</name>
<version>1.0.12</version>
<version>1.0.13</version>
<author>FlagShip Courier Solutions</author>
<link>https://www.flagshipcompany.com</link>
<file path="admin/controller/sale/order.php">
Expand Down
4 changes: 4 additions & 0 deletions upload/admin/controller/extension/shipping/flagship.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public function index() {
$data['action_couriers'] = $this->url->link('extension/shipping/flagship/couriers', 'user_token=' . $this->session->data['user_token'], true);
$data['test_token_check'] = $this->checkIfTokenIsTestToken();

$this->load->model('localisation/tax_class');
$data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
$data['shipping_flagship_tax_class_id'] = $this->config->get('shipping_flagship_tax_class_id');

if (isset($this->request->post['shipping_flagship_postcode'])) {
$data['shipping_flagship_postcode'] = $this->request->post['shipping_flagship_postcode'];
Expand Down Expand Up @@ -172,6 +175,7 @@ public function updateShipment() : int {
$shipment = $this->model_extension_shipping_flagship->updateShipment($flagship_shipment_id,$payload,$order_id,$orderLink);

$this->response->redirect($orderLink);
return 0;
}

public function confirmShipment() : int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$_['entry_couriers'] = 'Select Couriers to show';
$_['entry_test'] = 'Test Environment';
$_['entry_packing'] = 'Packing API';
$_['entry_tax'] = 'Tax class';
// Error
$_['error_permission'] = 'Warning: You do not have permission to modify FlagShip!';
$_['error_shipping_flagship_postcode'] = 'Invalid Postcode';
Expand Down
13 changes: 8 additions & 5 deletions upload/admin/model/extension/shipping/flagship.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function updateShipment(int $flagship_shipment_id,array $payload,int $ord
$url = $this->config->get('smartship_api_url').'/ship/shipments/'.$flagship_shipment_id;
$token = $this->config->get('shipping_flagship_token');

$shipment = $this->apiRequest($url,$payload,$token,'PUT',30,'1.0.12',$orderId,$orderLink);
$shipment = $this->apiRequest($url,$payload,$token,'PUT',30,'1.0.13',$orderId,$orderLink);
return $shipment["response"]->content;
}

Expand Down Expand Up @@ -147,7 +147,7 @@ public function getSelectedCouriers() : \stdClass {
public function prepareShipment(array $payload, int $orderId, string $orderLink) : \stdClass {
$url = $this->config->get('smartship_api_url').'/ship/prepare';
$token = $this->config->get('shipping_flagship_token');
$shipment = $this->apiRequest($url,$payload,$token,'POST',30,'1.0.12',$orderId,$orderLink);
$shipment = $this->apiRequest($url,$payload,$token,'POST',30,'1.0.13',$orderId,$orderLink);
return $shipment["response"]->content;
}

Expand Down Expand Up @@ -200,12 +200,12 @@ protected function getFlagshipShipmentStatus(int $shipment_id, int $orderId) : ?
$url = $this->config->get('smartship_api_url').'/ship/shipments/'.$shipment_id;
$token = $this->config->get('shipping_flagship_token');

$shipment = $this->apiRequest($url,[],$token,'GET',10,'1.0.12',$orderId);
$shipment = $this->apiRequest($url,[],$token,'GET',10,'1.0.13',$orderId);
$status = $shipment["response"]->content->status;
return $status;
}

protected function apiRequest(string $url,array $json, string $apiToken,string $method, int $timeout, string $version='1.0.12', int $orderId=0, string $orderLink='') : array {
protected function apiRequest(string $url,array $json, string $apiToken,string $method, int $timeout, string $version='1.0.13', int $orderId=0, string $orderLink='') : array {

$curl = curl_init();
$storeName = $this->config->get('config_name');
Expand Down Expand Up @@ -237,7 +237,10 @@ protected function apiRequest(string $url,array $json, string $apiToken,string $
];
curl_close($curl);

if(($httpcode >= 400 && $httpcode < 600) || ($httpcode === 0) || ($response === false) || ($httpcode === 209)){
if(($httpcode >= 400 && $httpcode < 600) ||
($httpcode === 0) ||
($response === false) ||
($httpcode === 209)){
return [];
}
return $responseArray;
Expand Down
19 changes: 18 additions & 1 deletion upload/admin/view/template/extension/shipping/flagship.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div class="form-group">
<label class="col-sm-2 control-label" for="input-token">{{ entry_token }}</label>
<div class="col-sm-10">
<input type="text" name="shipping_flagship_token" id="input-token" placeholder = "{{ placeholder_token }}"" class="form-control">
<input type="text" name="shipping_flagship_token" id="input-token" placeholder = "{{ placeholder_token }}" class="form-control">
{% if token_set %}
{% if test_token_check %}
<div class="text-info">{{text_test_token_set}}</div>
Expand All @@ -61,6 +61,23 @@
{% endif %}
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label" for="input-tax-class">{{ entry_tax }}</label>
<div class="col-sm-10">
<select name="shipping_flagship_tax_class_id" id="input-tax-class" class="form-control">
<option value="0">{{ text_none }}</option>
{% for tax_class in tax_classes %}
{% if tax_class.tax_class_id == shipping_flagship_tax_class_id %}
<option value="{{ tax_class.tax_class_id }}" selected="selected">{{ tax_class.title }}</option>
{% else %}
<option value="{{ tax_class.tax_class_id }}">{{ tax_class.title }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label" for="input-fee">{{ entry_fee }}</label>
<div class="col-sm-10">
Expand Down
4 changes: 2 additions & 2 deletions upload/catalog/model/extension/shipping/flagship.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getQuote($address)
];
}

if (isset($this->session->data['error'])) {
if (array_key_exists('error', $this->session->data) && isset($this->session->data['error'])) {
$quote_data = [];
$error = $this->session->data['error'];
unset($this->session->data['error']);
Expand Down Expand Up @@ -77,7 +77,7 @@ protected function getRates(array $payload)
}


protected function apiRequest(string $url,array $json, string $apiToken,string $method, int $timeout, string $flagshipFor='OpenCart',string $version='1.0.12') : array {
protected function apiRequest(string $url,array $json, string $apiToken,string $method, int $timeout, string $flagshipFor='OpenCart',string $version='1.0.13') : array {

$curl = curl_init();
$options = [
Expand Down

0 comments on commit 6cef85a

Please sign in to comment.