diff --git a/bootstrap.php b/bootstrap.php index 943cc999..63786eda 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -5,6 +5,19 @@ use function NewfoldLabs\WP\ModuleLoader\register; +define( 'NFD_WOOCOMMERCE_MODULE_VERSION', '1.3.26' ); + +if ( function_exists( 'is_admin' ) && is_admin() ) { + $old_woocommerce_module_version = get_option( 'nfd_woocommerce_module_version' ); + + if ( $old_woocommerce_module_version < NFD_WOOCOMMERCE_MODULE_VERSION ) { + update_option( 'nfd_woocommerce_module_version', NFD_WOOCOMMERCE_MODULE_VERSION, true ); + } +} + +/** + * Skips woocommerce onboarding + */ function skip_woo_onboarding() { $wc_option = 'woocommerce_onboarding_profile'; $skip_onboarding = array( diff --git a/src/components/PayPalButton.js b/src/components/PayPalButton.js new file mode 100644 index 00000000..cdecb5b8 --- /dev/null +++ b/src/components/PayPalButton.js @@ -0,0 +1,20 @@ +import {useEffect, useRef} from '@wordpress/element'; + +const PaypalButton = () => { + const ppButton = useRef(); + + useEffect(() => { + const paypalBtn = document.querySelector('.yith-btn-paypal'); + paypalBtn && ppButton.current.appendChild(paypalBtn); + return () => { + const hiddenWrapper = document.querySelector('.yith-ppcp-hidden-button-wrapper'); + hiddenWrapper && hiddenWrapper.appendChild(paypalBtn); + }; + }, []); + + return ( +
+ ); +}; + +export default PaypalButton; \ No newline at end of file diff --git a/src/components/Paypal.js b/src/components/Paypal.js index a78b1f47..ddc98569 100644 --- a/src/components/Paypal.js +++ b/src/components/Paypal.js @@ -1,5 +1,4 @@ -import { Badge, Button, Title, Link } from "@newfold/ui-component-library"; -import { useEffect } from "@wordpress/element"; +import { Badge, Button, Title } from "@newfold/ui-component-library"; import { __ } from "@wordpress/i18n"; import classNames from "classnames"; import { ReactComponent as AmexBrand } from "../icons/brands/amex.svg"; @@ -12,153 +11,122 @@ import { ReactComponent as SofortBrand } from "../icons/brands/sofort.svg"; import { ReactComponent as VenmoBrand } from "../icons/brands/venmo.svg"; import { ReactComponent as VisaBrand } from "../icons/brands/visa.svg"; import { ThirdPartyIntegration } from "./ThirdPartyIntegration"; +import PayPalButton from "./PayPalButton"; const Paypal = ({ notify }) => { - useEffect(() => { - 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' ); - if( !panel && ppButton ){ - ppButton.remove(); - } - }; - }); return ( -