Skip to content
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
2 changes: 1 addition & 1 deletion frontend/build/addons.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => '1e9dc81dc68591828144');
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => '71e3e008d37cf1f4a118');
2 changes: 1 addition & 1 deletion frontend/build/addons.js

Large diffs are not rendered by default.

36 changes: 23 additions & 13 deletions frontend/src/components/Addons.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useState, useEffect, useRef, useMemo, useCallback} from "react";
import { useMarketplace } from "../context/MarketplaceContext";
import { formatPluginPrice, getRebatePrice, getFullPrice } from "../utils/priceFormatter";
import { formatPluginPrice, getRebatePrice, getFullPrice, getDiscountPercentage } from "../utils/priceFormatter";
import ProductDetail from "./ProductDetail";
import ProductDetailRankMath from "./ProductDetailRankMath";
import ErrorToast from "./ErrorToast";
Expand Down Expand Up @@ -877,6 +877,10 @@ export default function Addons() {
const price = formatPluginPrice(plugin, freeLabel, uiI18n);
const fullPriceAmount = getFullPrice(plugin);
const rebatePriceAmount = getRebatePrice(plugin);
const discountPct = getDiscountPercentage(plugin);
const hasFreeTrialPeriod = plugin.i18n?.freeTrialPeriod && plugin.i18n.freeTrialPeriod.trim() !== '';
const hasFreeTrialText = plugin.i18n?.freeTrialText && plugin.i18n.freeTrialText.trim() !== '';
const hasDiscount = plugin.licenseType === "premium" && fullPriceAmount && rebatePriceAmount && discountPct > 0 && !hasFreeTrialPeriod && !hasFreeTrialText;

return (
<div
Expand All @@ -899,18 +903,24 @@ export default function Addons() {
<p className="oc-card-content gv-text-on-alternative gv-mb-sm gv-text-sm gv-flex-1">
{plugin.i18n.listingDescription || plugin.i18n.subtitle}
</p>
<span className="gv-caption-lg gv-text-bold">
<>
{plugin.licenseType === "premium" && (rebatePriceAmount > 0)
? (rebatePriceAmount !== null ? rebatePriceAmount : fullPriceAmount)
: price}
{plugin.licenseType !== "free" &&
price &&
price !== freeLabel &&
price !== (uiI18n?.labels?.freeUntilRenewal || 'Free until renewal') &&
<span className="gv-period">/{uiI18n?.labels?.timeMonth}</span>}
</>
</span>
{hasDiscount ? (
<div className="ocmp-price-wrapper">
<span className="gv-price-old gv-caption-lg">{fullPriceAmount}</span>
<span className="gv-caption-lg gv-text-bold">{rebatePriceAmount}<span className="gv-period">/{uiI18n?.labels?.timeMonth}</span></span>
<span className="gv-badge gv-badge-discount">{uiI18n?.labels?.save || 'Save'} {discountPct}%</span>
</div>
) : (
<span className="gv-caption-lg gv-text-bold">
<>
{price}
{plugin.licenseType !== "free" &&
price &&
price !== freeLabel &&
price !== (uiI18n?.labels?.freeUntilRenewal || 'Free until renewal') &&
<span className="gv-period">/{uiI18n?.labels?.timeMonth}</span>}
</>
</span>
)}
</div>
</div>
<div className="gv-span-1 gv-content-center gv-text-right">
Expand Down
Loading