From 5d7661eeb9034ad51c5623a4aab3a5720bd199d5 Mon Sep 17 00:00:00 2001 From: Fernando Date: Tue, 5 Oct 2021 09:27:30 -0300 Subject: [PATCH] Store Profiler and Product task - include Subscriptions (https://github.com/woocommerce/woocommerce-admin/pull/7734) * Add flag * Add free subscription to Product Types step * Show copy and install WC-Pay when `Subscriptions` is checked * Fixed `Start with a template` description * Added flag to product-types and small refactor * Add test for subscriptions * Fixed wc-pay installation in product-types step * Refactor product-template-modal # Conflicts: # client/task-list/tasks/products/product-template-modal.js # client/tasks/fills/products/product-template-modal.js * Add more tests * Refactor product types list * Add wc-pay activation in store profiler * Add `wc-pay filter in business details step * Add redirection after selecting subscriptions template option * Fix prop renamed * Fix product-types list * Add changelog * Fix typo * Add check to `Free features` * Refactor `SelectiveExtensionsBundle` * Add `is_activated` to `EvaluateExtension` * Add validation to `ProductTemplateModal` component * Removed useless import * Add missing flags * Fix list * Add promise.all to `product-types` * Removed useless validation Co-authored-by: Fernando Marichal --- .../changelogs/add-7445_include_subscriptions | 4 + .../selective-extensions-bundle/index.js | 39 ++++++-- .../selective-extensions-bundle/test/index.js | 5 +- .../steps/product-types/index.js | 77 +++++++++++++-- .../steps/product-types/test/index.js | 24 +++++ .../client/task-list/task-list.js | 2 +- .../tasks/products/product-template-modal.js | 54 ++++++++++- .../task-list/tasks/products/products.js | 31 ++++++ .../client/task-list/test/products.js | 94 ------------------- .../fills/products/product-template-modal.js | 54 ++++++++++- .../client/tasks/fills/products/products.js | 31 ++++++ plugins/woocommerce-admin/config/core.json | 1 + .../woocommerce-admin/config/development.json | 1 + plugins/woocommerce-admin/config/plugin.json | 1 + .../src/Features/Onboarding.php | 61 ++++++------ .../EvaluateExtension.php | 2 + 16 files changed, 332 insertions(+), 149 deletions(-) create mode 100644 plugins/woocommerce-admin/changelogs/add-7445_include_subscriptions delete mode 100644 plugins/woocommerce-admin/client/task-list/test/products.js diff --git a/plugins/woocommerce-admin/changelogs/add-7445_include_subscriptions b/plugins/woocommerce-admin/changelogs/add-7445_include_subscriptions new file mode 100644 index 00000000000..2c6dc7da2e0 --- /dev/null +++ b/plugins/woocommerce-admin/changelogs/add-7445_include_subscriptions @@ -0,0 +1,4 @@ +Significance: minor +Type: Add + +Store Profiler and Product task - include Subscriptions #7734 diff --git a/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/index.js b/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/index.js index 6e443018fbc..dd4060b09dd 100644 --- a/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/index.js +++ b/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/index.js @@ -178,22 +178,41 @@ export const SelectiveExtensionsBundle = ( { const [ showExtensions, setShowExtensions ] = useState( false ); const [ values, setValues ] = useState( baseValues ); - const { freeExtensions, isResolving } = useSelect( ( select ) => { - const { getFreeExtensions, hasFinishedResolution } = select( - ONBOARDING_STORE_NAME - ); + const { freeExtensions, isResolving, profileItems } = useSelect( + ( select ) => { + const { + getFreeExtensions, + getProfileItems, + hasFinishedResolution, + } = select( ONBOARDING_STORE_NAME ); - return { - freeExtensions: getFreeExtensions(), - isResolving: ! hasFinishedResolution( 'getFreeExtensions' ), - }; - } ); + return { + freeExtensions: getFreeExtensions(), + isResolving: ! hasFinishedResolution( 'getFreeExtensions' ), + profileItems: getProfileItems(), + }; + } + ); const installableExtensions = useMemo( () => { + const { product_types: productTypes } = profileItems; return freeExtensions.filter( ( list ) => { + if ( + window.wcAdminFeatures && + window.wcAdminFeatures.subscriptions + ) { + if ( productTypes.includes( 'subscriptions' ) ) { + list.plugins = list.plugins.filter( + ( extension ) => + extension.key !== 'woocommerce-payments' || + ( extension.key === 'woocommerce-payments' && + ! extension.is_activated ) + ); + } + } return ALLOWED_PLUGIN_LISTS.includes( list.key ); } ); - }, [ freeExtensions ] ); + }, [ freeExtensions, profileItems ] ); useEffect( () => { const initialValues = createInitialValues( installableExtensions ); diff --git a/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/test/index.js b/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/test/index.js index 64b09a576b4..065b4d09ec2 100644 --- a/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/test/index.js +++ b/plugins/woocommerce-admin/client/profile-wizard/steps/business-details/flows/selective-bundle/selective-extensions-bundle/test/index.js @@ -1,7 +1,6 @@ /** * External dependencies */ -import { createElement } from '@wordpress/element'; import { render } from '@testing-library/react'; import { useSelect } from '@wordpress/data'; import userEvent from '@testing-library/user-event'; @@ -84,11 +83,14 @@ const freeExtensions = [ }, ]; +const profileItems = { product_types: [] }; + describe( 'Selective extensions bundle', () => { it( 'should list installable free extensions in footer only basics', () => { useSelect.mockReturnValue( { freeExtensions, isResolving: false, + profileItems, } ); const { getByText, queryByText } = render( @@ -113,6 +115,7 @@ describe( 'Selective extensions bundle', () => { useSelect.mockReturnValue( { freeExtensions, isResolving: false, + profileItems, } ); const { getAllByRole, getByText, queryByText } = render( diff --git a/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/index.js b/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/index.js index b29ee63aba2..94f1759d79e 100644 --- a/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/index.js +++ b/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/index.js @@ -16,12 +16,13 @@ import { includes, filter, get } from 'lodash'; import { getSetting } from '@woocommerce/wc-admin-settings'; import { recordEvent } from '@woocommerce/tracks'; import { withDispatch, withSelect } from '@wordpress/data'; -import { ONBOARDING_STORE_NAME } from '@woocommerce/data'; +import { ONBOARDING_STORE_NAME, PLUGINS_STORE_NAME } from '@woocommerce/data'; import { Text } from '@woocommerce/experimental'; /** * Internal dependencies */ +import { createNoticesFromResponse } from '~/lib/notices'; import ProductTypeLabel from './label'; import './style.scss'; @@ -57,17 +58,45 @@ export class ProductTypes extends Component { } onContinue() { + const { selected } = this.state; + const { installedPlugins = [] } = this.props; + if ( ! this.validateField() ) { return; } - const { createNotice, goToNextStep, updateProfileItems } = this.props; + const { + createNotice, + goToNextStep, + installAndActivatePlugins, + updateProfileItems, + } = this.props; recordEvent( 'storeprofiler_store_product_type_continue', { - product_type: this.state.selected, + product_type: selected, } ); - updateProfileItems( { product_types: this.state.selected } ) + const promises = [ updateProfileItems( { product_types: selected } ) ]; + + if ( + window.wcAdminFeatures && + window.wcAdminFeatures.subscriptions && + ! installedPlugins.includes( 'woocommerce-payments' ) && + selected.includes( 'subscriptions' ) + ) { + promises.push( + installAndActivatePlugins( [ 'woocommerce-payments' ] ) + .then( ( response ) => { + createNoticesFromResponse( response ); + } ) + .catch( ( error ) => { + createNoticesFromResponse( error ); + throw new Error(); + } ) + ); + } + + Promise.all( promises ) .then( () => goToNextStep() ) .catch( () => createNotice( @@ -104,7 +133,11 @@ export class ProductTypes extends Component { render() { const { productTypes = {} } = getSetting( 'onboarding', {} ); const { error, isMonthlyPricing, selected } = this.state; - const { isProfileItemsRequesting } = this.props; + const { + installedPlugins = [], + isInstallingActivating, + isProfileItemsRequesting, + } = this.props; return (
@@ -166,9 +199,14 @@ export class ProductTypes extends Component {
); @@ -214,6 +268,9 @@ export default compose( getOnboardingError, isOnboardingRequesting, } = select( ONBOARDING_STORE_NAME ); + const { getInstalledPlugins, isPluginsRequesting } = select( + PLUGINS_STORE_NAME + ); return { isError: Boolean( getOnboardingError( 'updateProfileItems' ) ), @@ -221,14 +278,20 @@ export default compose( isProfileItemsRequesting: isOnboardingRequesting( 'updateProfileItems' ), + installedPlugins: getInstalledPlugins(), + isInstallingActivating: + isPluginsRequesting( 'installPlugins' ) || + isPluginsRequesting( 'activatePlugins' ), }; } ), withDispatch( ( dispatch ) => { const { updateProfileItems } = dispatch( ONBOARDING_STORE_NAME ); const { createNotice } = dispatch( 'core/notices' ); + const { installAndActivatePlugins } = dispatch( PLUGINS_STORE_NAME ); return { createNotice, + installAndActivatePlugins, updateProfileItems, }; } ) diff --git a/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/test/index.js b/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/test/index.js index fb89a1319f2..7bee3a2e6c0 100644 --- a/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/test/index.js +++ b/plugins/woocommerce-admin/client/profile-wizard/steps/product-types/test/index.js @@ -32,6 +32,7 @@ describe( 'ProductTypes', () => { afterEach( () => { setSetting( 'onboarding', {} ); + window.wcAdminFeatures.subscriptions = false; } ); test( 'should render product types', () => { @@ -86,4 +87,27 @@ describe( 'ProductTypes', () => { expect( mockGoToNextStep ).toHaveBeenCalled(); } ); } ); + test( 'should show a warning message at the bottom of the step', () => { + setSetting( 'onboarding', { + productTypes: { + subscriptions: { + label: 'Subscriptions', + }, + }, + } ); + window.wcAdminFeatures.subscriptions = true; + + render( ); + + const subscription = screen.getByText( 'Subscriptions', { + selector: 'label', + } ); + userEvent.click( subscription ); + + expect( + screen.queryByText( + 'The following extensions will be added to your site for free: WooCommerce Payments. An account is required to use this feature.' + ) + ).toBeInTheDocument(); + } ); } ); diff --git a/plugins/woocommerce-admin/client/task-list/task-list.js b/plugins/woocommerce-admin/client/task-list/task-list.js index 1dded4b7025..eb6032fadae 100644 --- a/plugins/woocommerce-admin/client/task-list/task-list.js +++ b/plugins/woocommerce-admin/client/task-list/task-list.js @@ -353,7 +353,7 @@ export const TaskList = ( { ? () => dismissTask( task ) : undefined } - remindMeLater={ + onSnooze={ task.allowRemindMeLater ? () => remindTaskLater( task ) : undefined diff --git a/plugins/woocommerce-admin/client/task-list/tasks/products/product-template-modal.js b/plugins/woocommerce-admin/client/task-list/tasks/products/product-template-modal.js index 91423ba1e27..cd47ae9dc29 100644 --- a/plugins/woocommerce-admin/client/task-list/tasks/products/product-template-modal.js +++ b/plugins/woocommerce-admin/client/task-list/tasks/products/product-template-modal.js @@ -4,9 +4,13 @@ import { __ } from '@wordpress/i18n'; import { Button, Modal, RadioControl } from '@wordpress/components'; import { useState } from '@wordpress/element'; -import { useDispatch } from '@wordpress/data'; -import { applyFilters } from '@wordpress/hooks'; -import { ITEMS_STORE_NAME } from '@woocommerce/data'; +import { useDispatch, useSelect } from '@wordpress/data'; +import { addFilter, applyFilters } from '@wordpress/hooks'; +import { + ITEMS_STORE_NAME, + ONBOARDING_STORE_NAME, + PLUGINS_STORE_NAME, +} from '@woocommerce/data'; import { getAdminLink } from '@woocommerce/wc-admin-settings'; import { recordEvent } from '@woocommerce/tracks'; @@ -44,18 +48,46 @@ const PRODUCT_TEMPLATES = [ 'woocommerce-admin' ), }, + { + key: 'subscription', + title: __( 'Subscription product', 'woocommerce-admin' ), + subtitle: __( + 'Products that customers receive or gain access to regularly by paying in advance', + 'woocommerce-admin' + ), + }, ]; export default function ProductTemplateModal( { onClose } ) { const [ selectedTemplate, setSelectedTemplate ] = useState( null ); const [ isRedirecting, setIsRedirecting ] = useState( false ); const { createProductFromTemplate } = useDispatch( ITEMS_STORE_NAME ); + const { profileItems } = useSelect( ( select ) => { + const { getProfileItems } = select( ONBOARDING_STORE_NAME ); + + return { + profileItems: getProfileItems(), + }; + } ); + const { installedPlugins } = useSelect( ( select ) => { + const { getInstalledPlugins } = select( PLUGINS_STORE_NAME ); + + return { + installedPlugins: getInstalledPlugins(), + }; + } ); const createTemplate = () => { setIsRedirecting( true ); recordEvent( 'tasklist_product_template_selection', { product_type: selectedTemplate, } ); + if ( selectedTemplate === 'subscription' ) { + window.location = getAdminLink( + 'post-new.php?post_type=product&subscription_pointers=true' + ); + return; + } if ( selectedTemplate ) { createProductFromTemplate( { @@ -84,6 +116,22 @@ export default function ProductTemplateModal( { onClose } ) { } }; + if ( + ( window.wcAdminFeatures && ! window.wcAdminFeatures.subscriptions ) || + ! profileItems.product_types.includes( 'subscriptions' ) || + ! installedPlugins.includes( 'woocommerce-payments' ) + ) { + addFilter( + ONBOARDING_PRODUCT_TEMPLATES_FILTER, + 'woocommerce-admin', + ( productTemplates ) => { + return productTemplates.filter( + ( template ) => template.key !== 'subscription' + ); + } + ); + } + const templates = applyFilters( ONBOARDING_PRODUCT_TEMPLATES_FILTER, PRODUCT_TEMPLATES diff --git a/plugins/woocommerce-admin/client/task-list/tasks/products/products.js b/plugins/woocommerce-admin/client/task-list/tasks/products/products.js index d49a2a74e2d..cf7b2e48afa 100644 --- a/plugins/woocommerce-admin/client/task-list/tasks/products/products.js +++ b/plugins/woocommerce-admin/client/task-list/tasks/products/products.js @@ -12,6 +12,8 @@ import { archive, download, } from '@wordpress/icons'; +import { ONBOARDING_STORE_NAME, PLUGINS_STORE_NAME } from '@woocommerce/data'; +import { useSelect } from '@wordpress/data'; import { List, Pill } from '@woocommerce/components'; import { getAdminLink } from '@woocommerce/wc-admin-settings'; import { recordEvent } from '@woocommerce/tracks'; @@ -90,6 +92,35 @@ const subTasks = [ export default function Products() { const [ selectTemplate, setSelectTemplate ] = useState( null ); + const { profileItems } = useSelect( ( select ) => { + const { getProfileItems } = select( ONBOARDING_STORE_NAME ); + + return { + profileItems: getProfileItems(), + }; + } ); + const { installedPlugins } = useSelect( ( select ) => { + const { getInstalledPlugins } = select( PLUGINS_STORE_NAME ); + + return { + installedPlugins: getInstalledPlugins(), + }; + } ); + + if ( + window.wcAdminFeatures && + window.wcAdminFeatures.subscriptions && + profileItems.product_types.includes( 'subscriptions' ) && + installedPlugins.includes( 'woocommerce-payments' ) + ) { + const task = subTasks.find( + ( { key } ) => key === 'addProductTemplate' + ); + task.content = __( + 'Use a template to add physical, digital, variable, and subscription products', + 'woocommerce-admin' + ); + } const onTaskClick = ( task ) => { task.onClick(); diff --git a/plugins/woocommerce-admin/client/task-list/test/products.js b/plugins/woocommerce-admin/client/task-list/test/products.js deleted file mode 100644 index 70a31b8a6bc..00000000000 --- a/plugins/woocommerce-admin/client/task-list/test/products.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * External dependencies - */ -import { render, screen, fireEvent } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; - -/** - * Internal dependencies - */ -import { Products, ProductTemplateModal } from '../tasks/products'; - -describe( 'products', () => { - describe( 'Products', () => { - afterEach( () => jest.clearAllMocks() ); - - it( 'should render 4 different options to add products', () => { - render( ); - - expect( - screen.queryByText( 'Start with a template' ) - ).toBeInTheDocument(); - expect( screen.queryByText( 'Add manually' ) ).toBeInTheDocument(); - expect( - screen.queryByText( 'Import via CSV' ) - ).toBeInTheDocument(); - expect( - screen.queryByText( 'Import from another service' ) - ).toBeInTheDocument(); - } ); - - it( 'should not render the product template modal right away', () => { - render( ); - - expect( screen.queryByText( '[ProductTemplateModal]' ) ).toBeNull(); - } ); - - it( 'should render product template modal when start with template task is selected', () => { - render( ); - - fireEvent( - screen.queryByText( 'Start with a template' ), - // eslint-disable-next-line no-undef - new MouseEvent( 'click', { bubbles: true } ) - ); - expect( - screen.queryByText( 'Physical product' ) - ).toBeInTheDocument(); - expect( - screen.queryByText( 'Digital product' ) - ).toBeInTheDocument(); - expect( - screen.queryByText( 'Variable product' ) - ).toBeInTheDocument(); - } ); - - it( 'should allow the user to close the template modal', () => { - render( ); - - fireEvent( - screen.queryByText( 'Start with a template' ), - // eslint-disable-next-line no-undef - new MouseEvent( 'click', { bubbles: true } ) - ); - expect( - screen.queryByText( 'Physical product' ) - ).toBeInTheDocument(); - const closeButton = screen.getByRole( 'button', { - name: 'Close dialog', - } ); - fireEvent.click( closeButton ); - expect( - screen.queryByText( 'Physical product' ) - ).not.toBeInTheDocument(); - } ); - } ); - - describe( 'ProductWithTemplate', () => { - afterEach( () => jest.clearAllMocks() ); - - it( 'should render 3 different product types', () => { - render( ); - - expect( - screen.queryByText( 'Physical product' ) - ).toBeInTheDocument(); - expect( - screen.queryByText( 'Digital product' ) - ).toBeInTheDocument(); - expect( - screen.queryByText( 'Variable product' ) - ).toBeInTheDocument(); - } ); - } ); -} ); diff --git a/plugins/woocommerce-admin/client/tasks/fills/products/product-template-modal.js b/plugins/woocommerce-admin/client/tasks/fills/products/product-template-modal.js index 91423ba1e27..cd47ae9dc29 100644 --- a/plugins/woocommerce-admin/client/tasks/fills/products/product-template-modal.js +++ b/plugins/woocommerce-admin/client/tasks/fills/products/product-template-modal.js @@ -4,9 +4,13 @@ import { __ } from '@wordpress/i18n'; import { Button, Modal, RadioControl } from '@wordpress/components'; import { useState } from '@wordpress/element'; -import { useDispatch } from '@wordpress/data'; -import { applyFilters } from '@wordpress/hooks'; -import { ITEMS_STORE_NAME } from '@woocommerce/data'; +import { useDispatch, useSelect } from '@wordpress/data'; +import { addFilter, applyFilters } from '@wordpress/hooks'; +import { + ITEMS_STORE_NAME, + ONBOARDING_STORE_NAME, + PLUGINS_STORE_NAME, +} from '@woocommerce/data'; import { getAdminLink } from '@woocommerce/wc-admin-settings'; import { recordEvent } from '@woocommerce/tracks'; @@ -44,18 +48,46 @@ const PRODUCT_TEMPLATES = [ 'woocommerce-admin' ), }, + { + key: 'subscription', + title: __( 'Subscription product', 'woocommerce-admin' ), + subtitle: __( + 'Products that customers receive or gain access to regularly by paying in advance', + 'woocommerce-admin' + ), + }, ]; export default function ProductTemplateModal( { onClose } ) { const [ selectedTemplate, setSelectedTemplate ] = useState( null ); const [ isRedirecting, setIsRedirecting ] = useState( false ); const { createProductFromTemplate } = useDispatch( ITEMS_STORE_NAME ); + const { profileItems } = useSelect( ( select ) => { + const { getProfileItems } = select( ONBOARDING_STORE_NAME ); + + return { + profileItems: getProfileItems(), + }; + } ); + const { installedPlugins } = useSelect( ( select ) => { + const { getInstalledPlugins } = select( PLUGINS_STORE_NAME ); + + return { + installedPlugins: getInstalledPlugins(), + }; + } ); const createTemplate = () => { setIsRedirecting( true ); recordEvent( 'tasklist_product_template_selection', { product_type: selectedTemplate, } ); + if ( selectedTemplate === 'subscription' ) { + window.location = getAdminLink( + 'post-new.php?post_type=product&subscription_pointers=true' + ); + return; + } if ( selectedTemplate ) { createProductFromTemplate( { @@ -84,6 +116,22 @@ export default function ProductTemplateModal( { onClose } ) { } }; + if ( + ( window.wcAdminFeatures && ! window.wcAdminFeatures.subscriptions ) || + ! profileItems.product_types.includes( 'subscriptions' ) || + ! installedPlugins.includes( 'woocommerce-payments' ) + ) { + addFilter( + ONBOARDING_PRODUCT_TEMPLATES_FILTER, + 'woocommerce-admin', + ( productTemplates ) => { + return productTemplates.filter( + ( template ) => template.key !== 'subscription' + ); + } + ); + } + const templates = applyFilters( ONBOARDING_PRODUCT_TEMPLATES_FILTER, PRODUCT_TEMPLATES diff --git a/plugins/woocommerce-admin/client/tasks/fills/products/products.js b/plugins/woocommerce-admin/client/tasks/fills/products/products.js index 30818805d71..efb26da637d 100644 --- a/plugins/woocommerce-admin/client/tasks/fills/products/products.js +++ b/plugins/woocommerce-admin/client/tasks/fills/products/products.js @@ -12,6 +12,8 @@ import { archive, download, } from '@wordpress/icons'; +import { ONBOARDING_STORE_NAME, PLUGINS_STORE_NAME } from '@woocommerce/data'; +import { useSelect } from '@wordpress/data'; import { List, Pill } from '@woocommerce/components'; import { getAdminLink } from '@woocommerce/wc-admin-settings'; import { recordEvent } from '@woocommerce/tracks'; @@ -92,6 +94,35 @@ const subTasks = [ const Products = () => { const [ selectTemplate, setSelectTemplate ] = useState( null ); + const { profileItems } = useSelect( ( select ) => { + const { getProfileItems } = select( ONBOARDING_STORE_NAME ); + + return { + profileItems: getProfileItems(), + }; + } ); + const { installedPlugins } = useSelect( ( select ) => { + const { getInstalledPlugins } = select( PLUGINS_STORE_NAME ); + + return { + installedPlugins: getInstalledPlugins(), + }; + } ); + + if ( + window.wcAdminFeatures && + window.wcAdminFeatures.subscriptions && + profileItems.product_types.includes( 'subscriptions' ) && + installedPlugins.includes( 'woocommerce-payments' ) + ) { + const task = subTasks.find( + ( { key } ) => key === 'addProductTemplate' + ); + task.content = __( + 'Use a template to add physical, digital, variable, and subscription products', + 'woocommerce-admin' + ); + } const onTaskClick = ( task ) => { task.onClick(); diff --git a/plugins/woocommerce-admin/config/core.json b/plugins/woocommerce-admin/config/core.json index 590927ab74d..5d0549cfd1d 100644 --- a/plugins/woocommerce-admin/config/core.json +++ b/plugins/woocommerce-admin/config/core.json @@ -15,6 +15,7 @@ "payment-gateway-suggestions": true, "settings": false, "shipping-label-banner": true, + "subscriptions": false, "store-alerts": true, "tasks": false, "transient-notices": true, diff --git a/plugins/woocommerce-admin/config/development.json b/plugins/woocommerce-admin/config/development.json index 529117f1293..6c98aa3acb5 100644 --- a/plugins/woocommerce-admin/config/development.json +++ b/plugins/woocommerce-admin/config/development.json @@ -15,6 +15,7 @@ "remote-free-extensions": true, "settings": false, "shipping-label-banner": true, + "subscriptions": true, "store-alerts": true, "tasks": true, "transient-notices": true, diff --git a/plugins/woocommerce-admin/config/plugin.json b/plugins/woocommerce-admin/config/plugin.json index ff4ca9470f8..b0347a62634 100644 --- a/plugins/woocommerce-admin/config/plugin.json +++ b/plugins/woocommerce-admin/config/plugin.json @@ -15,6 +15,7 @@ "payment-gateway-suggestions": true, "settings": false, "shipping-label-banner": true, + "subscriptions": false, "store-alerts": true, "tasks": false, "transient-notices": true, diff --git a/plugins/woocommerce-admin/src/Features/Onboarding.php b/plugins/woocommerce-admin/src/Features/Onboarding.php index 19b6964b3bf..c55f718e3db 100644 --- a/plugins/woocommerce-admin/src/Features/Onboarding.php +++ b/plugins/woocommerce-admin/src/Features/Onboarding.php @@ -433,37 +433,38 @@ class Onboarding { * @return array */ public static function get_allowed_product_types() { - $product_types = self::append_product_data( - array( - 'physical' => array( - 'label' => __( 'Physical products', 'woocommerce-admin' ), - 'default' => true, - ), - 'downloads' => array( - 'label' => __( 'Downloads', 'woocommerce-admin' ), - ), - 'subscriptions' => array( - 'label' => __( 'Subscriptions', 'woocommerce-admin' ), - 'product' => 27147, - ), - 'memberships' => array( - 'label' => __( 'Memberships', 'woocommerce-admin' ), - 'product' => 958589, - ), - 'bookings' => array( - 'label' => __( 'Bookings', 'woocommerce-admin' ), - 'product' => 390890, - ), - 'product-bundles' => array( - 'label' => __( 'Bundles', 'woocommerce-admin' ), - 'product' => 18716, - ), - 'product-add-ons' => array( - 'label' => __( 'Customizable products', 'woocommerce-admin' ), - 'product' => 18618, - ), - ) + $products = array( + 'physical' => array( + 'label' => __( 'Physical products', 'woocommerce-admin' ), + 'default' => true, + ), + 'downloads' => array( + 'label' => __( 'Downloads', 'woocommerce-admin' ), + ), + 'subscriptions' => array( + 'label' => __( 'Subscriptions', 'woocommerce-admin' ), + ), + 'memberships' => array( + 'label' => __( 'Memberships', 'woocommerce-admin' ), + 'product' => 958589, + ), + 'bookings' => array( + 'label' => __( 'Bookings', 'woocommerce-admin' ), + 'product' => 390890, + ), + 'product-bundles' => array( + 'label' => __( 'Bundles', 'woocommerce-admin' ), + 'product' => 18716, + ), + 'product-add-ons' => array( + 'label' => __( 'Customizable products', 'woocommerce-admin' ), + 'product' => 18618, + ), ); + if ( ! Features::is_enabled( 'subscriptions' ) ) { + $products['subscriptions']['product'] = 27147; + } + $product_types = self::append_product_data( $products ); return apply_filters( 'woocommerce_admin_onboarding_product_types', $product_types ); } diff --git a/plugins/woocommerce-admin/src/Features/RemoteFreeExtensions/EvaluateExtension.php b/plugins/woocommerce-admin/src/Features/RemoteFreeExtensions/EvaluateExtension.php index 01247fd3c92..352f279c391 100644 --- a/plugins/woocommerce-admin/src/Features/RemoteFreeExtensions/EvaluateExtension.php +++ b/plugins/woocommerce-admin/src/Features/RemoteFreeExtensions/EvaluateExtension.php @@ -31,7 +31,9 @@ class EvaluateExtension { } $installed_plugins = PluginsHelper::get_installed_plugin_slugs(); + $activated_plugins = PluginsHelper::get_active_plugin_slugs(); $extension->is_installed = in_array( explode( ':', $extension->key )[0], $installed_plugins, true ); + $extension->is_activated = in_array( explode( ':', $extension->key )[0], $activated_plugins, true ); return $extension; }