Skip to content

Commit

Permalink
Merge pull request #19 from wuunder/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
TimD90 authored Dec 16, 2019
2 parents fee7f8f + c515c7c commit c9896e5
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 83 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Please file changes under `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed` o
The format is based on [Keep a Changelog](http://keepachangelog.com/).
## Unreleased

## [1.3.2](https://github.com/kabisa/wuunder-webshopplugin-shopware/releases/tag/1.3.2) - 2019-11-16

### Fixed
- Weight and value to API
- Action buttons in order list
- Fixed re-login after booking

## [1.3.1](https://github.com/kabisa/wuunder-webshopplugin-shopware/releases/tag/1.3.1) - 2019-11-05

###
Expand Down
38 changes: 18 additions & 20 deletions Wuunder/Controllers/Backend/WuunderShipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Shopware_Controllers_Backend_WuunderShipment extends Enlight_Controller_Ac
{
use ReturnsJson;

private static $WUUNDER_PLUGIN_VERSION = array("product" => "Shopware extension", "version" => array("build" => "1.3.1", "plugin" => "1.0"));
private static $WUUNDER_PLUGIN_VERSION = array("product" => "Shopware extension", "version" => array("build" => "1.3.2", "plugin" => "1.0"));

public function getWhitelistedCSRFActions()
{
Expand All @@ -37,7 +37,7 @@ public function redirectAction()

$order_id = $this->Request()->getPost('order_id');

$url = $this->getWuunderRedirectUrl($order_id);
$url = intval($config['testmode']) === 1 ? 'https://api-staging.wearewuunder.com/api/bookings?' : 'https://api.wearewuunder.com/api/bookings?';
$data = $this->getData($order_id);

$res = Request::post($url, $data)
Expand All @@ -58,23 +58,6 @@ public function redirectAction()
$this->returnJson(['redirect' => $redirect, "error" => $res->body]);
}

private function getWuunderRedirectUrl($order_id)
{
$config = Shopware()->Container()
->get('shopware.plugin.config_reader')
->getByPluginName('Wuunder');
$base_url = $config['base_url'];

$redirect_url = $base_url . '/backend';
$redirect_url = 'redirect_url=' . urlencode($redirect_url);
$webhook_url = $base_url . '/wuunder_shipment?order_id=' . $order_id;
$webhook_url = 'webhook_url=' . urlencode($webhook_url);

$wuunder_redirect = intval($config['testmode']) === 1 ? 'https://api-staging.wearewuunder.com/api/bookings?' : 'https://api.wearewuunder.com/api/bookings?';

return $wuunder_redirect . $redirect_url . '&' . $webhook_url;
}

private function getData($order_id)
{
$order_repo = Shopware()->Models()->getRepository(Order::class);
Expand All @@ -88,8 +71,12 @@ private function getData($order_id)

$description = "";
$orderDetails = $order->getDetails();
$value = 0;
$weight = 0;
foreach ($orderDetails as $orderDetail) {
$description .= '- ' . $orderDetail->getQuantity() . 'x ' . $orderDetail->getArticleName() . "\r\n";
$value += round($orderDetail->getPrice(), 2) * 100;
$weight += round($orderDetail->getArticleDetail()->getWeight(), 2) * 1000;
}

$config = Shopware()->Container()
Expand Down Expand Up @@ -124,14 +111,25 @@ private function getData($order_id)
'zip_code' => $shippingAddress->getZipcode(),
];

$config = Shopware()->Container()
->get('shopware.plugin.config_reader')
->getByPluginName('Wuunder');
$base_url = $config['base_url'];
$redirect_url = $base_url . '/backend/';
$webhook_url = $base_url . '/wuunder_shipment?order_id=' . $order_id;

$body = [
'pickup_address' => $this->getPickupAddress(),
'delivery_address' => $delivery_address,
'customer_reference' => $order->getNumber(),
'description' => $description,
'value' => $value,
'weight' => $weight,
'preferred_service_level' => $preferredServiceLevel,
'source' => self::$WUUNDER_PLUGIN_VERSION,
'parcelshop_id' => isset($parcelshopId) ? $parcelshopId : null
'parcelshop_id' => isset($parcelshopId) ? $parcelshopId : null,
'redirect_url' => $redirect_url,
'webhook_url' => $webhook_url
];

return $body;
Expand Down
5 changes: 2 additions & 3 deletions Wuunder/Views/backend/wuunder/controller/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ Ext.define('Shopware.apps.Wuunder.controller.List', {
},

onShipOrder: function (record) {
var baseUrl = ("{config name='base_url' namespace='Wuunder'}");
Ext.Ajax.request({
method: 'POST',
url: baseUrl + '/backend/wuunder_shipment/redirect',
url: '{url controller=WuunderShipment action=redirect}',
params: { order_id: record.get('id') },
success: function (response, opts) {
var data = Ext.decode(response.responseText);
Ext.util.Cookies.set('wuunderOrderOverviewAfterRedirect', 1);
window.location = data.redirect;
window.location.href = data.redirect;
}
});
},
Expand Down
28 changes: 14 additions & 14 deletions Wuunder/Views/backend/wuunder/view/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
Ext.define('Shopware.apps.Wuunder.view.List', {
override: 'Shopware.apps.Order.view.list.List',

getColumns: function () {
createActionColumn: function () {
var me = this;
var columns = me.callParent(arguments);
columns.push(me.createWuunderColumn());
return columns;

var items = [
me.createOpenCustomerColumn(),
/*{if {acl_is_allowed privilege=delete}}*/
me.createDeleteOrderColumn(),
/*{/if}*/
me.createEditOrderColumn()
];

return Ext.create('Ext.grid.column.Action', {
width: 130,
items: items.concat(me.createWuunderIcon())
});
},

createWuunderIcon: function () {
Expand Down Expand Up @@ -135,16 +145,6 @@ Ext.define('Shopware.apps.Wuunder.view.List', {

}
}]
},

createWuunderColumn: function () {
var me = this;

return Ext.create('Ext.grid.column.Action', {
width: 50,
dataIndex: 'wuunderShipmentData',
items: me.createWuunderIcon()
});
}
});
//{/block}
44 changes: 0 additions & 44 deletions Wuunder/Views/backend/wuunder/view/list/list.js

This file was deleted.

3 changes: 2 additions & 1 deletion Wuunder/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"license": "proprietary",
"link": "http:\/\/www.wearewuunder.com",
"author": "Wuunder",
"currentVersion": "1.3.1",
"currentVersion": "1.3.2",
"changelog": {
"nl": {
"1.3.2": "Fixed icons order grid",
"1.3.1": "Added quantity in order desc to wuunder",
"1.3.0": "Added parcelshop locator",
"1.2.4": "Fixed mix street and housenumber field",
Expand Down
7 changes: 6 additions & 1 deletion Wuunder/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
<label lang="en">Wuunder shipping module</label>
<label lang="nl">Wuunder verzendmodule</label>

<version>1.3.1</version>
<version>1.3.2</version>
<copyright>(c) by Wuunder</copyright>
<license>proprietary</license>
<link>http://www.wearewuunder.com</link>
<author>Wuunder</author>
<compatibility minVersion="5.3.0"/>

<changelog version="1.3.2">
<changes lang="de">Fixed action icons in order list</changes>
<changes lang="en">Fixed action icons in order list</changes>
</changelog>

<changelog version="1.3.1">
<changes lang="de">Added quantity in order desc to wuunder</changes>
<changes lang="en">Added quantity in order desc to wuunder</changes>
Expand Down

0 comments on commit c9896e5

Please sign in to comment.