From a5a535d3410d0da5be6ce683e000c99f8b1519ff Mon Sep 17 00:00:00 2001 From: Sergey Andrievskiy Date: Thu, 14 Nov 2019 17:25:14 +0300 Subject: [PATCH] fix(bundles): hide old price if no discount (#5561) --- docs/app/@core/data/service/bundles.service.ts | 2 +- .../backend-bundles-section.component.html | 4 +++- .../backend-bundles-section.component.ts | 18 ++++++++++++++++-- docs/app/pages/home/landing-home.module.ts | 3 +++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/app/@core/data/service/bundles.service.ts b/docs/app/@core/data/service/bundles.service.ts index 6df9ac053d..49b9a41540 100644 --- a/docs/app/@core/data/service/bundles.service.ts +++ b/docs/app/@core/data/service/bundles.service.ts @@ -91,7 +91,7 @@ export class BundlesService { storeUrl: `${this.STORE}/${item.handle}`, tags: item.tags, title: item.title, - description: (item.body_html as string).trim().replace(/^

/, '').replace(/<\/p>$/, ''), + description: (item.body_html as string).trim().replace(/<(?:.|\n)*?>/gm, ' ').replace(/ +/gm, ' '), variants: item.variants.map(variant => { return { available: variant.available, diff --git a/docs/app/pages/home/backend-bundles-section/backend-bundles-section.component.html b/docs/app/pages/home/backend-bundles-section/backend-bundles-section.component.html index 0f33ea4655..d7c2dbeb0f 100644 --- a/docs/app/pages/home/backend-bundles-section/backend-bundles-section.component.html +++ b/docs/app/pages/home/backend-bundles-section/backend-bundles-section.component.html @@ -34,7 +34,9 @@

{{ product.title }}

- ${{ (product.variants | license:selectedLicenseType).compare_at_price }} + + ${{ (product.variants | license:selectedLicenseType).compare_at_price }} + ${{ (product.variants | license:selectedLicenseType).price }}
, - @Inject(NB_WINDOW) private window) { + @Inject(NB_WINDOW) private window, + private licensePipe: LicensePipe) { } ngAfterViewInit() { @@ -48,4 +56,10 @@ export class BackendBundlesSectionComponent implements AfterViewInit { this.window.scrollTo(0, this.el.nativeElement.offsetTop); }); } + + shouldShowOldPrice(variants: ProductVariant[], selectedLicenseType: string): boolean { + const product = this.licensePipe.transform(variants, selectedLicenseType); + + return !!parseFloat(product.compare_at_price); + } } diff --git a/docs/app/pages/home/landing-home.module.ts b/docs/app/pages/home/landing-home.module.ts index bafad4b423..d5f29bd097 100644 --- a/docs/app/pages/home/landing-home.module.ts +++ b/docs/app/pages/home/landing-home.module.ts @@ -54,6 +54,9 @@ const COMPONENTS = [ SwiperModule, LandingHomeRoutingModule, ], + providers: [ + ...PIPES, + ], }) export class LandingHomeModule { }