From 637173b9f7a1f0854a0fd723c53322d8615dd946 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Wed, 15 Feb 2023 14:10:42 +0530 Subject: [PATCH 01/13] add bluehost branding to bluehost india --- src/OnboardingSPA/styles/_branding.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OnboardingSPA/styles/_branding.scss b/src/OnboardingSPA/styles/_branding.scss index fd3ec319a..025a5560f 100644 --- a/src/OnboardingSPA/styles/_branding.scss +++ b/src/OnboardingSPA/styles/_branding.scss @@ -1,6 +1,7 @@ body { - &.nfd-brand-bluehost { + &.nfd-brand-bluehost, + &.nfd-brand-bluehost-india { --wp-admin-theme-color: #3575d3; --wp-admin-theme-color--rgb: 53, 117, 211; --wp-admin-theme-color-darker-10: #1c5cba; From d7ecc82fa768c847509a17b663828dba48036a7a Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Wed, 15 Feb 2023 14:15:59 +0530 Subject: [PATCH 02/13] fix lint --- src/OnboardingSPA/styles/_branding.scss | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/OnboardingSPA/styles/_branding.scss b/src/OnboardingSPA/styles/_branding.scss index 025a5560f..61b324678 100644 --- a/src/OnboardingSPA/styles/_branding.scss +++ b/src/OnboardingSPA/styles/_branding.scss @@ -8,9 +8,9 @@ body { --wp-admin-theme-color-darker-10--rgb: 28, 92, 186; --wp-admin-theme-color-darker-20: #0242a0; --wp-admin-theme-color-darker-20--rgb: 2, 66, 160; - --nfd-onboarding-dark-icon: url("../../Brands/bluehost/dark.svg"); - --nfd-onboarding-icon: url("../../Brands/bluehost/icon.svg"); - --nfd-onboarding-logo: url("../../Brands/bluehost/logo.svg"); + --nfd-onboarding-dark-icon: url(../../Brands/bluehost/dark.svg); + --nfd-onboarding-icon: url(../../Brands/bluehost/icon.svg); + --nfd-onboarding-logo: url(../../Brands/bluehost/logo.svg); --nfd-onboarding-primary: #3575d3; --nfd-onboarding-highlighted--rgb: 123, 177, 253; --nfd-onboarding-primary-alt: #2c76dc; @@ -31,8 +31,8 @@ body { --nfd-onboarding-drawer-icon-active-fill: var(--nfd-onboarding-light); --nfd-onboarding-loader-start: var(--nfd-onboarding-primary); --nfd-onboarding-loader-end: var(--nfd-onboarding-tertiary); - --nfd-onboarding-step-loader-icon: url("../../Brands/bluehost/step-loader-logo.svg"); - --nfd-onboarding-step-error-icon: url("../../Brands/bluehost/step-error-logo.svg"); + --nfd-onboarding-step-loader-icon: url(../../Brands/bluehost/step-loader-logo.svg); + --nfd-onboarding-step-error-icon: url(../../Brands/bluehost/step-error-logo.svg); } &.nfd-brand-hostgator { @@ -42,9 +42,9 @@ body { --wp-admin-theme-color-darker-10--rgb: 20, 133, 236; --wp-admin-theme-color-darker-20: #1177d2; --wp-admin-theme-color-darker-20--rgb: 17, 119, 210; - --nfd-onboarding-dark-icon: url("../../Brands/hostgator/dark.svg"); - --nfd-onboarding-icon: url("../../Brands/hostgator/icon.svg"); - --nfd-onboarding-logo: url("../../Brands/hostgator/logo.svg"); + --nfd-onboarding-dark-icon: url(../../Brands/hostgator/dark.svg); + --nfd-onboarding-icon: url(../../Brands/hostgator/icon.svg); + --nfd-onboarding-logo: url(../../Brands/hostgator/logo.svg); --nfd-onboarding-primary: #2e93ee; --nfd-onboarding-highlighted--rgb: 30, 32, 68; --nfd-onboarding-primary-alt: #3b97ff; @@ -73,9 +73,9 @@ body { --wp-admin-theme-color-darker-10--rgb: 43, 92, 251; --wp-admin-theme-color-darker-20: #0b44fb; --wp-admin-theme-color-darker-20--rgb: 11, 68, 251; - --nfd-onboarding-dark-icon: url("../../Brands/webcom/dark.svg"); - --nfd-onboarding-icon: url("../../Brands/webcom/icon.svg"); - --nfd-onboarding-logo: url("../../Brands/webcom/logo.svg"); + --nfd-onboarding-dark-icon: url(../../Brands/webcom/dark.svg); + --nfd-onboarding-icon: url(../../Brands/webcom/icon.svg); + --nfd-onboarding-logo: url(../../Brands/webcom/logo.svg); --nfd-onboarding-primary: #4b75fc; --nfd-onboarding-highlighted--rgb: 13, 71, 251; --nfd-onboarding-primary-alt: #0d47fb; From 36492ec2ce3317a2585e4bddaafe9597c8848b09 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Wed, 15 Feb 2023 14:27:38 +0530 Subject: [PATCH 03/13] whitelist razorpay --- includes/Data/Plugins.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/Data/Plugins.php b/includes/Data/Plugins.php index 45eae40ff..5e885acc5 100644 --- a/includes/Data/Plugins.php +++ b/includes/Data/Plugins.php @@ -45,6 +45,10 @@ final class Plugins { 'approved' => true, 'path' => 'creative-mail-by-constant-contact/creative-mail-plugin.php', ), + 'woo-razorpay' => array( + 'approved' => true, + 'path' => 'woo-razorpay/woo-razorpay.php', + ), ); /** From 47eb5bf4278e1d4f1773df1ac0b679d30b06c5c0 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Wed, 15 Feb 2023 18:20:17 +0530 Subject: [PATCH 04/13] install razorpay, remove shippo and paypal for Bluehost India --- includes/Data/Plugins.php | 187 ++++++++++++++++++++++++-------------- 1 file changed, 121 insertions(+), 66 deletions(-) diff --git a/includes/Data/Plugins.php b/includes/Data/Plugins.php index 5e885acc5..2c5ae0246 100644 --- a/includes/Data/Plugins.php +++ b/includes/Data/Plugins.php @@ -51,11 +51,11 @@ final class Plugins { ), ); - /** - * Contains a list of zip url's with a unique "nfd_slug" for each. - * - * @var array - */ + /** + * Contains a list of zip url's with a unique "nfd_slug" for each. + * + * @var array + */ protected static $nfd_slugs = array( 'nfd_slug_endurance_page_cache' => array( 'approved' => true, @@ -151,73 +151,127 @@ final class Plugins { ), ), 'ecommerce' => array( - 'default' => array( + 'default' => array( array( 'slug' => 'woocommerce', 'activate' => true, 'priority' => 260, ), ), - 'wc_standard' => array( - array( - 'slug' => 'nfd_slug_yith_woocommerce_customize_myaccount_page', - 'activate' => true, - 'priority' => 257, - ), - array( - 'slug' => 'nfd_slug_yith_woocommerce_gift_cards', - 'activate' => true, - 'priority' => 100, + 'bluehost' => array( + 'wc_standard' => array( + array( + 'slug' => 'nfd_slug_yith_woocommerce_customize_myaccount_page', + 'activate' => true, + 'priority' => 257, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_gift_cards', + 'activate' => true, + 'priority' => 100, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_wishlist', + 'activate' => true, + 'priority' => 80, + ), + array( + 'slug' => 'nfd_slug_yith_shippo_shippings_for_woocommerce', + 'activate' => true, + 'priority' => 259, + ), + array( + 'slug' => 'nfd_slug_yith_paypal_payments_for_woocommerce', + 'activate' => true, + 'priority' => 258, + ), ), - array( - 'slug' => 'nfd_slug_yith_woocommerce_wishlist', - 'activate' => true, - 'priority' => 80, - ), - array( - 'slug' => 'nfd_slug_yith_shippo_shippings_for_woocommerce', - 'activate' => true, - 'priority' => 259, - ), - array( - 'slug' => 'nfd_slug_yith_paypal_payments_for_woocommerce', - 'activate' => true, - 'priority' => 258, + 'wc_premium' => array( + array( + 'slug' => 'nfd_slug_yith_woocommerce_customize_myaccount_page', + 'activate' => true, + 'priority' => 257, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_gift_cards', + 'activate' => true, + 'priority' => 100, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_wishlist', + 'activate' => true, + 'priority' => 80, + ), + array( + 'slug' => 'nfd_slug_yith_shippo_shippings_for_woocommerce', + 'activate' => true, + 'priority' => 259, + ), + array( + 'slug' => 'nfd_slug_yith_paypal_payments_for_woocommerce', + 'activate' => true, + 'priority' => 258, + ), + array( + 'slug' => 'nfd_slug_ecomdash_wordpress_plugin', + 'activate' => true, + 'priority' => 20, + ), ), + 'wc_priority' => array(), ), - 'wc_premium' => array( - array( - 'slug' => 'nfd_slug_yith_woocommerce_customize_myaccount_page', - 'activate' => true, - 'priority' => 257, - ), - array( - 'slug' => 'nfd_slug_yith_woocommerce_gift_cards', - 'activate' => true, - 'priority' => 100, - ), - array( - 'slug' => 'nfd_slug_yith_woocommerce_wishlist', - 'activate' => true, - 'priority' => 80, + 'bluehost-india' => array( + 'wc_standard' => array( + array( + 'slug' => 'nfd_slug_yith_woocommerce_customize_myaccount_page', + 'activate' => true, + 'priority' => 257, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_gift_cards', + 'activate' => true, + 'priority' => 100, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_wishlist', + 'activate' => true, + 'priority' => 80, + ), + array( + 'slug' => 'woo-razorpay', + 'activate' => true, + 'priority' => 258, + ), ), - array( - 'slug' => 'nfd_slug_yith_shippo_shippings_for_woocommerce', - 'activate' => true, - 'priority' => 259, - ), - array( - 'slug' => 'nfd_slug_yith_paypal_payments_for_woocommerce', - 'activate' => true, - 'priority' => 258, - ), - array( - 'slug' => 'nfd_slug_ecomdash_wordpress_plugin', - 'activate' => true, - 'priority' => 20, + 'wc_premium' => array( + array( + 'slug' => 'nfd_slug_yith_woocommerce_customize_myaccount_page', + 'activate' => true, + 'priority' => 257, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_gift_cards', + 'activate' => true, + 'priority' => 100, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_wishlist', + 'activate' => true, + 'priority' => 80, + ), + array( + 'slug' => 'woo-razorpay', + 'activate' => true, + 'priority' => 258, + ), + array( + 'slug' => 'nfd_slug_ecomdash_wordpress_plugin', + 'activate' => true, + 'priority' => 20, + ), ), + 'wc_priority' => array(), ), - 'wc_priority' => array(), ), ); @@ -302,8 +356,8 @@ public static function get_approved() { return array( 'wp_slugs' => array_keys( array_filter( self::$wp_slugs, array( __CLASS__, 'check_approved' ) ) ), 'nfd_slugs' => array_keys( array_filter( self::$nfd_slugs, array( __CLASS__, 'check_approved' ) ) ), - 'urls' => array_keys( self::$urls, true ), - 'domains' => array_keys( self::$domains, true ), + 'urls' => array_keys( self::$urls, true, true ), + 'domains' => array_keys( self::$domains, true, true ), ); } @@ -314,7 +368,7 @@ public static function get_approved() { * @return boolean */ private static function check_approved( $value ) { - return true === $value['approved']; + return true === $value['approved']; } /** @@ -329,10 +383,11 @@ public static function get_init() { $init_list = self::$init_list['default']; if ( $plan_flow && isset( self::$init_list[ $plan_flow ] ) ) { if ( isset( self::$init_list[ $plan_flow ]['default'] ) ) { - $init_list = array_merge( $init_list, self::$init_list[ $plan_flow ]['default'] ); + $init_list = array_merge( $init_list, self::$init_list[ $plan_flow ]['default'] ); } - if ( 'default' !== $plan_subtype && isset( self::$init_list[ $plan_flow ][ $plan_subtype ] ) ) { - $init_list = array_merge( $init_list, self::$init_list[ $plan_flow ][ $plan_subtype ] ); + $current_brand = Data::current_brand()['brand']; + if ( 'default' !== $plan_subtype && isset( self::$init_list[ $plan_flow ][ $current_brand ][ $plan_subtype ] ) ) { + $init_list = array_merge( $init_list, self::$init_list[ $plan_flow ][ $current_brand ][ $plan_subtype ] ); } } From f72ed5f5c3577fc0b2e580b65e415eb8af5d0612 Mon Sep 17 00:00:00 2001 From: abhijitb Date: Fri, 17 Feb 2023 05:11:56 +0530 Subject: [PATCH 05/13] updated url links for bluehost india --- includes/Data/Brands.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index f7add3595..70e6c285d 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -77,11 +77,14 @@ public static function get_brands() { 'facebookUrl' => 'https://www.facebook.com/BlueHostIndia', 'twitterName' => '@BluehostIndia', 'twitterUrl' => 'https://twitter.com/bluehostindia', - 'youtubeUrl' => null, + 'youtubeUrl' => 'https://www.youtube.com/c/BluehostIndia1', 'linkedinUrl' => null, 'accountUrl' => 'https://my.bluehost.in', 'domainsUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/domains', 'emailUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/email-office', + 'phoneNumbers' => array( + 'support' => '1800-419-4426', + ), 'hireExpertsInfo' => array( 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', 'utmParameters' => array( From d2db429f3bc042e3a2a5cd163ffde5bbfc3ae477 Mon Sep 17 00:00:00 2001 From: abhijitb Date: Wed, 22 Feb 2023 12:24:50 +0530 Subject: [PATCH 06/13] added bluesky link for BH.in --- includes/Data/Brands.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index 70e6c285d..beb204f54 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -86,7 +86,7 @@ public static function get_brands() { 'support' => '1800-419-4426', ), 'hireExpertsInfo' => array( - 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', + 'defaultLink' => 'https://www.bluehost.in/bluesky', 'utmParameters' => array( 'utm_source' => 'blog', 'utm_medium' => 'socialmedia', From 76ac2b9fde25a99dd1270399c43bbf4fe8443c71 Mon Sep 17 00:00:00 2001 From: abhijitb Date: Thu, 23 Feb 2023 18:58:21 +0530 Subject: [PATCH 07/13] updated utm params for BH.com and BH.in links --- includes/Data/Brands.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index beb204f54..58506d68c 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -39,8 +39,8 @@ public static function get_brands() { 'fragment' => '#/marketplace/services/blue-sky', 'queryParameters' => array( 'page' => 'bluehost', - 'utm_source' => 'onboarding', - 'utm_medium' => 'wp_admin', + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', 'utm_campaign' => 'wp-setup', ), ), @@ -88,9 +88,9 @@ public static function get_brands() { 'hireExpertsInfo' => array( 'defaultLink' => 'https://www.bluehost.in/bluesky', 'utmParameters' => array( - 'utm_source' => 'blog', - 'utm_medium' => 'socialmedia', - 'utm_campaign' => 'blogpost', + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', + 'utm_campaign' => 'wp-setup', ), ), 'expertsInfo' => array( From 8832cb860d8b722527ea318ec6891e2ef0fa94f1 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Wed, 8 Mar 2023 16:47:04 +0530 Subject: [PATCH 08/13] add defaults from https://github.com/newfold-labs/wp-module-onboarding/pull/184, fix errors --- .../Steps/Ecommerce/StepAddress/index.js | 171 +++++++++++++----- 1 file changed, 128 insertions(+), 43 deletions(-) diff --git a/src/OnboardingSPA/pages/Steps/Ecommerce/StepAddress/index.js b/src/OnboardingSPA/pages/Steps/Ecommerce/StepAddress/index.js index 12f4c2552..6b0ac3a42 100644 --- a/src/OnboardingSPA/pages/Steps/Ecommerce/StepAddress/index.js +++ b/src/OnboardingSPA/pages/Steps/Ecommerce/StepAddress/index.js @@ -1,6 +1,6 @@ import { useViewportMatch } from '@wordpress/compose'; import { useDispatch, useSelect } from '@wordpress/data'; -import { useEffect, useState } from '@wordpress/element'; +import { useEffect } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { useNavigate } from 'react-router-dom'; import { @@ -12,15 +12,13 @@ import CommonLayout from '../../../../components/Layouts/Common'; import NeedHelpTag from '../../../../components/NeedHelpTag'; import NewfoldLargeCard from '../../../../components/NewfoldLargeCard'; import { store as nfdOnboardingStore } from '../../../../store'; -import content from '../content.json'; import countries from '../countries.json'; import currencies from '../currencies.json'; -import { useWPSettings } from '../useWPSettings'; +import { useWPSettings as getWPSettings } from '../useWPSettings'; import Animate from '../../../../components/Animate'; import { EcommerceStateHandler } from '../../../../components/StateHandlers'; const StepAddress = () => { - const [ settings, setSettings ] = useState(); const navigate = useNavigate(); const isLargeViewport = useViewportMatch( 'medium' ); const { @@ -32,6 +30,53 @@ const StepAddress = () => { setIsHeaderNavigationEnabled, } = useDispatch( nfdOnboardingStore ); + const getDefaultValues = ( brand ) => { + switch ( brand ) { + case 'crazy-domains': + return { + woocommerce_default_country: 'AU:NSW', + woocommerce_currency: 'AUD', + }; + case 'bluehost-india': + return { + woocommerce_default_country: 'IN:AP', + woocommerce_currency: 'INR', + }; + case 'bluehost': + default: + return { + woocommerce_default_country: 'US:AZ', + woocommerce_currency: 'USD', + }; + } + }; + + /** + * When WC in installed, it sets a bunch of defaults related to country etc + * which is detected by matching a set of values. + * + * @param {Record} options + * @return {boolean} Is default address set + */ + const isDefaultAddressSet = ( options ) => { + const emptyFields = [ + 'woocommerce_store_address', + 'woocommerce_store_city', + 'woocommerce_store_postcode', + ]; + const areAddressFieldsEmpty = emptyFields.every( + ( key ) => options[ key ] === null || options[ key ] === '' + ); + const wcDefaults = [ + [ 'woocommerce_default_country', 'US:CA' ], + [ 'woocommerce_currency', 'USD' ], + ]; + const isCountryUSA = wcDefaults.every( + ( [ key, value ] ) => options[ key ] === value + ); + return areAddressFieldsEmpty && isCountryUSA; + }; + const setNavigationState = () => { if ( isLargeViewport ) { setIsDrawerOpened( true ); @@ -40,19 +85,19 @@ const StepAddress = () => { setIsHeaderNavigationEnabled( true ); }; - async function getSettingsData() { - setSettings( await useWPSettings() ); - } - + const settings = getWPSettings(); useEffect( () => { setSidebarActiveView( SIDEBAR_LEARN_MORE ); setDrawerActiveView( VIEW_NAV_ECOMMERCE_STORE_INFO ); - getSettingsData(); }, [] ); - const currentData = useSelect( ( select ) => - select( nfdOnboardingStore ).getCurrentOnboardingData() - ); + const { currentData, newfoldBrand } = useSelect( ( select ) => { + return { + currentData: + select( nfdOnboardingStore ).getCurrentOnboardingData(), + newfoldBrand: select( nfdOnboardingStore ).getNewfoldBrand(), + }; + }, [] ); useEffect( () => { if ( settings ) { @@ -64,10 +109,28 @@ const StepAddress = () => { 'woocommerce_currency', 'woocommerce_email_from_address', ]; + + const keysWithDefaultValues = [ + 'woocommerce_default_country', + 'woocommerce_currency', + ]; + if ( settings !== null && currentData.storeDetails.address === undefined ) { + const useDefaultValues = isDefaultAddressSet( settings ); + const addressToBeSet = { ...settings }; + const defaultValues = getDefaultValues( newfoldBrand ); + for ( const key of keysWithDefaultValues ) { + if ( + addressToBeSet[ key ] === null || + addressToBeSet[ key ] === '' || + useDefaultValues + ) { + addressToBeSet[ key ] = defaultValues[ key ]; + } + } setCurrentOnboardingData( { storeDetails: { ...currentData.storeDetails, @@ -76,7 +139,7 @@ const StepAddress = () => { ...addressKeys.reduce( ( address, key ) => ( { ...address, - [ key ]: settings[ key ], + [ key ]: addressToBeSet[ key ], } ), {} ), @@ -85,18 +148,15 @@ const StepAddress = () => { } ); } } - }, [ settings, currentData.storeDetails ] ); + }, [ settings, currentData.storeDetails, newfoldBrand ] ); const { address } = currentData.storeDetails; const fieldProps = { - disabled: settings === null, + disabled: address === undefined, onChange: handleFieldChange, onBlur: handleFieldChange, }; - const defaultPlace = - address?.woocommerce_default_country ?? - settings?.woocommerce_default_country ?? - 'US:AZ'; + const defaultPlace = address?.woocommerce_default_country ?? ''; const [ defaultCountry, defaultState ] = defaultPlace.split( ':' ); const selectedCountry = address?.country ?? defaultCountry; const states = @@ -109,17 +169,16 @@ const StepAddress = () => { if ( country === defaultCountry && state === undefined ) { state = defaultState; } - if ( states.length == 0 ) { + if ( states.length === 0 ) { state = ''; // edge case to handle when the user goes back to onboarding and changes from a country with state to no state } let place = ''; if ( [ 'country', 'state' ].includes( fieldName ) ) { - place = - fieldName === 'country' - ? state - ? `${ newValue }:${ state }` - : newValue - : `${ country }:${ newValue }`; + if ( fieldName === 'country' ) { + place = state ? `${ newValue }:${ state }` : newValue; + } else { + place = `${ country }:${ newValue }`; + } } setCurrentOnboardingData( { storeDetails: { @@ -168,29 +227,34 @@ const StepAddress = () => {
-
-
-
+ ) }