Skip to content
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

Fix/stats not showing discount for sale #40348

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import usePricingData from './use-pricing-data';

const PriceComponent = ( { slug }: { slug: string } ) => {
const { discountPrice, fullPrice, currencyCode } = usePricingData( slug );

return (
<div className={ styles.priceContainer }>
{ discountPrice && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection';

const parsePricingData = ( pricingForUi: ProductCamelCase[ 'pricingForUi' ] ) => {
const { tiers, wpcomFreeProductSlug, introductoryOffer } = pricingForUi;

if ( pricingForUi.tiers ) {
const {
discountPrice,
Expand All @@ -33,18 +32,21 @@ const parsePricingData = ( pricingForUi: ProductCamelCase[ 'pricingForUi' ] ) =>
}

const {
discountPrice,
discountPricePerMonth,
fullPrice,
fullPricePerMonth,
currencyCode,
isIntroductoryOffer,
wpcomProductSlug,
} = pricingForUi;
const hasDiscount = discountPrice && discountPrice !== fullPrice;
const eligibleForIntroDiscount = ! introductoryOffer?.reason;
return {
wpcomFreeProductSlug,
wpcomProductSlug,
discountPrice:
// Only display discount if site is elgible
isIntroductoryOffer && ! introductoryOffer?.reason ? discountPricePerMonth : null,
hasDiscount && eligibleForIntroDiscount ? discountPricePerMonth : null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I am wrong, but I think we can do it this way where the discount isn't shown if the site is not eligible for an intro discount since sales are always for new purchases only 🤔 Let me know if I am wrong or am missing something. There may be an edge case in there that this would not work for

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think this is correct. I mean, it sounds right to me! 👍

fullPrice: fullPricePerMonth,
currencyCode,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const useEvaluationRecommendations = () => {
// in zero(0) unownedRecommendedModules.
const ownedProducts = (
process?.env?.NODE_ENV === 'development'
? [ 'anti-spam', 'extras', 'stats', 'jetpack-ai' ]
? [ 'anti-spam', 'extras', 'jetpack-ai' ]
: getMyJetpackWindowInitialState( 'lifecycleStats' )?.ownedProducts || []
) as JetpackModule[];
// We filter out owned modules, and return the top recommendations
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix stats not showing sale discount
Loading