-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/thumbnail images of products in view order #3273
Changes from 9 commits
a4840eb
26b3cd8
bf536a9
3f162a4
1619e9c
2cd28e5
84c24b0
6916cc1
bc53db3
ca4c5d8
b92c93a
648d192
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -44,6 +44,9 @@ | |||||
<th class="serif lh20"> | ||||||
{{ $t('Subtotal') }} | ||||||
</th> | ||||||
<th class="serif lh20"> | ||||||
{{ $t('Thumbnail') }} | ||||||
</th> | ||||||
</tr> | ||||||
</thead> | ||||||
<tbody> | ||||||
|
@@ -63,35 +66,38 @@ | |||||
<td class="fs-medium lh25" :data-th="$t('Subtotal')"> | ||||||
{{ item.row_total_incl_tax | price }} | ||||||
</td> | ||||||
<td class="fs-medium lh25"> | ||||||
<product-image :image="{src: itemThumbnail[item.sku]}" /> | ||||||
</td> | ||||||
</tr> | ||||||
</tbody> | ||||||
<tfoot> | ||||||
<tr class="brdr-top-1 brdr-cl-bg-secondary"> | ||||||
<td colspan="4" class="align-right"> | ||||||
<td colspan="5" class="align-right"> | ||||||
{{ $t('Subtotal') }} | ||||||
</td> | ||||||
<td>{{ order.subtotal | price }}</td> | ||||||
</tr> | ||||||
<tr> | ||||||
<td colspan="4" class="align-right"> | ||||||
<td colspan="5" class="align-right"> | ||||||
{{ $t('Shipping') }} | ||||||
</td> | ||||||
<td>{{ order.shipping_amount | price }}</td> | ||||||
</tr> | ||||||
<tr> | ||||||
<td colspan="4" class="align-right"> | ||||||
<td colspan="5" class="align-right"> | ||||||
{{ $t('Tax') }} | ||||||
</td> | ||||||
<td>{{ order.tax_amount + order.discount_tax_compensation_amount | price }}</td> | ||||||
</tr> | ||||||
<tr v-if="order.discount_amount"> | ||||||
<td colspan="4" class="align-right"> | ||||||
<td colspan="5" class="align-right"> | ||||||
{{ $t('Discount') }} | ||||||
</td> | ||||||
<td>{{ order.discount_amount | price }}</td> | ||||||
</tr> | ||||||
<tr> | ||||||
<td colspan="4" class="align-right"> | ||||||
<td colspan="5" class="align-right"> | ||||||
{{ $t('Grand total') }} | ||||||
</td> | ||||||
<td>{{ order.grand_total | price }}</td> | ||||||
|
@@ -137,13 +143,36 @@ | |||||
</template> | ||||||
|
||||||
<script> | ||||||
import Vue from 'vue' | ||||||
import MyOrder from '@vue-storefront/core/compatibility/components/blocks/MyAccount/MyOrder' | ||||||
import ReturnIcon from 'theme/components/core/blocks/Header/ReturnIcon' | ||||||
import ProductImage from 'theme/components/core/ProductImage' | ||||||
import { getThumbnailPath } from '@vue-storefront/core/helpers' | ||||||
import { mapActions } from 'vuex' | ||||||
|
||||||
export default { | ||||||
mixins: [MyOrder], | ||||||
components: { | ||||||
ReturnIcon | ||||||
ReturnIcon, | ||||||
ProductImage | ||||||
}, | ||||||
data () { | ||||||
return { | ||||||
itemThumbnail: [] | ||||||
} | ||||||
}, | ||||||
methods: { | ||||||
...mapActions({ | ||||||
getProduct: 'product/single' | ||||||
}) | ||||||
}, | ||||||
beforeMount () { | ||||||
this.skipGrouped(this.order.items).forEach(async item => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you also with this PR change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really see what do you mean by using find. We process a whole array here, we're not aiming at getting a single element, could you elaborate? As for computed property I completely agree. |
||||||
if (this.itemThumbnail[item.sku] === undefined || this.itemThumbnail[item.sku] === null) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's the same as
Suggested change
|
||||||
const product = await this.getProduct({ options: { sku: item.sku }, setCurrentProduct: false, setCurrentCategoryPath: false, selectDefaultVariant: false }) | ||||||
Vue.set(this.itemThumbnail, item.sku, getThumbnailPath(product.image, 80, 80)) | ||||||
} | ||||||
}) | ||||||
} | ||||||
} | ||||||
</script> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd do that on mounted, so there is no way to have problems with SSR