Skip to content

Commit

Permalink
Merge branch 'PRESS4-400' into release-1.3.22
Browse files Browse the repository at this point in the history
  • Loading branch information
manikantakailasa committed Feb 9, 2024
2 parents 31e64de + 46fdcaa commit cc081e9
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 129 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '6c718e3c13b65348751e');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '6307329585bdd0c557f9');
22 changes: 17 additions & 5 deletions includes/Data/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,39 @@ final class Plugins
'url' => 'admin.php?page=wc-settings',
),
'nfd_slug_yith_woocommerce_customize_myaccount_page' => array(
'file_extented' => 'yith-woocommerce-customize-myaccount-page-extended/init.php',
'file_premium' => 'yith-woocommerce-customize-myaccount-page-premium/init.php',
'file' => 'yith-woocommerce-customize-myaccount-page/init.php',
'url' => 'admin.php?page=yith_wcmap_panel',
),
'nfd_slug_yith_woocommerce_gift_cards' => array(
'file' => 'yith-woocommerce-gift-cards-premium/init.php',
'file_extented' => 'yith-woocommerce-gift-cards-extended/init.php',
'file_premium' => 'yith-woocommerce-gift-cards-premium/init.php',
'file' => 'yith-woocommerce-gift-cards/init.php',
'url' => 'admin.php?page=yith_woocommerce_gift_cards_panel',
),
'nfd_slug_yith_woocommerce_wishlist' => array(
'file' => 'yith-woocommerce-wishlist-premium/init.php',
'file_extented' => 'yith-woocommerce-wishlist-extended/init.php',
'file_premium' => 'yith-woocommerce-wishlist-premium/init.php',
'file' => 'yith-woocommerce-wishlist/init.php',
'url' => 'admin.php?page=yith_wcwl_panel',
),
'nfd_slug_yith_woocommerce_ajax_product_filter' => array(
'file' => 'yith-woocommerce-ajax-product-filter-premium/init.php',
'file_extented' => 'yith-woocommerce-ajax-product-filter-extended/init.php',
'file_premium' => 'yith-woocommerce-ajax-product-filter-premium/init.php',
'file' => 'yith-woocommerce-ajax-product-filter/init.php',
'url' => 'admin.php?page=yith_wcan_panel',
),
'nfd_slug_yith_woocommerce_booking' => array(
'file' => 'yith-woocommerce-booking-premium/init.php',
'file_extented' => 'yith-woocommerce-booking-extended/init.php',
'file_premium' => 'yith-woocommerce-booking-premium/init.php',
'file' => 'yith-woocommerce-booking/init.php',
'url' => 'admin.php?page=yith_wcbk_panel',
),
'yith-woocommerce-ajax-search' => array(
'file' => 'yith-woocommerce-ajax-search-premium/init.php',
'file_extented' => 'yith-woocommerce-ajax-search-extended/init.php',
'file_premium' => 'yith-woocommerce-ajax-search-premium/init.php',
'file' => 'yith-woocommerce-ajax-search/init.php',
'url' => 'admin.php?page=yith_wcas_panel',
),
'nfd_slug_yith_shippo_shippings_for_woocommerce' => array(
Expand Down
4 changes: 2 additions & 2 deletions includes/RestApi/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public function get_plugins_status( \WP_REST_Request $request) {
continue;
}
$status = 'need_to_install';
if ( file_exists( WP_PLUGIN_DIR . '/' . $info['file'] ) ) {
$active = \is_plugin_active( $info['file'] );
if ( file_exists( WP_PLUGIN_DIR . '/' . $info['file_extented'] ) ||file_exists( WP_PLUGIN_DIR . '/' . $info['file_premium'] ) ||file_exists( WP_PLUGIN_DIR . '/' . $info['file'] ) ) {
$active = (\is_plugin_active( $info['file_extented'] ) || \is_plugin_active( $info['file_premium'] )|| \is_plugin_active( $info['file'] ));
if ( $active ) {
$status = 'active';
} else {
Expand Down
106 changes: 102 additions & 4 deletions src/components/YITHPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,102 @@ import { YITHPluginsDefinitions } from "../configs/YITHPlugins.config";
import { Section } from "./Section";
import { useCardManager } from "./useCardManager";
import classNames from "classnames";
import { useEffect, useState } from "@wordpress/element";
import apiFetch from "@wordpress/api-fetch";
import { NewfoldRuntime } from "../sdk/NewfoldRuntime";
import { YithFeatureCard } from "./YithFeatureCard";
import filter from "../icons/brands/yith-woocommerce-ajax-product-filter.svg";
import search from "../icons/brands/yith-woocommerce-ajax-search.svg";
import booking from "../icons/brands/yith-woocommerce-booking.svg";
import customizeAccount from "../icons/brands/yith-woocommerce-customize-myaccount-page.svg";
import gift from "../icons/brands/yith-woocommerce-gift-card.svg";
import wishList from "../icons/brands/yith-woocommerce-wishlist.svg";
import { RuntimeSdk } from "../sdk/runtime";

export function YITHPlugins({ woo, wpModules }) {
const isBluehost = RuntimeSdk?.brandSettings?.brand?.includes("bluehost");
const yithPluginsMap = new Map([
[
"fc4cbc14-470d-471b-b448-c6666e5b763d",
{
title: "nfd_slug_yith_woocommerce_booking",
name: "YITH Booking and Appointment for WooCommerce",
learnMore:
isBluehost &&
"https://www.bluehost.com/help/article/yith-booking-and-appointment-for-woocommerce",
image: booking,
},
],
[
"e307cb8f-24b5-46e1-81e3-83de32c62c78",
{
title: "yith-woocommerce-ajax-search",
name: "YITH WooCommerce AJAX Search",
image: search,
},
],
[
"93c942e4-36fb-46be-867b-5f0d014adb22",
{
title: "nfd_slug_yith_woocommerce_wishlist",
name: "YITH WooCommerce Wishlist",
learnMore:
isBluehost &&
"https://www.bluehost.com/help/article/yith-woocommerce-wishlist",
image: wishList,
},
],
[
"c7025d24-a05a-4f01-bca7-5c9bcd17bb76",
{
title: "nfd_slug_yith_woocommerce_ajax_product_filter",
name: "YITH WooCommerce Ajax Product Filter",
learnMore:
isBluehost &&
"https://www.bluehost.com/help/article/yith-woocommerce-ajax-product-filter",
image: filter,
},
],
[
"f7834881-f5df-43ab-9c7e-c4e6969f5606",
{
title: "nfd_slug_yith_woocommerce_gift_cards",
name: "YITH WooCommerce Gift Cards",
learnMore:
isBluehost &&
"https://www.bluehost.com/help/article/yith-woocommerce-gift-cards",
image: gift,
},
],
[
"58701f50-cb5c-4b39-b030-edadf4af6f97",
{
title: "nfd_slug_yith_woocommerce_customize_myaccount_page",
name: "YITH WooCommerce Customize My Account Page",
learnMore:
isBluehost &&
"https://www.bluehost.com/help/article/yith-woocommerce-customize-my-account-page",
image: customizeAccount,
},
],
]);
let [cards] = useCardManager(
YITHPluginsDefinitions({ notify: wpModules.notify }),
{ refreshInterval: 10 * 1000, isPaused: () => !woo.isActive }
);
const [yithProducts, setYithProducts] = useState([]);
useEffect(async () => {
const data = await apiFetch({
url: NewfoldRuntime.createApiUrl("/newfold-marketplace/v1/marketplace"),
});
setYithProducts(
data?.products?.data.filter(
(product) =>
product.categories?.includes("eCommerce") &&
product.categories?.length === 1
)
);
}, []);
if (!woo.isActive) {
return null;
}
Expand Down Expand Up @@ -37,10 +127,18 @@ export function YITHPlugins({ woo, wpModules }) {
"lg:nfd-grid-cols-3"
)}
>
{cards.map((cardConfig) => {
let { Card, name, ...props } = cardConfig;
return <Card key={name} {...props} />;
})}
{yithProducts
?.filter((product) => yithPluginsMap.has(product.id))
.map((product) => {
return (
<YithFeatureCard
id={product.id}
yithProducts={product}
yithPluginsMap={yithPluginsMap}
cards={cards}
/>
);
})}
</div>
</Section.Content>
</Section.Container>
Expand Down
116 changes: 116 additions & 0 deletions src/components/YithFeatureCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { Button, Card, Link, Title } from "@newfold/ui-component-library";
import { __ } from "@wordpress/i18n";
import { AnalyticsSdk } from "../sdk/analytics";
import { ArrowLongRightIcon } from "@heroicons/react/20/solid";

export function YithFeatureCard({
yithProducts: { name, description, primaryUrl },
yithPluginsMap,
id,
cards,
}) {
const cardsInfo = cards.filter(
(card) => card.name === yithPluginsMap.get(id).title
)[0];
const state = cardsInfo?.state;
const isInstallDisabled =
!state?.isActive && !state?.isQueueEmpty && !state?.isInstalling;
return (
<Card>
<Card.Content>
<img
src={yithPluginsMap.get(id).image}
className="nfd-w-12 nfd-text-[--nfd-ecommerce-text-dark]"
/>
<Title size={4} className="nfd-leading-normal nfd-my-4">
{name}
</Title>
{description ? <span>{description}</span> : null}
<br />
<br />
{yithPluginsMap.get(id).learnMore && (
<Link
className="nfd-flex nfd-mt-4 nfd-items-center nfd-gap-2 nfd-no-underline"
href={yithPluginsMap.get(id).learnMore}
target="_blank"
onClick={() =>
AnalyticsSdk.track("commerce", name, {
value: "clicked on the learn more url",
})
}
>
<span>{__("Learn More", "wp-module-ecommerce")}</span>
<ArrowLongRightIcon className="nfd-h-5 nfd-text-black" />
</Link>
)}
</Card.Content>
{isInstallDisabled ? (
<Card.Footer>
<span>
{__(
"please wait while other features are installed...",
"wp-module-ecommerce"
)}
</span>
</Card.Footer>
) : state?.isActive && state?.featureUrl !== null ? (
<Card.Footer>
<Button
className="nfd-w-full nfd-h-9 nfd-border nfd-flex nfd-items-center nfd-gap-2"
variant="secondary"
as="a"
href={state?.featureUrl}
>
<span>{state?.isActive ? __("Manage") : __("Enable")}</span>
</Button>
</Card.Footer>
) : state?.isUpsellNeeded ? (
<Card.Footer>
<Button
className="nfd-w-full nfd-h-9 nfd-border nfd-flex nfd-items-center nfd-gap-2"
variant="upsell"
as="a"
target="_blank"
{...(state?.upsellOptions?.clickToBuyId
? {
"data-action": "load-nfd-ctb",
"data-ctb-id": state?.upsellOptions.clickToBuyId,
}
: {})}
href={primaryUrl}
>
<span>{__("Purchase", "wp-module-ecommerce")}</span>
</Button>
</Card.Footer>
) : (
<Card.Footer>
<Button
className="nfd-w-full nfd-h-9 nfd-border nfd-flex nfd-items-center nfd-gap-2"
variant="secondary"
onClick={() =>
state?.isActive
? cardsInfo?.actions?.manageFeature?.(
cardsInfo?.state,
cardsInfo
)
: cardsInfo?.actions?.installFeature?.(
cardsInfo?.state,
cardsInfo
)
}
isLoading={state?.isInstalling}
disabled={state?.isDisabled}
>
<span>
{state?.isInstalling
? __("Installing...", "wp-module-ecommerce")
: state?.isActive
? __("Manage")
: __("Enable")}
</span>
</Button>
</Card.Footer>
)}
</Card>
);
}
Loading

0 comments on commit cc081e9

Please sign in to comment.