diff --git a/includes/ECommerce.php b/includes/ECommerce.php index 83d259aa..deb6d9fe 100644 --- a/includes/ECommerce.php +++ b/includes/ECommerce.php @@ -95,6 +95,10 @@ public function __construct( Container $container ) { add_filter('woocommerce_shipping_fields', array( $this,'add_phone_number_email_to_shipping_form'), 10, 1 ); add_action('woocommerce_checkout_create_order', array( $this, 'save_custom_shipping_fields' ), 10, 1); 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' ) ); + if (($container->plugin()->id === "bluehost" && ($canAccessGlobalCTB || $hasYithExtended)) || ($container->plugin()->id === "hostgator" && $hasYithExtended)) { add_filter( 'admin_menu', array($this,'custom_add_promotion_menu_item') ); @@ -528,5 +532,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); + } + } } diff --git a/src/components/OnboardingScreen.js b/src/components/OnboardingScreen.js index dbb70907..cd4c7119 100644 --- a/src/components/OnboardingScreen.js +++ b/src/components/OnboardingScreen.js @@ -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"; @@ -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: { @@ -39,6 +40,7 @@ export function OnboardingScreen({ : Text.Live; const [hovered, setIsHovered] = useState(false); + const [editUrl, setEditUrl] = useState(''); const handleMouseOver = () => { setIsHovered(true); @@ -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 ( { 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 ( - - {({ integrationStatus, onConnect, isInstalling }) => { - const isSetupComplete = integrationStatus?.complete; - const environment = integrationStatus?.details?.environment; - return ( -
-
- - {isInstalling ? ( - - ) : isSetupComplete ? ( - - ) : typeof yith_ppwc_login !== "undefined" && - !parseInt(yith_ppwc_login?.liveConnected) ? ( - - {__("Connect", "wp-module-ecommerce")} - - ) : ( - - )} -
- {isSetupComplete && environment && ( -
- {__("Environment:", "wp-module-ecommerce")} - - {environment} - -
- )} - {!isSetupComplete && ( -
- - {__("Provides flexible checkout options", "wp-module-ecommerce")} - -
    -
  • {__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}
  • -
  • {__("White-Labeling", "wp-module-ecommerce")}
  • -
  • - {__( - "Country-specific payment methods", - "wp-module-ecommerce" + + {({ integrationStatus, onConnect, isInstalling }) => { + const isSetupComplete = integrationStatus?.complete; + const environment = integrationStatus?.details?.environment; + return ( +
    +
    -
- - {__( - " 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> )} - -
- - - - - - - -
+ {isSetupComplete && environment && ( +
+ {__("Environment:", "wp-module-ecommerce")} + + {environment} + +
+ )} + {!isSetupComplete && ( +
+ + {__("Provides flexible checkout options", "wp-module-ecommerce")} + +
    +
  • {__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}
  • +
  • {__("White-Labeling", "wp-module-ecommerce")}
  • +
  • + {__( + "Country-specific payment methods", + "wp-module-ecommerce" + )} +
  • +
+ + {__( + " Supports many popular payment methods", + "wp-module-ecommerce" + )} + +
+ + + + + + + + +
+
+ )}
- )} -
- ); - }} -
+ ); + }} + ); }; export default Paypal; diff --git a/src/components/YITHPlugins.js b/src/components/YITHPlugins.js index 0d12ce9b..c482d387 100644 --- a/src/components/YITHPlugins.js +++ b/src/components/YITHPlugins.js @@ -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;