mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 15:40:11 +01:00
fix(bundles): hide old price if no discount (#5561)
This commit is contained in:
parent
9e85f2aab5
commit
a5a535d341
4 changed files with 23 additions and 4 deletions
|
|
@ -91,7 +91,7 @@ export class BundlesService {
|
||||||
storeUrl: `${this.STORE}/${item.handle}`,
|
storeUrl: `${this.STORE}/${item.handle}`,
|
||||||
tags: item.tags,
|
tags: item.tags,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
description: (item.body_html as string).trim().replace(/^<p>/, '').replace(/<\/p>$/, ''),
|
description: (item.body_html as string).trim().replace(/<(?:.|\n)*?>/gm, ' ').replace(/ +/gm, ' '),
|
||||||
variants: item.variants.map(variant => {
|
variants: item.variants.map(variant => {
|
||||||
return {
|
return {
|
||||||
available: variant.available,
|
available: variant.available,
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,9 @@
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<div class="package-card__price-wrapper">
|
<div class="package-card__price-wrapper">
|
||||||
<span class="package-card__price package-card__price--old">${{ (product.variants | license:selectedLicenseType).compare_at_price }}</span>
|
<span class="package-card__price package-card__price--old" *ngIf="shouldShowOldPrice(product.variants, selectedLicenseType)">
|
||||||
|
${{ (product.variants | license:selectedLicenseType).compare_at_price }}
|
||||||
|
</span>
|
||||||
<span class="package-card__price">${{ (product.variants | license:selectedLicenseType).price }}</span>
|
<span class="package-card__price">${{ (product.variants | license:selectedLicenseType).price }}</span>
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ product.storeUrl }}?utm_source=ngx_admin_landing&utm_medium=buy_bundle_{{ selectedLicenseType }}"
|
<a href="{{ product.storeUrl }}?utm_source=ngx_admin_landing&utm_medium=buy_bundle_{{ selectedLicenseType }}"
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,15 @@ import { Observable } from 'rxjs';
|
||||||
import { delay, filter, take } from 'rxjs/operators';
|
import { delay, filter, take } from 'rxjs/operators';
|
||||||
import { NB_WINDOW } from '@nebular/theme';
|
import { NB_WINDOW } from '@nebular/theme';
|
||||||
|
|
||||||
import { BUNDLE_LICENSE, BundlesService, Feature, Product } from '../../../@core/data/service/bundles.service';
|
import {
|
||||||
|
BUNDLE_LICENSE,
|
||||||
|
BundlesService,
|
||||||
|
Feature,
|
||||||
|
Product,
|
||||||
|
ProductVariant,
|
||||||
|
} from '../../../@core/data/service/bundles.service';
|
||||||
import { Descriptions, DescriptionsService } from '../../../@core/data/service/descriptions.service';
|
import { Descriptions, DescriptionsService } from '../../../@core/data/service/descriptions.service';
|
||||||
|
import { LicensePipe } from '../backend-bundles-section/license.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-backend-bundles-section',
|
selector: 'ngx-backend-bundles-section',
|
||||||
|
|
@ -34,7 +41,8 @@ export class BackendBundlesSectionComponent implements AfterViewInit {
|
||||||
private bundlesService: BundlesService,
|
private bundlesService: BundlesService,
|
||||||
private activatedRoute: ActivatedRoute,
|
private activatedRoute: ActivatedRoute,
|
||||||
private el: ElementRef<HTMLElement>,
|
private el: ElementRef<HTMLElement>,
|
||||||
@Inject(NB_WINDOW) private window) {
|
@Inject(NB_WINDOW) private window,
|
||||||
|
private licensePipe: LicensePipe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
|
@ -48,4 +56,10 @@ export class BackendBundlesSectionComponent implements AfterViewInit {
|
||||||
this.window.scrollTo(0, this.el.nativeElement.offsetTop);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,9 @@ const COMPONENTS = [
|
||||||
SwiperModule,
|
SwiperModule,
|
||||||
LandingHomeRoutingModule,
|
LandingHomeRoutingModule,
|
||||||
],
|
],
|
||||||
|
providers: [
|
||||||
|
...PIPES,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class LandingHomeModule {
|
export class LandingHomeModule {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue