Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Conversation

@octaedro
Copy link
Contributor

Fixes #4578

This PR adds personalization to the Purchase extension task list item.

It should:

  • Display the extension name if the user selected one extension: Purchase and install [extension_name] extension
  • Apply the same for themes: Purchase and install [theme_name] theme
  • Keep the task description generic if the user selected more than one product

Accessibility

Screenshots

screenshot-2020-06-02-at-12.34.18.png

Detailed test instructions:

Extensions

  • Go to the 3rd step of the OBW (URL: /wp-admin/admin.php?page=wc-admin&path=%2Fprofiler&step=product-types).
  • Select only one paid extension. Be sure you don't have a paid theme selected too.
  • Go back to the Dashboard or Home screen (URL: /wp-admin/admin.php?page=wc-admin).
  • Now the item Purchase and install [extension_name] extension should be visible in the task list.

Themes

  • Now unselect the paid extension, choose a free one and go to the 5th step of the OBW and select a paid theme.
  • Go back to the Dashboard or Home screen (URL: /wp-admin/admin.php?page=wc-admin).
  • Now the item Purchase and install [theme_name] theme should be visible in the task list.

More than one item

  • Try adding a paid extension and a paid theme, or two paid extensions.
  • The message Purchase & install extensions should be visible.

Changelog Note:

Dev: Added personalization to purchase extension task

This commit adds personalization to purchase extension task
octaedro added 2 commits July 22, 2020 16:28
This commit removes an unnecessary naming fix
Copy link
Contributor

@jeffstieler jeffstieler left a comment

Choose a reason for hiding this comment

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

This tests well - nicely done. There are some issues with the way strings are being built and translated that need to be addressed.

key: 'purchase',
title: __( 'Purchase & install extensions', 'woocommerce-admin' ),
title: sprintf(
__( '%s', 'woocommerce-admin' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is effectively an untranslatable string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! I corrected it in the commit 7e8426d


const purchaseAndInstallText =
uniqueItemsList.length === 1
? `Purchase & install ${ uniqueItemsList[ 0 ].name } ${ uniqueItemsList[ 0 ].type }`
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be translatable - e.g. __( 'Purchase & install %s theme', 'woocommerce-admin' ). We should probably restrict the dynamic part of the string to just the Extension or Theme name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @jeffstieler, this is also corrected in the commit 7e8426d

const purchaseAndInstallText =
uniqueItemsList.length === 1
? `Purchase & install ${ uniqueItemsList[ 0 ].name } ${ uniqueItemsList[ 0 ].type }`
: 'Purchase & install extensions';
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be wrapped in an i18n call.

);

const uniqueItemsList = [
...new Set( [
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting trick!

* @param {Array} installedPlugins Installed plugins.
* @return {Array} Objects with grouped product names and types.
*/
export function getGroupedOnboardingProducts( profileItems, installedPlugins ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Total nitpick on naming: technically this isn't grouping the products, it's labeling/categorizing them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion, I changed it in the commit e160630

if ( product.label ) {
cleanedProduct = { type: 'extension', name: product.label };
} else {
cleanedProduct = { type: 'theme', name: product.title };
Copy link
Contributor

Choose a reason for hiding this comment

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

I've left other comments about translation - if these type values still end up in strings to display (which I don't think they should) they need to be passed through the i18n functions as raw strings here.

@jeffstieler jeffstieler added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed [Status] Needs Review labels Jul 29, 2020
octaedro added 2 commits July 30, 2020 10:59
The method 'getGroupedOnboardingProducts' was given a more accurate name.
@octaedro
Copy link
Contributor Author

Thank you for your review @jeffstieler, I addressed the suggested changes. Could you give this PR another look?

@octaedro octaedro added [Status] Needs Review and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Jul 30, 2020
? __( 'theme', 'woocommerce-admin' )
: __( 'extension', 'woocommerce-admin' );
purchaseAndInstallText = sprintf(
__( 'Purchase & install %s %s', 'woocommerce-admin' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're leaving two placeholders in the string they need to be positional - either a named replacement using interpolation or numerically indexed. Also we'd need to leave a note for the translators.

I'd personally prefer an alternative - this could turn into 2 translatable strings using the itemType logic above. Something like:

const purchaseAndInstallFormat = 'theme' === itemType ? __( 'Purchase & install %s theme, 'woocommerce-admin' ) : __( 'Purchase & install %s extension, 'woocommerce-admin' );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion @jeffstieler. The modification was added in the commit c6e734d

Copy link
Contributor

@jeffstieler jeffstieler left a comment

Choose a reason for hiding this comment

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

Code looks good and tests well. Nice work!

@octaedro octaedro merged commit 7a68f82 into main Aug 3, 2020
@octaedro octaedro deleted the add/4578 branch August 3, 2020 19:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task List: Personalize Purchase Extension task

3 participants