woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.39k stars 10.76k forks source link

[Customize Your Store] Intro page when task not completed but content changed #40328

Closed chihsuan closed 1 year ago

chihsuan commented 1 year ago

User Story

As a new merchant, I want to be presented with simple flows to customize my store, so that I can start selling sooner.

Design

Mrk6SERPZ4KrFHSjM0a8TK-fi-3913%3A288838

Acceptance Criteria

Feature: Customize Your Store Intro page when task not completed but content changed

  Scenario: Choose "Design with AI"
    Given the Customize Your Store Task is not completed but the theme content changed
    When the User presses the "Design with AI" button
    Then pop up `Are you sure you want to start a new design?` modal Mrk6SERPZ4KrFHSjM0a8TK-fi-3616%3A278871
    When the User presses the "Start again'
    Then proceed to the AI wizard
moon0326 commented 1 year ago

@chihsuan What would be the best way to know if the active theme has been modified?

Do you think get_theme_mods is a good function to use for our use cases?

moon0326 commented 1 year ago

For the via the "Editor" link, what value should we use? We've linked it to Customize your store on other pages, but that's where the user is on the intro page 🤔

chihsuan commented 1 year ago

@chihsuan What would be the best way to know if the active theme has been modified?

Do you think get_theme_mods is a good function to use for our use cases?

Hey @moon0326 I think we need to check if the current template, pages, and global style have been modified for block themes (We only support block themes in CYS).

Template

Get the current template and check if modified field is not null.

// https://github.com/woocommerce/woocommerce/blob/7f9322c85858a17f6e9e9e79eaa3aefeda1a0624/plugins/woocommerce-admin/client/customize-store/design-with-ai/services.ts#L315
    const currentTemplate = await resolveSelect(
        coreStore
        // @ts-ignore No types for this exist yet.
    ).__experimentalGetTemplateForLink( '/' );

Screenshot 2023-09-22 at 12 30 25

Pages

Retrieve the pages and check the value of _links.version_history.count OR compare whether the date and modification are the same to know whether they have been changed.

import { useEntityRecords } from '@wordpress/core-data';

const { records, isResolving } = useEntityRecords( 'postType', 'page' );

Screenshot 2023-09-22 at 12 27 44

Global Styles

Use useGlobalStylesRevisions or getCurrentThemeGlobalStylesRevisions

Let me know if you have other questions. Thank you! 🙏


For the via the "Editor" link, what value should we use?

Use /wp-admin/site-editor.php. 🙂

chihsuan commented 1 year ago

Hmm, looks like get_theme_mods also works. Let me test your PR first. 🙌

chihsuan commented 1 year ago

Hey @moon0326 I just tested get_theme_mods on a fresh JN site.

It seems that even if I haven't modified the theme, it returns an item by default

[22-Sep-2023 05:04:00 UTC] Array
(
    [custom_css_post_id] => -1
)

And after I modified the page through the site-editor, it did not change the results.

moon0326 commented 1 year ago

Thank for checking it @chihsuan 👍

Let's go with your approach in that case. I'll make changes

moon0326 commented 1 year ago

@chihsuan For the page query, doesn't it also return other custom pages created by users 🤔 ?

import { useEntityRecords } from '@wordpress/core-data';

const { records, isResolving } = useEntityRecords( 'postType', 'page' );
chihsuan commented 1 year ago

For the page query, doesn't it also return other custom pages created by users

@moon0326 Ah, you're right!

Do you know how we can check if a page was created by a user? 🤔

However, I think we could ignore pages now since we've decided to make the frame not navigable for the MVP (pdnLyh-4it-p2).