Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Store Customization > Update products with AI generated content #11155

Merged
merged 36 commits into from
Oct 24, 2023

Conversation

nefeline
Copy link
Contributor

@nefeline nefeline commented Oct 5, 2023

What

This PR enables the feature for automatically generating dummy products and assigning them to AI-generated content. Up to six new dummy products are created if the store owner doesn't have any by the time the Customize Your Store feature is used. The dummy products will be updated with AI-generated content and managed images only if they were not edited by the store owner.

Conditions for Product Creation

  • New dummy products will be created whenever a request to the patterns endpoint is made, and the store doesn't have at least six dummy products available to render patterns with products.
  • If the store owner created at least one product, no new dummy products will be created: this logic is to ensure that we won't create dummy products for consolidated stores, only new ones.

Conditions for AI to update the Product

  • The _headstart_post post meta should be associated with the product. PS: it is mandatory for us to stick with this name for the postmeta as it coincides with what is already in use for the auto-generated products on Woo Express.
  • AI content creation is not allowed if the dummy product was edited by the user. To ensure this, the difference between the post date created and the date modified is not bigger than 60s.
  • The hash during the moment the product had content generated by AI should be the same as the hash for the product in its current state: this also signals that it is okay for the user to overwrite the content with new AI-generated content if they want to since the content is still the same as the last time AI generated it.

Fixes #11142

Why

This change is required to ensure the store always has at least six products available whenever the CYS feature is used so users can properly preview the content associated with patterns powered by the Product Collection Block.

Testing Instructions

Please consider any edge cases this change may have, and also other areas of the product this may impact.

Initial Setup

Or alternatively, create a new WordPress install from scratch (make sure the install is a Jurassic Ninja install or equivalent. Otherwise you won't be able to connect with Jetpack to test this PR).

  • Install and activate this version of WooCommerce.
  • Install and activate WooCommerce Blocks from this zip file.
  • Install and activate Jetpack.
  • In your wp-admin, you should see the following section for Jetpack:

Screenshot 2023-10-22 at 09 29 08

  • Click on "Set up Jetpack" and make sure the connection is successful:

Screenshot 2023-10-22 at 09 29 08

  • Install and activate Woo AI (the plugin is available within the monorepo)
  • Install and activate WooCommerce Beta Tester (the plugin is available within the monorepo)
  • Head over to /wp-admin/tools.php?page=woocommerce-admin-test-helper and enable customize-store feature flag:
Screenshot 2023-10-22 at 10 32 24

Product generation within the CYS Experience

Test Scenario 1 - initial setup, ensure six new dummy products are created if none is available.

  1. Head over to Products > All Products (wp-admin/edit.php?post_type=product) and delete all pre-existing products (if you have any).
  2. Head over to Home > Customize your Store:
Screenshot 2023-10-22 at 09 29 08
  1. Click on design with AI.
  2. Type a description for your business.
  3. After the screen finishes loading, notice how the templates are all correctly rendered and the relevant patterns have products.
  4. Access the Products > All Products (wp-admin/edit.php?post_type=product) page again and notice six new products were created.
Screen.Recording.2023-10-22-b.mov

Test Scenario 2 - Ensure additional dummy products are created if less than six are available.

  1. Head over to Products > All Products (wp-admin/edit.php?post_type=product) and delete at least two of the pre-existing dummy products.
  2. Head over to Home > Customize your Store.
  3. Click on Design with AI.
  4. Type a description for your business.
  5. After the screen finishes loading, notice how the templates are all correctly rendered and the relevant patterns have products.
  6. Access the Products > All Products (wp-admin/edit.php?post_type=product) page again and notice that additional dummy products were created and now you have a total of six available again.
Screen.Recording.2023-10-22-c.mov

Test Scenario 3 - Ensure edited dummy products don't have their content updated by AI.

  1. Head over to Products > All Products (wp-admin/edit.php?post_type=product) and edit one of the dummy products available.
  2. Head over to Home > Customize your Store.
  3. Click on Design with AI.
  4. Type a description for your business.
  5. After the screen finishes loading, notice how the templates are all correctly rendered and the relevant patterns have products.
  6. Access the Products > All Products (wp-admin/edit.php?post_type=product) page again and notice the product you edited didn't have its content modified by AI.
Screen.Recording.2023-10-22-d.mov

Test Scenario 4 - Ensure products created by the store owner don't have their content modified by AI.

  1. Head over to Products > All Products (wp-admin/edit.php?post_type=product) and create one or two new products from scratch.
  2. Head over to Home > Customize your Store.
  3. Click on Design with AI.
  4. Type a description for your business.
  5. After the screen finishes loading, notice how the templates are all correctly rendered and the relevant patterns have products.
  6. Access the Products > All Products (wp-admin/edit.php?post_type=product) page again and notice the product(s) you created didn't have its content modified by AI.
Screen.Recording.2023-10-22-e.mov
  1. Head over to Products > All Products (wp-admin/edit.php?post_type=product) and create one or two new products from scratch.
  2. Head over to Home > Customize your Store.
  3. Click on Design with AI.
  4. Type a description for your business.
  5. After the screen finishes loading, notice how the templates are all correctly rendered and the relevant patterns have products.
  6. Access the Products > All Products (wp-admin/edit.php?post_type=product) page again and notice the product(s) you created didn't have its content modified by AI.

Note

On rare occasions, you may notice that AI won't assign an image or generate content for a given product. This known issue is being investigated and worked on as part of a separate PR.

  • Do not include in the Testing Notes
  • Should be tested by the development team exclusively

WooCommerce Visibility

Required:

  • WooCommerce Core
  • Feature plugin
  • Experimental
  • N/A

Checklist

Required:

  • This PR has either a [type] label or a [skip-changelog] label.
  • [] This PR is assigned to a milestone.

Conditional:

  • This PR has a changelog description (if [skip-changelog] label is not present).
  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces, and I've updated this doc.
  • This PR has been accessibility tested.
  • This PR has had any necessary documentation added/updated.

Changelog

Store Customization > Ensure dummy products can have AI-generated content.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-11155.zip

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 524
  • Total errors: 2341

🎉 🎉 This PR does not introduce new TS errors.

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

Size Change: 0 B

Total Size: 1.53 MB

ℹ️ View Unchanged
Filename Size
build/3810-frontend.js 18.3 kB
build/4124-frontend.js 23.9 kB
build/8280-frontend.js 8.48 kB
build/active-filters-frontend.js 6.56 kB
build/active-filters-rtl.css 1.68 kB
build/active-filters-wrapper-frontend.js 6.88 kB
build/active-filters-wrapper-rtl.css 1.53 kB
build/active-filters-wrapper.css 1.53 kB
build/active-filters.css 1.68 kB
build/active-filters.js 6.04 kB
build/add-to-cart-form-rtl.css 375 B
build/add-to-cart-form.css 373 B
build/all-products-frontend.js 9.86 kB
build/all-products-rtl.css 4.53 kB
build/all-products.css 4.53 kB
build/all-products.js 39.8 kB
build/all-reviews-rtl.css 1.79 kB
build/all-reviews.css 1.79 kB
build/all-reviews.js 7.84 kB
build/attribute-filter-frontend.js 19.8 kB
build/attribute-filter-rtl.css 4.03 kB
build/attribute-filter-wrapper-frontend.js 21 kB
build/attribute-filter-wrapper-rtl.css 1.65 kB
build/attribute-filter-wrapper.css 1.65 kB
build/attribute-filter.css 4.01 kB
build/attribute-filter.js 11.2 kB
build/base-components-stock-filter-wrapper~attribute-filter-wrapper~rating-filter-wrapper-style.scss-rtl.css 2.97 kB
build/base-components-stock-filter-wrapper~attribute-filter-wrapper~rating-filter-wrapper-style.scss.css 2.97 kB
build/blocks-checkout.js 33.9 kB
build/blocks-components.js 8.44 kB
build/breadcrumbs-rtl.css 234 B
build/breadcrumbs.css 234 B
build/breadcrumbs.js 2.03 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.4 kB
build/cart-blocks/cart-accepted-payment-methods-style.js 153 B
build/cart-blocks/cart-cross-sells-frontend.js 268 B
build/cart-blocks/cart-cross-sells-products-frontend.js 5.55 kB
build/cart-blocks/cart-cross-sells-products-style.js 153 B
build/cart-blocks/cart-cross-sells-style.js 269 B
build/cart-blocks/cart-express-payment-frontend.js 5.36 kB
build/cart-blocks/cart-express-payment-style.js 155 B
build/cart-blocks/cart-items-frontend.js 273 B
build/cart-blocks/cart-items-style.js 240 B
build/cart-blocks/cart-line-items-frontend.js 9.23 kB
build/cart-blocks/cart-line-items-style.js 153 B
build/cart-blocks/cart-order-summary-frontend.js 20.5 kB
build/cart-blocks/cart-order-summary-style.js 341 B
build/cart-blocks/cart-totals-frontend.js 290 B
build/cart-blocks/cart-totals-style.js 253 B
build/cart-blocks/empty-cart-frontend.js 367 B
build/cart-blocks/empty-cart-style.js 365 B
build/cart-blocks/filled-cart-frontend.js 605 B
build/cart-blocks/filled-cart-style.js 333 B
build/cart-blocks/order-summary-coupon-form-frontend.js 20.8 kB
build/cart-blocks/order-summary-coupon-form-style.js 155 B
build/cart-blocks/order-summary-discount-frontend.js 20.9 kB
build/cart-blocks/order-summary-discount-style.js 155 B
build/cart-blocks/order-summary-fee-frontend.js 288 B
build/cart-blocks/order-summary-fee-style.js 153 B
build/cart-blocks/order-summary-heading-frontend.js 346 B
build/cart-blocks/order-summary-heading-style.js 351 B
build/cart-blocks/order-summary-shipping-frontend.js 20.5 kB
build/cart-blocks/order-summary-shipping-style.js 154 B
build/cart-blocks/order-summary-subtotal-frontend.js 291 B
build/cart-blocks/order-summary-subtotal-style.js 154 B
build/cart-blocks/order-summary-taxes-frontend.js 456 B
build/cart-blocks/order-summary-taxes-style.js 202 B
build/cart-blocks/proceed-to-checkout-frontend.js 7.62 kB
build/cart-blocks/proceed-to-checkout-style.js 1.08 kB
build/cart-frontend.js 28.9 kB
build/cart-rtl.css 9.23 kB
build/cart.css 9.22 kB
build/cart.js 39.5 kB
build/catalog-sorting-rtl.css 259 B
build/catalog-sorting.css 259 B
build/catalog-sorting.js 1.69 kB
build/checkout-blocks/actions-frontend.js 8.11 kB
build/checkout-blocks/actions-style.js 1.01 kB
build/checkout-blocks/billing-address-frontend.js 9.91 kB
build/checkout-blocks/billing-address-style.js 630 B
build/checkout-blocks/contact-information-frontend.js 1.7 kB
build/checkout-blocks/contact-information-style.js 653 B
build/checkout-blocks/express-payment-frontend.js 5.84 kB
build/checkout-blocks/fields-frontend.js 297 B
build/checkout-blocks/fields-style.js 271 B
build/checkout-blocks/order-note-frontend.js 760 B
build/checkout-blocks/order-summary-cart-items-frontend.js 6.47 kB
build/checkout-blocks/order-summary-cart-items-style.js 153 B
build/checkout-blocks/order-summary-coupon-form-frontend.js 20.9 kB
build/checkout-blocks/order-summary-coupon-form-style.js 155 B
build/checkout-blocks/order-summary-discount-frontend.js 20.9 kB
build/checkout-blocks/order-summary-discount-style.js 154 B
build/checkout-blocks/order-summary-fee-frontend.js 291 B
build/checkout-blocks/order-summary-fee-style.js 155 B
build/checkout-blocks/order-summary-frontend.js 20.5 kB
build/checkout-blocks/order-summary-shipping-frontend.js 20.5 kB
build/checkout-blocks/order-summary-shipping-style.js 154 B
build/checkout-blocks/order-summary-style.js 342 B
build/checkout-blocks/order-summary-subtotal-frontend.js 289 B
build/checkout-blocks/order-summary-subtotal-style.js 155 B
build/checkout-blocks/order-summary-taxes-frontend.js 456 B
build/checkout-blocks/order-summary-taxes-style.js 201 B
build/checkout-blocks/payment-frontend.js 14.5 kB
build/checkout-blocks/payment-style.js 509 B
build/checkout-blocks/pickup-options-frontend.js 11.2 kB
build/checkout-blocks/pickup-options-style.js 480 B
build/checkout-blocks/shipping-address-frontend.js 9.87 kB
build/checkout-blocks/shipping-address-style.js 517 B
build/checkout-blocks/shipping-method-frontend.js 1.96 kB
build/checkout-blocks/shipping-method-style.js 1.43 kB
build/checkout-blocks/shipping-methods-frontend.js 19 kB
build/checkout-blocks/shipping-methods-style.js 456 B
build/checkout-blocks/terms-frontend.js 1.55 kB
build/checkout-blocks/terms-style.js 1.02 kB
build/checkout-blocks/totals-frontend.js 334 B
build/checkout-blocks/totals-style.js 301 B
build/checkout-frontend.js 30.5 kB
build/checkout-rtl.css 8.5 kB
build/checkout.css 8.49 kB
build/checkout.js 42.7 kB
build/classic-shortcode-rtl.css 242 B
build/classic-shortcode.css 241 B
build/classic-shortcode.js 4.63 kB
build/collection-filters.js 1.63 kB
build/collection-price-filter-frontend.js 577 B
build/collection-price-filter-rtl.css 1.28 kB
build/collection-price-filter.css 1.28 kB
build/collection-price-filter.js 3.43 kB
build/customer-account-rtl.css 410 B
build/customer-account.css 409 B
build/customer-account.js 3.17 kB
build/featured-category-rtl.css 974 B
build/featured-category.css 973 B
build/featured-category.js 13.6 kB
build/featured-product-rtl.css 1.02 kB
build/featured-product.css 1.02 kB
build/featured-product.js 13.7 kB
build/filter-wrapper-frontend.js 14.5 kB
build/filter-wrapper-rtl.css 378 B
build/filter-wrapper.css 378 B
build/filter-wrapper.js 2.37 kB
build/handpicked-products.js 7.22 kB
build/legacy-template-rtl.css 240 B
build/legacy-template.css 240 B
build/legacy-template.js 7.73 kB
build/mini-cart-component-frontend.js 30.7 kB
build/mini-cart-contents-block/cart-button-frontend.js 1.86 kB
build/mini-cart-contents-block/cart-button-style.js 1.23 kB
build/mini-cart-contents-block/checkout-button-frontend.js 1.95 kB
build/mini-cart-contents-block/checkout-button-style.js 1.43 kB
build/mini-cart-contents-block/empty-cart-frontend.js 374 B
build/mini-cart-contents-block/empty-cart-style.js 378 B
build/mini-cart-contents-block/filled-cart-frontend.js 284 B
build/mini-cart-contents-block/filled-cart-style.js 288 B
build/mini-cart-contents-block/footer-frontend.js 3.87 kB
build/mini-cart-contents-block/footer-style.js 1.95 kB
build/mini-cart-contents-block/items-frontend.js 247 B
build/mini-cart-contents-block/items-style.js 251 B
build/mini-cart-contents-block/products-table-frontend.js 8.58 kB
build/mini-cart-contents-block/shopping-button-frontend.js 501 B
build/mini-cart-contents-block/shopping-button-style.js 361 B
build/mini-cart-contents-block/title-frontend.js 2.04 kB
build/mini-cart-contents-block/title-items-counter-frontend.js 1.74 kB
build/mini-cart-contents-block/title-items-counter-style.js 1.2 kB
build/mini-cart-contents-block/title-label-frontend.js 1.68 kB
build/mini-cart-contents-block/title-label-style.js 1.14 kB
build/mini-cart-contents-block/title-style.js 1.38 kB
build/mini-cart-contents-rtl.css 3.21 kB
build/mini-cart-contents.css 3.2 kB
build/mini-cart-contents.js 15.9 kB
build/mini-cart-frontend.js 2.35 kB
build/mini-cart-rtl.css 2.44 kB
build/mini-cart.css 2.44 kB
build/mini-cart.js 6 kB
build/order-confirmation-additional-information-rtl.css 367 B
build/order-confirmation-additional-information.css 367 B
build/order-confirmation-additional-information.js 1.57 kB
build/order-confirmation-billing-address-rtl.css 398 B
build/order-confirmation-billing-address.css 397 B
build/order-confirmation-billing-address.js 1.55 kB
build/order-confirmation-billing-wrapper.js 1.5 kB
build/order-confirmation-downloads-rtl.css 477 B
build/order-confirmation-downloads-wrapper.js 1.57 kB
build/order-confirmation-downloads.css 478 B
build/order-confirmation-downloads.js 1.9 kB
build/order-confirmation-shipping-address-rtl.css 399 B
build/order-confirmation-shipping-address.css 398 B
build/order-confirmation-shipping-address.js 1.55 kB
build/order-confirmation-shipping-wrapper.js 1.5 kB
build/order-confirmation-status-rtl.css 280 B
build/order-confirmation-status.css 280 B
build/order-confirmation-status.js 1.54 kB
build/order-confirmation-summary-rtl.css 460 B
build/order-confirmation-summary.css 460 B
build/order-confirmation-summary.js 1.75 kB
build/order-confirmation-totals-rtl.css 594 B
build/order-confirmation-totals-wrapper.js 1.79 kB
build/order-confirmation-totals.css 593 B
build/order-confirmation-totals.js 2.16 kB
build/packages-style-rtl.css 5.02 kB
build/packages-style.css 5.02 kB
build/page-content-wrapper.js 1.85 kB
build/price-filter-frontend.js 7.86 kB
build/price-filter-rtl.css 2.68 kB
build/price-filter-wrapper-frontend.js 8.08 kB
build/price-filter-wrapper-rtl.css 2.53 kB
build/price-filter-wrapper.css 2.53 kB
build/price-filter.css 2.67 kB
build/price-filter.js 7.42 kB
build/price-format.js 913 B
build/product-add-to-cart-frontend.js 8.11 kB
build/product-add-to-cart-rtl.css 1.37 kB
build/product-add-to-cart.css 1.38 kB
build/product-add-to-cart.js 8.35 kB
build/product-average-rating-frontend.js 1.88 kB
build/product-average-rating.js 1.4 kB
build/product-best-sellers.js 7.04 kB
build/product-button-frontend.js 4.93 kB
build/product-button-interactivity-frontend.js 8.48 kB
build/product-button-rtl.css 1.14 kB
build/product-button.css 1.14 kB
build/product-button.js 4.64 kB
build/product-categories-rtl.css 654 B
build/product-categories.css 654 B
build/product-categories.js 2.58 kB
build/product-category.js 7.97 kB
build/product-collection.js 13.7 kB
build/product-details-rtl.css 397 B
build/product-details.css 394 B
build/product-gallery-frontend.js 638 B
build/product-gallery-large-image-frontend.js 585 B
build/product-gallery-large-image-next-previous.js 4.15 kB
build/product-gallery-large-image.js 2.36 kB
build/product-gallery-pager.js 3.38 kB
build/product-gallery-rtl.css 1.15 kB
build/product-gallery-thumbnails.js 3.8 kB
build/product-gallery.css 1.15 kB
build/product-gallery.js 9.4 kB
build/product-image-frontend.js 2.89 kB
build/product-image-gallery-rtl.css 307 B
build/product-image-gallery.css 306 B
build/product-image-rtl.css 996 B
build/product-image.css 994 B
build/product-image.js 2.53 kB
build/product-new.js 7.3 kB
build/product-on-sale.js 7.29 kB
build/product-price-frontend.js 2.81 kB
build/product-price-rtl.css 644 B
build/product-price.css 643 B
build/product-price.js 2.33 kB
build/product-query-rtl.css 350 B
build/product-query.css 349 B
build/product-query.js 11.5 kB
build/product-rating-counter-frontend.js 2.19 kB
build/product-rating-counter.js 1.71 kB
build/product-rating-frontend.js 2.53 kB
build/product-rating-rtl.css 247 B
build/product-rating-stars-frontend.js 2.43 kB
build/product-rating-stars-rtl.css 899 B
build/product-rating-stars.css 900 B
build/product-rating-stars.js 1.95 kB
build/product-rating.css 246 B
build/product-rating.js 2.05 kB
build/product-results-count-rtl.css 230 B
build/product-results-count.css 230 B
build/product-results-count.js 1.65 kB
build/product-reviews-rtl.css 458 B
build/product-reviews.css 458 B
build/product-sale-badge-frontend.js 2.01 kB
build/product-sale-badge-rtl.css 437 B
build/product-sale-badge.css 437 B
build/product-sale-badge.js 1.52 kB
build/product-search-rtl.css 419 B
build/product-search.css 417 B
build/product-search.js 2.6 kB
build/product-sku-frontend.js 2.02 kB
build/product-sku-rtl.css 240 B
build/product-sku.css 239 B
build/product-sku.js 1.53 kB
build/product-stock-indicator-frontend.js 2.19 kB
build/product-stock-indicator-rtl.css 232 B
build/product-stock-indicator.css 232 B
build/product-stock-indicator.js 1.71 kB
build/product-summary-frontend.js 2.35 kB
build/product-summary-rtl.css 549 B
build/product-summary.css 549 B
build/product-summary.js 1.87 kB
build/product-tag.js 7.5 kB
build/product-template-rtl.css 536 B
build/product-template.css 535 B
build/product-template.js 2.8 kB
build/product-title-frontend.js 2.31 kB
build/product-title-rtl.css 693 B
build/product-title.css 694 B
build/product-title.js 2.04 kB
build/product-top-rated.js 7.57 kB
build/products-by-attribute.js 8.02 kB
build/rating-filter-frontend.js 18.7 kB
build/rating-filter-rtl.css 4.08 kB
build/rating-filter-wrapper-frontend.js 19.7 kB
build/rating-filter-wrapper-rtl.css 1.73 kB
build/rating-filter-wrapper.css 1.73 kB
build/rating-filter.css 4.07 kB
build/rating-filter.js 5.79 kB
build/reviews-by-category-rtl.css 1.79 kB
build/reviews-by-category.css 1.79 kB
build/reviews-by-category.js 11.4 kB
build/reviews-by-product-rtl.css 1.79 kB
build/reviews-by-product.css 1.79 kB
build/reviews-by-product.js 12.7 kB
build/reviews-frontend.js 6.52 kB
build/single-product-rtl.css 378 B
build/single-product.css 378 B
build/single-product.js 11 kB
build/stock-filter-frontend.js 18.9 kB
build/stock-filter-rtl.css 3.88 kB
build/stock-filter-wrapper-frontend.js 19.9 kB
build/stock-filter-wrapper-rtl.css 1.49 kB
build/stock-filter-wrapper.css 1.49 kB
build/stock-filter.css 3.87 kB
build/stock-filter.js 6.42 kB
build/store-notices.js 1.67 kB
build/wc-blocks-classic-template-revert-button-style-rtl.css 240 B
build/wc-blocks-classic-template-revert-button-style.css 239 B
build/wc-blocks-classic-template-revert-button.js 1.18 kB
build/wc-blocks-data.js 19.6 kB
build/wc-blocks-editor-style-rtl.css 7.18 kB
build/wc-blocks-editor-style.css 7.17 kB
build/wc-blocks-google-analytics.js 1.16 kB
build/wc-blocks-jetpack-woocommerce-analytics.js 750 B
build/wc-blocks-middleware.js 735 B
build/wc-blocks-registry.js 2.74 kB
build/wc-blocks-rtl.css 2.47 kB
build/wc-blocks-shared-context.js 850 B
build/wc-blocks-shared-hocs.js 1.4 kB
build/wc-blocks-vendors.js 61.7 kB
build/wc-blocks.css 2.48 kB
build/wc-blocks.js 2.61 kB
build/wc-interactivity.js 10.7 kB
build/wc-payment-method-bacs.js 406 B
build/wc-payment-method-cheque.js 401 B
build/wc-payment-method-cod.js 508 B
build/wc-payment-method-paypal.js 437 B
build/wc-settings.js 2.4 kB
build/wc-shipping-method-pickup-location.js 29.3 kB

compressed-size-action

@nefeline nefeline self-assigned this Oct 10, 2023
@github-actions
Copy link
Contributor

update to comply with DRY principles.

update to comply with DRY principles.


// @todo update to comply with DRY principles.
$query = "SELECT ID FROM {$wpdb->posts} WHERE ID NOT IN ( SELECT p.ID FROM {$wpdb->posts} p JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id WHERE pm.meta_key = %s AND p.post_type = 'product' AND p.post_status = 'publish' ) AND post_type = 'product' AND post_status = 'publish'";
} else {
$query = "SELECT p.ID FROM {$wpdb->posts} p JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id WHERE pm.meta_key = %s AND p.post_type = 'product' AND p.post_status = 'publish'";
}
return $wpdb->get_results( $wpdb->prepare( $query, '_headstart_post' ) );
}
/**
* Return the hash for a product based on its name, description and image_id.
*

🚀 This comment was generated by the automations bot based on a todo comment in 11f6eb7 in #11155. cc @nefeline

@nefeline nefeline requested a review from tjcafferkey October 22, 2023 09:29
@nefeline nefeline added the type: enhancement The issue is a request for an enhancement. label Oct 22, 2023
@tjcafferkey
Copy link
Contributor

tjcafferkey commented Oct 23, 2023

Just finished testing (still yet to review the code) and the testing instructions worked perfectly and functionally it worked as expected, so thank you for writing all of that out.

Just a few things that came up, some of these may not be relevant to this PR change but just noting them anyway so we're aware. For context, my business name was always "I am a medium sized business that sells sports apparel"

Image Description
The product names I guess are relevant to my store description but they aren't what I'd consider "products". One of them seems to be a book also
Some of the text was ineligible because of the lack of color contrast
Some of the images were more fashion clothes rather than sports apparel
Other times the imagery appeared to be irrelevant

@nefeline
Copy link
Contributor Author

nefeline commented Oct 23, 2023

Thanks @tjcafferkey, regarding:

Just a few things that came up, some of these may not be relevant to this PR change but just noting them anyway so we're aware. For context, my business name was always "I am a medium sized business that sells sports apparel"

Those are unrelated to this PR indeed, the focus here is to ensure products are created and have AI-generated content assigned to them exclusively, but thanks for flagging. The prompts and additional fine-tuning for the AI-generated content are being worked on #11280

@tjcafferkey
Copy link
Contributor

@nefeline I have just left a few comments. Once answered by you I will approve/request changes! 😄 thanks for working on this! 💪🏻

@nefeline
Copy link
Contributor Author

I have just left a few comments. Once answered by you I will approve/request changes! 😄 thanks for working on this! 💪🏻

Thanks for the review, @tjcafferkey! All feedback addressed. FYI - there are a few additional optimizations being made for this feature on #11280, especially regarding performance and execution time: more details to be shared on that PR soon.

Copy link
Contributor

@tjcafferkey tjcafferkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the changes @nefeline and for putting this PR together!

Copy link
Contributor

@tjcafferkey tjcafferkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the changes @nefeline and for putting this PR together!

@nefeline nefeline enabled auto-merge (squash) October 24, 2023 12:59
@nefeline nefeline merged commit fdf7da0 into trunk Oct 24, 2023
32 checks passed
@nefeline nefeline deleted the add/ai-generated-content-for-products branch October 24, 2023 13:33
@gigitux gigitux added this to the 11.4.2 milestone Oct 25, 2023
gigitux pushed a commit that referenced this pull request Oct 25, 2023
* Introduce the ProductUpdater class.

* Update the image assignment for the default products content.

* Update the default products content.

* Introduce the generate_content and get_placeholder_products methods.

* Update the get_placeholder_products method and introduce the new create_new_product method.

* Verify the hash of the product content and compare it with the hash of the ai generated content to ensure we wont override products modified by the store owner.

* Add docblocks and update the structure for the ProductUpdater class.

* Pass the vertical images as a param for the PatternUpdater and the ProductUpdater.

* Update the provided variable to the PatternUpdater class.

* Update the ProductUpdater class to include the requirements for usage of the media_sideload_image method outside the wp-admin area (via API) and other adjustments to the products generation and hashes

* remove unnecessary calls to post/product images.

* Update the loop for generating products.

* Further adjustments to the Product Updater.

* Provide the business_description as a param for the generate_content ProductUpdates

* Update the default timeout for the AI connection; update the path to the default image. Add a limit of 6 when quering the total products created by the store owner.

* Add new neutral placeholder images for products and patterns.

* Update the prompt and the logic for the placeholder images.

* Remove placeholder images.

* Increase max execution time

* Update the products query.

* Move the media_sideload_image function dependencies to outside of the loop and add comment.

* Update text content.

* Address code review.

* bail early if no business description provided.

* Add an extra safety check in case of query errors.

* Address CR.
gigitux added a commit that referenced this pull request Oct 26, 2023
* Empty commit for release pull request

* Do a version bump to 11.4.1

* Add Instruction Notes and update the Changelog

* Update the testing instructions and the changelog and the .zip link

* Empty commit for release pull request

* Remove the fontSize for the button (#11433)

* [Store Customization MVP] Ensure the AI-generated content in patterns is updated on plugin update (#11210)

* Update the patterns content after updating the plugin

* Remove unused variable and use statement

* Schedule action for updating the patterns content on plugin update (for both WooCommerce and WooCommerce Blocks.)

* Update condition to remove the plugin folder name

* Remove the update function from bootstrap.php

* Remove unused use

* Fix the condition, since $options['plugin'] is an array

* Remove pattern file

This was left empty by mistake in a merge, we need to remove the file or we get an error

---------

Co-authored-by: Patricia Hillebrandt <[email protected]>

* Fix outer space and title (#11434)

* Store Customization > Update products with AI generated content (#11155)

* Introduce the ProductUpdater class.

* Update the image assignment for the default products content.

* Update the default products content.

* Introduce the generate_content and get_placeholder_products methods.

* Update the get_placeholder_products method and introduce the new create_new_product method.

* Verify the hash of the product content and compare it with the hash of the ai generated content to ensure we wont override products modified by the store owner.

* Add docblocks and update the structure for the ProductUpdater class.

* Pass the vertical images as a param for the PatternUpdater and the ProductUpdater.

* Update the provided variable to the PatternUpdater class.

* Update the ProductUpdater class to include the requirements for usage of the media_sideload_image method outside the wp-admin area (via API) and other adjustments to the products generation and hashes

* remove unnecessary calls to post/product images.

* Update the loop for generating products.

* Further adjustments to the Product Updater.

* Provide the business_description as a param for the generate_content ProductUpdates

* Update the default timeout for the AI connection; update the path to the default image. Add a limit of 6 when quering the total products created by the store owner.

* Add new neutral placeholder images for products and patterns.

* Update the prompt and the logic for the placeholder images.

* Remove placeholder images.

* Increase max execution time

* Update the products query.

* Move the media_sideload_image function dependencies to outside of the loop and add comment.

* Update text content.

* Address code review.

* bail early if no business description provided.

* Add an extra safety check in case of query errors.

* Address CR.

* Patterns > Upload optimized version of placeholder image (#11441)

* Improve vars name and remove duplicated user name (#11430)

* Add overlay with 30% opacity (#11428)

* [Store Customization] Update the "Footer with 3 Menus" (#11379)

* Fix search bar, spacing and show text in one line

* Set site log width

* Adjust margins and search bar

* Make the search bar fill space on mobile

* Update column sizes

* Remove width from site logo

* [CYS Woo Express] Update large footer (#11413)

* Update large footer

* Update space between icons

* Remove with from site logo

* update changelog and testing instructions

* bump to 11.4.2 version

* [CYS Woo Express] Fix essential header (#11449)

* Fix essential header

* Fix spacing

* update testing instructions

* Make groups to adapt better to mobile views (#11463)

* update testing instructions and changelog

* Unify the search bar layout across patterns (#11445)

* Unify the search bar layout across patterns

* restore changes

* [CYS Woo Express] Footer with simple menu and cart (#11409)

* Update footer simple menu cart

* Change structure to use rows not columns

* Make search fill space

* Fix spacing and switch mini-cart and menu

* Unify the search bar

* Remove mini cart

* update testing instructions and changelog

* Store Customization > Fetch product images from the Pexels API (#11280)

* Introduce the ProductUpdater class.

* Update the image assignment for the default products content.

* Update the default products content.

* Introduce the generate_content and get_placeholder_products methods.

* Update the get_placeholder_products method and introduce the new create_new_product method.

* Verify the hash of the product content and compare it with the hash of the ai generated content to ensure we wont override products modified by the store owner.

* Add docblocks and update the structure for the ProductUpdater class.

* Pass the vertical images as a param for the PatternUpdater and the ProductUpdater.

* Update the provided variable to the PatternUpdater class.

* Update the ProductUpdater class to include the requirements for usage of the media_sideload_image method outside the wp-admin area (via API) and other adjustments to the products generation and hashes

* remove unnecessary calls to post/product images.

* Update the loop for generating products.

* Further adjustments to the Product Updater.

* Provide the business_description as a param for the generate_content ProductUpdates

* Update the default timeout for the AI connection; update the path to the default image. Add a limit of 6 when quering the total products created by the store owner.

* Add new neutral placeholder images for products and patterns.

* Update the prompt and the logic for the placeholder images.

* Remove placeholder images.

* Pass the AI connection as a param and update the get_images_for_pattern method to rely on the results returned from the Pexels API.

* update the product updater class to rely on Pexels images and add the ai_connection as a param.

* Remove the unused get_random_images method.

* Update the patterns endpoint.

* Delete unused ChatGPTClient class.

* Introduce the new Pexels class.

* Remove the Verticals references.

* Update the reference for the alt description for images.

* Update the scheduled action to populate patterns and products.

* Remove unused Verticals classes.

* Ensure the Pexels class already returns the array with the expected format for assignment to Patterns and Products.

* Introduce the select_image_src_based_on_format method.

* Increase max execution time

* Increase max execution time

* Update the request to rely on the WP.com external-media endpoint instead.

* Improve performance for product content update.

* Improve quality of images used in products and update queries.

* Update the products query.

* Move the media_sideload_image function dependencies to outside of the loop and add comment.

* Update text content.

* Merge base branch

* Introduce the should_update_dummy_product method.

* Update the method to be triggered on scheduled action to return true.

* Change the image format for products to improve performance.

* Make portrait the default fallback image format.

* Address code review.

* bail early if no business description provided.

* Add an extra safety check in case of query errors.

* Address CR.

* Raise the default memory limit.

* Update the prompt for the search term for images.

* Make sure the 'woocommerce_blocks_allow_ai_connection' option is set to true if the site is connected to AI.

* Update the prompt for AI generated content in patterns and initialize the images and alts for the patterns.

* Update the prompt for products and introduce the update_dummy_products method.

* Update the default number of images returned by Pexels.

* Update the default fallback for the expected image format.

* Update the prompt for selecting the images.

* Add a character limit to the testimonials.

* Increase timeout to fetch products data

* Address code review.

* update changelog

* add zip link

* fix markdown

* remove duplicate testing instructions

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Daniel Dudzic <[email protected]>
Co-authored-by: Alba Rincón <[email protected]>
Co-authored-by: Patricia Hillebrandt <[email protected]>
Co-authored-by: Tom Cafferkey <[email protected]>
Co-authored-by: Luigi <[email protected]>
gigitux added a commit that referenced this pull request Nov 2, 2023
* Empty commit for release pull request

* Add changelog entries to readme.txt

* Update version numbers

* Add testing instructions

* Update the changelog with #11421

* Always show the `Enable the shipping calculator on the cart page` option in WC Admin (#11421)

* Always show `Enable the shipping calculator ...`

Always show the `Enable the shipping calculator on the cart page` option
no matter of what is used for the cart page.

* Update remove_shipping_settings docblock to accurately describe its purpose.

---------

Co-authored-by: Mike Jolley <[email protected]>

* Add a safe guard that the variable is set before accessing it (#11424)

* Update zip package link

* Modify the <main> HTML tag in the title to 'main' to ensure the title remains intact

* Revert "Use the <header> element for the checkout header (#11222)"

This reverts commit 045789e.

* Remove #11222 from the Changelog and the Testing Notes

* Remove #11190 from the Changelog and Testing Notes as it was never merged

* Update .zip file with latest changes

* Release: 11.4.2 (#11452)

* Empty commit for release pull request

* Do a version bump to 11.4.1

* Add Instruction Notes and update the Changelog

* Update the testing instructions and the changelog and the .zip link

* Empty commit for release pull request

* Remove the fontSize for the button (#11433)

* [Store Customization MVP] Ensure the AI-generated content in patterns is updated on plugin update (#11210)

* Update the patterns content after updating the plugin

* Remove unused variable and use statement

* Schedule action for updating the patterns content on plugin update (for both WooCommerce and WooCommerce Blocks.)

* Update condition to remove the plugin folder name

* Remove the update function from bootstrap.php

* Remove unused use

* Fix the condition, since $options['plugin'] is an array

* Remove pattern file

This was left empty by mistake in a merge, we need to remove the file or we get an error

---------

Co-authored-by: Patricia Hillebrandt <[email protected]>

* Fix outer space and title (#11434)

* Store Customization > Update products with AI generated content (#11155)

* Introduce the ProductUpdater class.

* Update the image assignment for the default products content.

* Update the default products content.

* Introduce the generate_content and get_placeholder_products methods.

* Update the get_placeholder_products method and introduce the new create_new_product method.

* Verify the hash of the product content and compare it with the hash of the ai generated content to ensure we wont override products modified by the store owner.

* Add docblocks and update the structure for the ProductUpdater class.

* Pass the vertical images as a param for the PatternUpdater and the ProductUpdater.

* Update the provided variable to the PatternUpdater class.

* Update the ProductUpdater class to include the requirements for usage of the media_sideload_image method outside the wp-admin area (via API) and other adjustments to the products generation and hashes

* remove unnecessary calls to post/product images.

* Update the loop for generating products.

* Further adjustments to the Product Updater.

* Provide the business_description as a param for the generate_content ProductUpdates

* Update the default timeout for the AI connection; update the path to the default image. Add a limit of 6 when quering the total products created by the store owner.

* Add new neutral placeholder images for products and patterns.

* Update the prompt and the logic for the placeholder images.

* Remove placeholder images.

* Increase max execution time

* Update the products query.

* Move the media_sideload_image function dependencies to outside of the loop and add comment.

* Update text content.

* Address code review.

* bail early if no business description provided.

* Add an extra safety check in case of query errors.

* Address CR.

* Patterns > Upload optimized version of placeholder image (#11441)

* Improve vars name and remove duplicated user name (#11430)

* Add overlay with 30% opacity (#11428)

* [Store Customization] Update the "Footer with 3 Menus" (#11379)

* Fix search bar, spacing and show text in one line

* Set site log width

* Adjust margins and search bar

* Make the search bar fill space on mobile

* Update column sizes

* Remove width from site logo

* [CYS Woo Express] Update large footer (#11413)

* Update large footer

* Update space between icons

* Remove with from site logo

* update changelog and testing instructions

* bump to 11.4.2 version

* [CYS Woo Express] Fix essential header (#11449)

* Fix essential header

* Fix spacing

* update testing instructions

* Make groups to adapt better to mobile views (#11463)

* update testing instructions and changelog

* Unify the search bar layout across patterns (#11445)

* Unify the search bar layout across patterns

* restore changes

* [CYS Woo Express] Footer with simple menu and cart (#11409)

* Update footer simple menu cart

* Change structure to use rows not columns

* Make search fill space

* Fix spacing and switch mini-cart and menu

* Unify the search bar

* Remove mini cart

* update testing instructions and changelog

* Store Customization > Fetch product images from the Pexels API (#11280)

* Introduce the ProductUpdater class.

* Update the image assignment for the default products content.

* Update the default products content.

* Introduce the generate_content and get_placeholder_products methods.

* Update the get_placeholder_products method and introduce the new create_new_product method.

* Verify the hash of the product content and compare it with the hash of the ai generated content to ensure we wont override products modified by the store owner.

* Add docblocks and update the structure for the ProductUpdater class.

* Pass the vertical images as a param for the PatternUpdater and the ProductUpdater.

* Update the provided variable to the PatternUpdater class.

* Update the ProductUpdater class to include the requirements for usage of the media_sideload_image method outside the wp-admin area (via API) and other adjustments to the products generation and hashes

* remove unnecessary calls to post/product images.

* Update the loop for generating products.

* Further adjustments to the Product Updater.

* Provide the business_description as a param for the generate_content ProductUpdates

* Update the default timeout for the AI connection; update the path to the default image. Add a limit of 6 when quering the total products created by the store owner.

* Add new neutral placeholder images for products and patterns.

* Update the prompt and the logic for the placeholder images.

* Remove placeholder images.

* Pass the AI connection as a param and update the get_images_for_pattern method to rely on the results returned from the Pexels API.

* update the product updater class to rely on Pexels images and add the ai_connection as a param.

* Remove the unused get_random_images method.

* Update the patterns endpoint.

* Delete unused ChatGPTClient class.

* Introduce the new Pexels class.

* Remove the Verticals references.

* Update the reference for the alt description for images.

* Update the scheduled action to populate patterns and products.

* Remove unused Verticals classes.

* Ensure the Pexels class already returns the array with the expected format for assignment to Patterns and Products.

* Introduce the select_image_src_based_on_format method.

* Increase max execution time

* Increase max execution time

* Update the request to rely on the WP.com external-media endpoint instead.

* Improve performance for product content update.

* Improve quality of images used in products and update queries.

* Update the products query.

* Move the media_sideload_image function dependencies to outside of the loop and add comment.

* Update text content.

* Merge base branch

* Introduce the should_update_dummy_product method.

* Update the method to be triggered on scheduled action to return true.

* Change the image format for products to improve performance.

* Make portrait the default fallback image format.

* Address code review.

* bail early if no business description provided.

* Add an extra safety check in case of query errors.

* Address CR.

* Raise the default memory limit.

* Update the prompt for the search term for images.

* Make sure the 'woocommerce_blocks_allow_ai_connection' option is set to true if the site is connected to AI.

* Update the prompt for AI generated content in patterns and initialize the images and alts for the patterns.

* Update the prompt for products and introduce the update_dummy_products method.

* Update the default number of images returned by Pexels.

* Update the default fallback for the expected image format.

* Update the prompt for selecting the images.

* Add a character limit to the testimonials.

* Increase timeout to fetch products data

* Address code review.

* update changelog

* add zip link

* fix markdown

* remove duplicate testing instructions

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Daniel Dudzic <[email protected]>
Co-authored-by: Alba Rincón <[email protected]>
Co-authored-by: Patricia Hillebrandt <[email protected]>
Co-authored-by: Tom Cafferkey <[email protected]>
Co-authored-by: Luigi <[email protected]>

* Release: 11.4.3 (#11496)

* bump to 11.4.3

* Empty commit for release pull request

* Improve Hero Product Chessboard pattern (#11423)

* improve pattern

* remove hardcoded font-size

* address feedback

* update to h2

* Remove group and separator to get rid of the extra space (#11477)

* [Store Customization] Update the design for the Product Gallery pattern (#11464)

* Remove rating, show only title and price

* Improve title spacing and level

* Patterns with Search Bar: improve style (#11478)

* "Product Collection X Columns" patterns: align "no reviews" text with the star (#11468)

* improve line-height

* use variable

* add testing instructions

* Rename pattern (#11487)

* update readme

* Store Customization > Enhance the Hero Product Split pattern (#11505)

* Update the bottom margin for the Hero Product Split and the heading from h3 to h2.

* Update heading comment

* update testing instructions

* Simplify the `Hero Product 3 Split` pattern design (#11495)

* Simplify the pattern design

* Add char limits to the AI generated content

* Fix url

* update testing instructions

* Product Search Block: unify border-radius (#11515)

* add testing instructions

* [Store Customization] Update the Centered Header Menu with Search Pattern (#11304)

* Fix hidden elements on mobile and margins

* Increase navigation items spacing

* Add site logo width

* Improve search bar and title font weight

* Remove width from site logo

* Unify search bar

* Remove search, improve margins

* Use columns to improve the mobile view

* add testing instructions

* Large Header pattern: improve the layout on mobile view (#11490)

* Improve Large header

* improve large header

* use lens

* add padding

* add testing instructions

* Fix "Large footer" left spacing (#11520)

* Fix large footer left spacing

* Use esc_html_e

* add testing instructions

* add zip file

* improve testing instructions

* update testing instructions

* update testing instructions

---------

Co-authored-by: Luigi <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: Alba Rincón <[email protected]>
Co-authored-by: Patricia Hillebrandt <[email protected]>

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Daniel Dudzic <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
Co-authored-by: Mike Jolley <[email protected]>
Co-authored-by: Karol Manijak <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Alba Rincón <[email protected]>
Co-authored-by: Patricia Hillebrandt <[email protected]>
Co-authored-by: Tom Cafferkey <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: ai Issues related to AI generated content in blocks and patterns type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store Customization > Create new dummy products and update them with AI generated content
3 participants