Skip to content

Commit

Permalink
Merge branch 'trunk' into update/composer-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyakrishnai authored Feb 22, 2024
2 parents e967ab1 + 556fbed commit 161f633
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 134 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' => 'c3f16f7961a01916c59e');
<?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' => '64d8ebf708a365ec7d39');
8 changes: 8 additions & 0 deletions includes/ECommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public function __construct( Container $container ) {
add_action('woocommerce_admin_order_data_after_shipping_address', array( $this, 'display_custom_shipping_fields_in_admin' ), 10, 1 );
add_action( 'before_woocommerce_init', array( $this,'custom_payment_gateways_order'));
add_action('before_woocommerce_init', array( $this,'dismiss_woo_payments_cta'));
add_action( 'load-toplevel_page_'. $container->plugin()->id, array( $this, 'disable_creative_mail_banner' ) );

// Handle WonderCart Integrations
if ( is_plugin_active( 'wonder-cart/init.php' ) ) {
Expand Down Expand Up @@ -435,5 +436,12 @@ public function dismiss_woo_payments_cta() {
update_option('wcpay_welcome_page_incentives_dismissed', array("wcpay-promo-2023-action-discount"));
}
}

public function disable_creative_mail_banner() {
$is_dismissed = get_option( 'ce4wp_ignore_review_notice');
if (!is_array($is_dismissed) || empty($is_dismissed)) {
update_option('ce4wp_ignore_review_notice', true);
}
}

}
17 changes: 15 additions & 2 deletions src/components/OnboardingScreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Alert, Button, Title } from "@newfold/ui-component-library";
import { useState } from "@wordpress/element";
import { useEffect, useState } from "@wordpress/element";
import { __ } from "@wordpress/i18n";
import classNames from "classnames";
import { ReactComponent as ComingSoonIllustration } from "../icons/coming-soon.svg";
Expand All @@ -9,6 +9,7 @@ import { RuntimeSdk } from "../sdk/runtime";
import { OnboardingList } from "./OnboardingList";
import { Section } from "./Section";
import { SiteStatus } from "./SiteStatus";
import { WordPressSdk } from "../sdk/wordpress";

const Text = {
Pending: {
Expand Down Expand Up @@ -39,6 +40,7 @@ export function OnboardingScreen({
: Text.Live;

const [hovered, setIsHovered] = useState(false);
const [editUrl, setEditUrl] = useState('');

const handleMouseOver = () => {
setIsHovered(true);
Expand All @@ -52,6 +54,17 @@ export function OnboardingScreen({
"wpadminbar"
).style.display = "none";
};

useEffect(() => {
WordPressSdk.settings.get().then(res => {
if(res?.page_on_front && res?.show_on_front === 'page'){
setEditUrl(RuntimeSdk.adminUrl(`post.php?post=${res?.page_on_front}&action=edit`, false))
}else{
setEditUrl(RuntimeSdk.adminUrl('site-editor.php?canvas=edit'));
}
})
}, [])

return (
<Section.Container
className="nfd-welcome-section"
Expand Down Expand Up @@ -158,7 +171,7 @@ export function OnboardingScreen({
}}
as="a"
className="nfd-bg-canvas "
href={RuntimeSdk.adminUrl('site-editor.php?postType=wp_template&postId='+NewfoldRuntime.currentTheme+'//home')}
href={editUrl}
target="_blank"
variant="secondary"
data-cy="edit-site"
Expand Down
253 changes: 133 additions & 120 deletions src/components/Paypal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,137 +15,150 @@ import { ThirdPartyIntegration } from "./ThirdPartyIntegration";

const Paypal = ({ notify }) => {
useEffect(() => {
const ppButton = document.querySelector(".yith-btn-paypal");
window?.PAYPAL?.apps?.Signup?.loadScripts(document, "script");
window?.PAYPAL?.apps?.Signup?.render();
const ppButton = document.querySelector( ".yith-btn-paypal" );
if( ppButton ){
(function( d, s, id ) {
var js, ref = d.getElementsByTagName( s )[0];
if ( !d.getElementById( id ) ) {
js = d.createElement( s );
js.id = id;
js.async = true;
js.src = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
ref.parentNode.insertBefore( js, ref );
}
}( document, "script", "paypal-js" ));
window?.PAYPAL?.apps?.Signup?.loadScripts( document, "script" );
window?.PAYPAL?.apps?.Signup?.render();
}

return ()=>{
const panel = document.querySelector('#payment-details');
const panel = document.querySelector( '#payment-details' );
if( !panel && ppButton ){
ppButton.remove();
}
};
});
return (
<ThirdPartyIntegration
id="paypal"
title={__("Paypal", "wp-module-ecommerce")}
description={__(
"Online payments built for success. We help you do business in 200+ markets and 100+ currencies—even if your customers don't have PayPal.",
"wp-module-ecommerce"
)}
notify={notify}
>
{({ integrationStatus, onConnect, isInstalling }) => {
const isSetupComplete = integrationStatus?.complete;
const environment = integrationStatus?.details?.environment;
return (
<div className="nfd-border nfd-rounded-md nfd-p-6">
<div
className={classNames(
"max-[359px]:nfd-flex-col",
"min-[360px]:nfd-flex nfd-justify-between nfd-items-center min-[360px]:nfd-mb-8"
)}
>
<PaypalBrand />
{isInstalling ? (
<Button
variant="secondary"
isLoading
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Installing...", "wp-module-ecommerce")}
</Button>
) : isSetupComplete ? (
<Button
variant="secondary"
as="a"
href={integrationStatus?.integration?.plugin?.url}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Manage", "wp-module-ecommerce")}
</Button>
) : typeof yith_ppwc_login !== "undefined" &&
!parseInt(yith_ppwc_login?.liveConnected) ? (
<Link
href={yith_ppwc_login.loginURL}
variant="primary"
className="nfd-button nfd-button--primary yith-btn-paypal nfd-text-white"
target="_blank"
data-paypal-onboard-complete="onboardedCallback"
data-paypal-button="PPLtBlue"
>
{__("Connect", "wp-module-ecommerce")}
</Link>
) : (
<Button
onClick={onConnect}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Connect", "wp-module-ecommerce")}
</Button>
)}
</div>
{isSetupComplete && environment && (
<div className="nfd-flex nfd-gap-4 nfd-mt-4">
<span>{__("Environment:", "wp-module-ecommerce")}</span>
<Badge
size="large"
variant={environment === "sandbox" ? "upsell" : "plain"}
className={classNames(
"nfd-text-sm nfd-capitalize",
environment === "live" && "nfd-bg-[#178113] nfd-text-white"
)}
>
{environment}
</Badge>
</div>
)}
{!isSetupComplete && (
<div className="nfd-space-y-4 nfd-text-[#5B5B5B]">
<Title size="3">
{__("Provides flexible checkout options", "wp-module-ecommerce")}
</Title>
<ul className="nfd-pl-5 nfd-list-disc">
<li>{__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}</li>
<li>{__("White-Labeling", "wp-module-ecommerce")}</li>
<li>
{__(
"Country-specific payment methods",
"wp-module-ecommerce"
<ThirdPartyIntegration
id="paypal"
title={__("Paypal", "wp-module-ecommerce")}
description={__(
"Online payments built for success. We help you do business in 200+ markets and 100+ currencies—even if your customers don't have PayPal.",
"wp-module-ecommerce"
)}
notify={notify}
>
{({ integrationStatus, onConnect, isInstalling }) => {
const isSetupComplete = integrationStatus?.complete;
const environment = integrationStatus?.details?.environment;
return (
<div className="nfd-border nfd-rounded-md nfd-p-6">
<div
className={classNames(
"max-[359px]:nfd-flex-col",
"min-[360px]:nfd-flex nfd-justify-between nfd-items-center min-[360px]:nfd-mb-8"
)}
</li>
</ul>
<Title size="3">
{__(
" Supports many popular payment methods",
"wp-module-ecommerce"
>
<PaypalBrand />
{isInstalling ? (
<Button
variant="secondary"
isLoading
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Installing...", "wp-module-ecommerce")}
</Button>
) : isSetupComplete ? (
<Button
variant="secondary"
as="a"
href={integrationStatus?.integration?.plugin?.url}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Manage", "wp-module-ecommerce")}
</Button>
) : typeof yith_ppwc_login !== "undefined" &&
!parseInt(yith_ppwc_login?.liveConnected) ? (
<Link
href={yith_ppwc_login.loginURL}
variant="primary"
className="nfd-button nfd-button--primary yith-btn-paypal nfd-text-white"
target="_blank"
data-paypal-onboard-complete="onboardedCallback"
data-paypal-button="PPLtBlue"
>
{__("Connect", "wp-module-ecommerce")}
</Link>
) : (
<Button
onClick={onConnect}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Connect", "wp-module-ecommerce")}
</Button>
)}
</Title>
<div className="nfd-flex nfd-items-end nfd-gap-2 nfd-flex-wrap">
<VisaBrand />
<MasterCardBrand />
<AmexBrand />
<DiscoverBrand />
<VenmoBrand />
<IdealBrand />
<GiroPayBrand />
<SofortBrand />
</div>
{isSetupComplete && environment && (
<div className="nfd-flex nfd-gap-4 nfd-mt-4">
<span>{__("Environment:", "wp-module-ecommerce")}</span>
<Badge
size="large"
variant={environment === "sandbox" ? "upsell" : "plain"}
className={classNames(
"nfd-text-sm nfd-capitalize",
environment === "live" && "nfd-bg-[#178113] nfd-text-white"
)}
>
{environment}
</Badge>
</div>
)}
{!isSetupComplete && (
<div className="nfd-space-y-4 nfd-text-[#5B5B5B]">
<Title size="3">
{__("Provides flexible checkout options", "wp-module-ecommerce")}
</Title>
<ul className="nfd-pl-5 nfd-list-disc">
<li>{__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}</li>
<li>{__("White-Labeling", "wp-module-ecommerce")}</li>
<li>
{__(
"Country-specific payment methods",
"wp-module-ecommerce"
)}
</li>
</ul>
<Title size="3">
{__(
" Supports many popular payment methods",
"wp-module-ecommerce"
)}
</Title>
<div className="nfd-flex nfd-items-end nfd-gap-2 nfd-flex-wrap">
<VisaBrand />
<MasterCardBrand />
<AmexBrand />
<DiscoverBrand />
<VenmoBrand />
<IdealBrand />
<GiroPayBrand />
<SofortBrand />
</div>
</div>
)}
</div>
)}
</div>
);
}}
</ThirdPartyIntegration>
);
}}
</ThirdPartyIntegration>
);
};
export default Paypal;
25 changes: 14 additions & 11 deletions src/components/YITHPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,20 @@ export function YITHPlugins({ woo, wpModules }) {
{ 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
)
);
useEffect( () => {
const fecthApi = 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
)
);
}
fecthApi()
}, []);
if (!woo.isActive) {
return null;
Expand Down

0 comments on commit 161f633

Please sign in to comment.