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/bugs #368

Merged
merged 9 commits into from
Oct 22, 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
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use function NewfoldLabs\WP\ModuleLoader\register;

define( 'NFD_ECOMMERCE_MODULE_VERSION', '1.4.0-beta.8' );
define( 'NFD_ECOMMERCE_MODULE_VERSION', '1.4.0-beta.9' );

if ( function_exists( 'is_admin' ) && is_admin() ) {
$old_woocommerce_module_version = get_option( 'nfd_ecommerce_module_version' );
Expand Down
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', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '857fc5b5930751df9c71');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '06f7324e4a155909e837');
10 changes: 5 additions & 5 deletions includes/Data/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@ final class Plugins {
'file' => 'sensei-lms/sensei-lms.php'
),
//Add An Affiliate Program
'yith-woocommerce-affiliates-premium' => array(
'yith-woocommerce-affiliates' => array(
'url' => 'admin.php?page=yith_wcaf_panel&tab=settings&sub_tab=settings-general',
'file' => 'yith-woocommerce-affiliates-premium/init.php'
),
//Setup Bookings
'yith-woocommerce-booking-premium' => array(
'yith-woocommerce-booking' => array(
'url' => 'edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1',
'file' => 'yith-woocommerce-booking-premium/init.php'
),
//Setup A Loyalty Program
'yith-woocommerce-points-and-rewards-premium' => array(
'yith-woocommerce-points-and-rewards' => array(
'url' => 'admin.php?page=yith_woocommerce_points_and_rewards&tab=points&sub_tab=points-standard',
'file' => 'yith-woocommerce-points-and-rewards-premium/init.php'
),
//Setup WishList
'yith-woocommerce-wishlist-premium' => array(
'yith-woocommerce-wishlist' => array(
'url' => 'admin.php?page=yith_wcwl_panel&tab=settings&sub_tab=settings-general',
'file' => 'yith-woocommerce-wishlist-premium/init.php'
),
//Enable Product Reviews
'yith-woocommerce-advanced-reviews-premium' => array(
'yith-woocommerce-advanced-reviews' => array(
'url' => 'admin.php?page=yith_ywar_panel',
'file' => 'yith-woocommerce-advanced-reviews-premium/init.php'
),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@newfold-labs/wp-module-ecommerce",
"description": "Brand Agnostic eCommerce Experience",
"license": "GPL-2.0-or-later",
"version": "1.4.0-beta.8",
"version": "1.4.0-beta.9",
"main": "build/index.js",
"files": [
"build/",
Expand Down
34 changes: 25 additions & 9 deletions src/components/WPSolutionsBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ export function WPSolutionsBanner() {
"nfd_slug_wonder_cart",
() =>
PluginsSdk.queries
.status("nfd_slug_wonder_cart", "sensei-lms", "wp-seo", "yith-woocommerce-affiliates-premium", "yith-woocommerce-booking-premium", "yith-woocommerce-points-and-rewards-premium", "yith-woocommerce-wishlist-premium", "yith-woocommerce-advanced-reviews-premium", "yith-woocommerce-dynamic-pricing-and-discounts")
.status("nfd_slug_wonder_cart",
"sensei-lms",
"wp-seo",
"yith-woocommerce-affiliates",
"yith-woocommerce-booking",
"yith-woocommerce-points-and-rewards",
"yith-woocommerce-wishlist",
"yith-woocommerce-advanced-reviews",
"yith-woocommerce-dynamic-pricing-and-discounts")
.then(res => {
setPluginActiveStatusArray(res?.details)
}),
Expand Down Expand Up @@ -73,7 +81,7 @@ export function WPSolutionsBanner() {
);
}
else if (apiResponse) {
if (purchasedSolution === null) {
if (purchasedSolution === null || !hasSolution) {
return (<NoExistingPlan availableSolutions={availableSolutions} />);
}
else{
Expand Down Expand Up @@ -112,16 +120,24 @@ export function WPSolutionsBanner() {
status === "active" ?
(
<Button key={`btn-${index}`} className="nfd-button nfd-button--primary nfd-mt-9 nfd-mt-auto nfd-self-start" as="a" href={url}>
{ __(`${details['buttonText']}`,"wp-module-ecommerce") }
{ __(`${details['cta']['text']}`,"wp-module-ecommerce") }
<RightArrow className="nfd-mt-2.5" />
</Button>
)
:
//installed but not active
status === "need_to_activate" ?
(
<Button key={`btn-${index}`} className="nfd-button nfd-button--primary nfd-mt-9 nfd-mt-auto nfd-self-start" as="button" data-plugin={details.basename}>
{ __(`${details['buttonText']}`,"wp-module-ecommerce") }
<Button key={`btn-${index}`}
className="nfd-button nfd-button--primary nfd-mt-9 nfd-mt-auto nfd-self-start"
as="button"
data-nfd-installer-plugin-activate={true}
data-nfd-installer-pls-slug={slug}
data-nfd-installer-pls-provider={details.plsProviderName}
data-nfd-installer-plugin-name={details.name}
data-nfd-installer-plugin-url={url}
>
{ __(`${details['cta']['text']}`,"wp-module-ecommerce") }
<RightArrow className="nfd-mt-2.5" />
</Button>
)
Expand All @@ -142,7 +158,7 @@ export function WPSolutionsBanner() {
data-nfd-installer-plugin-url={url}
isLoading={status==="installing"}
>
{ __(`${details['buttonText']}`,"wp-module-ecommerce") }
{ __(`${details['cta']['text']}`,"wp-module-ecommerce") }
<RightArrow className="nfd-mt-2.5" />
</Button>
)
Expand All @@ -160,7 +176,7 @@ export function WPSolutionsBanner() {
data-nfd-installer-plugin-url={url}
isLoading={status==="installing"}
>
{ __(`${details['buttonText']}`,"wp-module-ecommerce") }
{ __(`${details['cta']['text']}`,"wp-module-ecommerce") }
<RightArrow className="nfd-mt-2.5" />
</Button>
) : null
Expand All @@ -171,8 +187,8 @@ export function WPSolutionsBanner() {
))
:
//For type not plugin
(<Button key={`btn-${index}`} className="nfd-button nfd-button--primary nfd-mt-9 nfd-mt-auto nfd-self-start" as="a" href={details.url}>
{ __(`${details['buttonText']}`,"wp-module-ecommerce") }
(<Button key={`btn-${index}`} className="nfd-button nfd-button--primary nfd-mt-9 nfd-mt-auto nfd-self-start" as="a" href={details.cta.url}>
{ __(`${details['cta']['text']}`,"wp-module-ecommerce") }
<RightArrow className="nfd-mt-2.5" />
</Button>)

Expand Down
25 changes: 22 additions & 3 deletions src/configs/ProductsAndServices.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
wcPluginStatusParser,
wcProductsParser,
} from "./selectors";
import apiFetch from '@wordpress/api-fetch';


const getUrl = (href) => {
let [page, qs] = href.split("?");
Expand All @@ -39,11 +41,19 @@ function defineFeatureState() {
isUpsellNeeded: () => !(NewfoldRuntime.hasCapability("hasYithExtended") && NewfoldRuntime.hasCapability("hasSolution")),
featureUrl: (data) =>
data?.products.length > 0 ? data.plugins?.pluginUrl : null,
purchasedSolution: ( data ) => data.isEcomSolution !== 'WP_SOLUTION_COMMERCE',
upsellOptions: (data) => data?.upsellOptions,
};
}

export const ProductsAndServicesDefinition = (props) => ({
async function getPurchasedSolution() {
const url = NewfoldRuntime.createApiUrl("/newfold-solutions/v1/entitlements")
const res = await apiFetch( { url: `${ url }` } )
return res
}

export const ProductsAndServicesDefinition = (props) => (
{
dataDependencies: {
plugins: async () =>
PluginsSdk.queries.status(
Expand All @@ -53,6 +63,7 @@ export const ProductsAndServicesDefinition = (props) => ({
),
products: WooCommerceSdk.products.list,
upsellOptions: MarketplaceSdk.eCommerceOptions,
isEcomSolution: () => getPurchasedSolution()
},
cards: [
{
Expand Down Expand Up @@ -155,7 +166,7 @@ export const ProductsAndServicesDefinition = (props) => ({
},
{
Card: FeatureCard,
shouldRender: () => NewfoldRuntime.hasCapability("hasSolution"),
shouldRender: (state) => NewfoldRuntime.hasCapability("hasSolution") && state.purchasedSolution,
name: "booking",
assets: ({ isActive }) => ({
Image: CalendarIcon,
Expand Down Expand Up @@ -203,11 +214,15 @@ export const ProductsAndServicesDefinition = (props) => ({
"YITH Booking and Appointment for WooCommerce"
),
},
{
key: "isEcomSolution",
selector: (data) => data?.solution
}
],
},
{
Card: FeatureCard,
shouldRender: () => NewfoldRuntime.hasCapability("hasSolution"),
shouldRender: (state) => NewfoldRuntime.hasCapability("hasSolution") && state.purchasedSolution,
name: "gifts",
assets: ({ isActive }) => ({
Image: GiftIcon,
Expand Down Expand Up @@ -251,6 +266,10 @@ export const ProductsAndServicesDefinition = (props) => ({
key: "upsellOptions",
selector: findUpsellWithName("YITH WooCommerce Gift Cards"),
},
{
key: "isEcomSolution",
selector: (data) => data?.solution
}
],
},
],
Expand Down
Loading
Loading