Skip to content

Instantly share code, notes, and snippets.

@supercat1510
Last active June 10, 2021 11:31
Show Gist options
  • Save supercat1510/c2c57e96baf6cb3b7da79e561813c382 to your computer and use it in GitHub Desktop.
Save supercat1510/c2c57e96baf6cb3b7da79e561813c382 to your computer and use it in GitHub Desktop.
Erweitern von sw-order-list
import { Component } from 'src/core/shopware';
import template from './sw-order-list.html.twig';
import deDE from '../../../../snippet/de-DE.json';
import enGB from '../../../../snippet/en-GB.json';
Shopware.Locale.extend('de-DE', deDE);
Shopware.Locale.extend('en-GB', enGB);
Shopware.Component.override('sw-order-list', {
template,
computed : {
orderColumns() {
let columns = this.getOrderColumns();
columns.push({
property: 'deliveries',
label: 'sw-order.list.trackingnumber',
align: 'left'
},{
property: 'countryId',
label: 'sw-order.list.country',
align: 'left'
});
return columns;
}
},
methods : {
getTrackingNumbers(order){
var trackingNumbers = "";
order.deliveries.forEach(function(item){
trackingNumbers += item.trackingCodes.join(", ");
});
return trackingNumbers;
}
}
});
Object { page: 1, limit: 25, term: undefined, filters: [], ids: [], queries: [], associations: (8) […], postFilter: [], sortings: (1) […], aggregations: [], … }
aggregations: Array []
associations: Array(8) [ {…}, {…}, {…}, … ]
0: Object { association: "addresses", criteria: {…} }
1: Object { association: "billingAddress", criteria: {…} }
association: "billingAddress"
criteria: Object { page: null, limit: null, term: null, … }
aggregations: Array []
associations: Array [ {…} ]
0: Object { association: "country", criteria: {…} }
association: "country"
criteria: Object { page: null, limit: null, term: null, … }
aggregations: Array []
associations: Array []
filters: Array []
groupFields: Array []
grouping: Array []
ids: Array []
limit: null
page: null
postFilter: Array []
queries: Array []
sortings: Array []
term: null
totalCountMode: 1
<prototype>: Object { … }
<prototype>: Object { … }
length: 1
<prototype>: Array []
filters: Array []
groupFields: Array []
grouping: Array []
ids: Array []
limit: null
page: null
postFilter: Array []
queries: Array []
sortings: Array []
term: null
totalCountMode: 1
<prototype>: Object { … }
<prototype>: Object { … }
2: Object { association: "salesChannel", criteria: {…} }
3: Object { association: "orderCustomer", criteria: {…} }
4: Object { association: "currency", criteria: {…} }
5: Object { association: "documents", criteria: {…} }
6: Object { association: "transactions", criteria: {…} }
7: Object { association: "deliveries", criteria: {…} }
{% block sw_order_list_grid_columns %}
{% parent %}
{% block sw_order_list_grid_columns_trackingcodes %}
<template #column-deliveries="{ item }">
{{ getTrackingNumbers(item)}}
</template>
{% endblock %}
{% block sw_order_list_grid_columns_country %}
<template #column-countryId="{ item }">
{% if item.billingAddress.countryId == 'c75aecfa9a764755803a7be2805f1b20' %}DE
{% elseif item.billingAddress.countryId == 'c2178f4f4542406495afaec4d8ed905e' %}AT
{% elseif item.billingAddress.countryId == 'f2b9ae01e7464501b1b21578987ac194' %}BE
{% elseif item.billingAddress.countryId == 'acd8a04a06d2451b8d90785a74df1c36' %}CH
{% elseif item.billingAddress.countryId == 'b08ab3c94f4a4be591947fb2619b8249' %}ES
{% elseif item.billingAddress.countryId == 'cc8898ac4034474b98954d061f70c743' %}FI
{% elseif item.billingAddress.countryId == 'f56f9a8basd74428e8e1937d279e2e28c' %}FR
{% elseif item.billingAddress.countryId == '1067d451f17843d297e5304ddbe7bbb8' %}HU
{% elseif item.billingAddress.countryId == 'ae359689afe9488b86198fa559fe746d' %}IT
{% else %}
{{ item.billingAddress.countryId }}
{% endif %}
</template>
{% endblock %}
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment