add regular price and sale price flag to product apis and types

This commit is contained in:
Raja Sekar Manimaran 2024-09-18 12:55:42 +05:30
parent 1b58098848
commit 72b5bff518
2 changed files with 8 additions and 0 deletions

View File

@ -27,6 +27,8 @@ export type SearchAPIProductType = {
billing_period: string;
billing_period_interval: number;
currency: string;
is_on_Sale: boolean;
regular_price: number;
};
export interface Product {
@ -58,6 +60,8 @@ export interface Product {
billingPeriod?: string;
billingPeriodInterval?: number;
currency: string;
isOnSale: boolean;
regularPrice: number;
}
export interface ProductTracksData {

View File

@ -138,6 +138,8 @@ async function fetchSearchResults(
url: product.link,
// Due to backwards compatibility, raw_price is from search API, price is from featured API
price: product.raw_price ?? product.price,
regularPrice: product.regular_price,
isOnSale: product.is_on_Sale,
averageRating: product.rating ?? null,
reviewsCount: product.reviews_count ?? null,
isInstallable: product.is_installable,
@ -408,6 +410,8 @@ const subscriptionToProduct = ( subscription: Subscription ): Product => {
icon: subscription.product_icon,
url: subscription.product_url,
price: -1,
regularPrice: -1,
isOnSale: false,
averageRating: null,
reviewsCount: null,
isInstallable: false,