Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Add advanced setting option
2 changes: 1 addition & 1 deletion plugins/woocommerce/client/admin/config/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"minified-js": false,
"mobile-app-banner": true,
"navigation": true,
"new-product-management-experience": false,
"new-product-management-experience": true,
"onboarding": true,
"onboarding-tasks": true,
"product-variation-management": false,
Expand Down
2 changes: 1 addition & 1 deletion plugins/woocommerce/client/admin/config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"minified-js": true,
"mobile-app-banner": true,
"navigation": true,
"new-product-management-experience": false,
"new-product-management-experience": true,
"onboarding": true,
"onboarding-tasks": true,
"payment-gateway-suggestions": true,
Expand Down
5 changes: 5 additions & 0 deletions plugins/woocommerce/client/legacy/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4375,6 +4375,11 @@ img.help_tip {
top: 20px;
}

td.help-tooltip {
white-space: nowrap;
width: 8px;
}

.select2-container {
vertical-align: top;
margin-bottom: 3px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ class="<?php echo esc_attr( $value['class'] ); ?>"
?>
<tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
<td class="help-tooltip"><?php echo isset( $value['tooltip'] ) && '' !== $value['tooltip'] ? wc_help_tip( esc_html( $value['tooltip'] ) ) : ''; ?></td>
Copy link
Member

Choose a reason for hiding this comment

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

Interestingly, this new cell creates an issue on the WooCommerce ▸ Settings ▸ Advanced ▸ Custom Data Stores screen, effectively displacing some other settings (because the rows above and below contain just two table cells):

wc-settings-advanced-custom-data-stores

I haven't had a chance to look in any depth—I just noticed while working on some HPOS stuff—but I wonder if this is causing a problem on other screens, too (and/or what the best solution is).

cc @octaedro

Copy link
Member

Choose a reason for hiding this comment

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

Does indeed impact a few places:

settings-advanced

(Settings > Advanced)

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 @barryhughes for reporting this.
I just created a PR to fix that.

<td class="forminp forminp-checkbox">
<fieldset>
<?php
Expand Down
12 changes: 7 additions & 5 deletions plugins/woocommerce/src/Admin/Features/Features.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class Features {
* @var array
*/
protected static $optional_features = array(
'multichannel-marketing' => array( 'default' => 'no' ),
'navigation' => array( 'default' => 'no' ),
'settings' => array( 'default' => 'no' ),
'analytics' => array( 'default' => 'yes' ),
'remote-inbox-notifications' => array( 'default' => 'yes' ),
'multichannel-marketing' => array( 'default' => 'no' ),
'navigation' => array( 'default' => 'no' ),
'settings' => array( 'default' => 'no' ),
'new-product-management-experience' => array( 'default' => 'no' ),
'analytics' => array( 'default' => 'yes' ),
'remote-inbox-notifications' => array( 'default' => 'yes' ),
);

/**
Expand All @@ -41,6 +42,7 @@ class Features {
protected static $beta_features = array(
'multichannel-marketing',
'navigation',
'new-product-management-experience',
'settings',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
*/
class NewProductManagementExperience {

/**
* Option name used to toggle this feature.
*/
const TOGGLE_OPTION_NAME = 'woocommerce_new_product_management_enabled';

/**
* Constructor
*/
Expand Down
23 changes: 18 additions & 5 deletions plugins/woocommerce/src/Internal/Features/FeaturesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Internal\Admin\Analytics;
use Automattic\WooCommerce\Admin\Features\Navigation\Init;
use Automattic\WooCommerce\Admin\Features\NewProductManagementExperience;
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Utilities\ArrayUtil;
Expand Down Expand Up @@ -89,25 +90,31 @@ class FeaturesController {
*/
public function __construct() {
$features = array(
'analytics' => array(
'analytics' => array(
'name' => __( 'Analytics', 'woocommerce' ),
'description' => __( 'Enables WooCommerce Analytics', 'woocommerce' ),
'is_experimental' => false,
'enabled_by_default' => true,
),
'new_navigation' => array(
'new_navigation' => array(
'name' => __( 'Navigation', 'woocommerce' ),
'description' => __( 'Adds the new WooCommerce navigation experience to the dashboard', 'woocommerce' ),
'is_experimental' => false,
),
'custom_order_tables' => array(
'new_product_management' => array(
'name' => __( 'New product editor', 'woocommerce' ),
'description' => __( 'Try the new product editor (Beta)', 'woocommerce' ),
'tooltip' => __( 'Enable to try the new, simplified product editor (currently in development and only available for simple products). No extension support yet.', 'woocommerce' ),
'is_experimental' => false,
),
'custom_order_tables' => array(
'name' => __( 'High-Performance order storage (COT)', 'woocommerce' ),
'description' => __( 'Enable the high performance order storage feature.', 'woocommerce' ),
'is_experimental' => true,
),
);

$this->legacy_feature_ids = array( 'analytics', 'new_navigation' );
$this->legacy_feature_ids = array( 'analytics', 'new_navigation', 'new_product_management' );

$this->init_features( $features );

Expand Down Expand Up @@ -393,6 +400,8 @@ public function feature_enable_option_name( string $feature_id ): string {
return Analytics::TOGGLE_OPTION_NAME;
} elseif ( 'new_navigation' === $feature_id ) {
return Init::TOGGLE_OPTION_NAME;
} elseif ( 'new_product_management' === $feature_id ) {
return NewProductManagementExperience::TOGGLE_OPTION_NAME;
}

return "woocommerce_feature_${feature_id}_enabled";
Expand Down Expand Up @@ -450,7 +459,7 @@ private function process_updated_option( string $option, $old_value, $value ) {
$matches = array();
$success = preg_match( '/^woocommerce_feature_([a-zA-Z0-9_]+)_enabled$/', $option, $matches );

if ( ! $success && Analytics::TOGGLE_OPTION_NAME !== $option && Init::TOGGLE_OPTION_NAME !== $option ) {
if ( ! $success && Analytics::TOGGLE_OPTION_NAME !== $option && Init::TOGGLE_OPTION_NAME !== $option && NewProductManagementExperience::TOGGLE_OPTION_NAME !== $option ) {
return;
}

Expand All @@ -462,6 +471,8 @@ private function process_updated_option( string $option, $old_value, $value ) {
$feature_id = 'analytics';
} elseif ( Init::TOGGLE_OPTION_NAME === $option ) {
$feature_id = 'new_navigation';
} elseif ( NewProductManagementExperience::TOGGLE_OPTION_NAME === $option ) {
$feature_id = 'new_product_management';
} else {
$feature_id = $matches[1];
}
Expand Down Expand Up @@ -590,6 +601,7 @@ private function get_setting_for_feature( string $feature_id, array $feature, bo
$description = $feature['description'];
$disabled = false;
$desc_tip = '';
$tooltip = isset( $feature['tooltip'] ) ? $feature['tooltip'] : '';

if ( ( 'analytics' === $feature_id || 'new_navigation' === $feature_id ) && $admin_features_disabled ) {
$disabled = true;
Expand Down Expand Up @@ -675,6 +687,7 @@ private function get_setting_for_feature( string $feature_id, array $feature, bo
'id' => $this->feature_enable_option_name( $feature_id ),
'disabled' => $disabled && ! $this->force_allow_enabling_features,
'desc_tip' => $desc_tip,
'tooltip' => $tooltip,
'default' => $this->feature_is_enabled_by_default( $feature_id ) ? 'yes' : 'no',
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ test.describe( 'Analytics pages', () => {
await page.goto(
`/wp-admin/admin.php?page=wc-admin&path=%2Fanalytics%2F${ urlTitle }`
);
const pageTitle = page.locator( 'h1' );
const pageTitle = page.locator(
'.woocommerce-layout__header-wrapper > h1'
);
await expect( pageTitle ).toContainText( aPages );
await expect(
page.locator( '#woocommerce-layout__primary' )
Expand Down
122 changes: 64 additions & 58 deletions plugins/woocommerce/tests/e2e-pw/tests/admin-tasks/payment.spec.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,91 @@
const { test, expect } = require('@playwright/test');
const wcApi = require('@woocommerce/woocommerce-rest-api').default;
const { test, expect } = require( '@playwright/test' );
const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default;

test.describe('Payment setup task', () => {
test.use({ storageState: process.env.ADMINSTATE });
test.describe( 'Payment setup task', () => {
test.use( { storageState: process.env.ADMINSTATE } );

test.beforeEach(async ({ page }) => {
await page.goto('wp-admin/admin.php?page=wc-admin&path=/setup-wizard');
await page.click('text=Skip setup store details');
await page.click('text=No thanks');
await page.waitForLoadState('networkidle');
});
test.beforeEach( async ( { page } ) => {
await page.goto(
'wp-admin/admin.php?page=wc-admin&path=/setup-wizard'
);
await page.click( 'text=Skip setup store details' );
await page.click( 'text=No thanks' );
await page.waitForLoadState( 'networkidle' );
} );

test.afterAll(async ({ baseURL }) => {
const api = new wcApi({
test.afterAll( async ( { baseURL } ) => {
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc/v3',
});
await api.put('payment_gateways/bacs', {
} );
await api.put( 'payment_gateways/bacs', {
enabled: false,
});
await api.put('payment_gateways/cod', {
} );
await api.put( 'payment_gateways/cod', {
enabled: false,
});
});
} );
} );

test('Can visit the payment setup task from the homescreen if the setup wizard has been skipped', async ({
test( 'Can visit the payment setup task from the homescreen if the setup wizard has been skipped', async ( {
page,
}) => {
await page.goto('wp-admin/admin.php?page=wc-admin');
await page.click('text=Set up payments');
await expect(page.locator('h1')).toHaveText('Set up payments');
});
} ) => {
await page.goto( 'wp-admin/admin.php?page=wc-admin' );
await page.click( 'text=Set up payments' );
await expect(
page.locator( '.woocommerce-layout__header-wrapper > h1' )
).toHaveText( 'Set up payments' );
} );

test('Saving valid bank account transfer details enables the payment method', async ({
test( 'Saving valid bank account transfer details enables the payment method', async ( {
page,
}) => {
} ) => {
// load the bank transfer page
await page.goto(
'wp-admin/admin.php?page=wc-admin&task=payments&id=bacs'
);
// purposely no await -- close the help dialog if/when it appears
page.locator('.components-button.is-small.has-icon')
page.locator( '.components-button.is-small.has-icon' )
.click()
.catch(() => {});
.catch( () => {} );

// fill in bank transfer form
await page.fill('//input[@placeholder="Account name"]', 'Savings');
await page.fill('//input[@placeholder="Account number"]', '1234');
await page.fill('//input[@placeholder="Bank name"]', 'Test Bank');
await page.fill('//input[@placeholder="Sort code"]', '12');
await page.fill('//input[@placeholder="IBAN"]', '12 3456 7890');
await page.fill('//input[@placeholder="BIC / Swift"]', 'ABBA');
await page.click('text=Save');
await page.fill( '//input[@placeholder="Account name"]', 'Savings' );
await page.fill( '//input[@placeholder="Account number"]', '1234' );
await page.fill( '//input[@placeholder="Bank name"]', 'Test Bank' );
await page.fill( '//input[@placeholder="Sort code"]', '12' );
await page.fill( '//input[@placeholder="IBAN"]', '12 3456 7890' );
await page.fill( '//input[@placeholder="BIC / Swift"]', 'ABBA' );
await page.click( 'text=Save' );

// check that bank transfers were set up
await expect(
page.locator('div.components-snackbar__content')
).toContainText('Direct bank transfer details added successfully');
page.locator( 'div.components-snackbar__content' )
).toContainText( 'Direct bank transfer details added successfully' );

await page.goto('wp-admin/admin.php?page=wc-settings&tab=checkout');
await page.goto( 'wp-admin/admin.php?page=wc-settings&tab=checkout' );

await expect(
page.locator('//tr[@data-gateway_id="bacs"]/td[@class="status"]/a')
).toHaveClass('wc-payment-gateway-method-toggle-enabled');
});
page.locator(
'//tr[@data-gateway_id="bacs"]/td[@class="status"]/a'
)
).toHaveClass( 'wc-payment-gateway-method-toggle-enabled' );
} );

test('Enabling cash on delivery enables the payment method', async ({
test( 'Enabling cash on delivery enables the payment method', async ( {
page,
baseURL,
}) => {
} ) => {
// Payments page differs if located outside of a WCPay-supported country, so make sure we aren't.
const api = new wcApi({
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc/v3',
});
} );
// ensure store address is US
await api.post('settings/general/batch', {
await api.post( 'settings/general/batch', {
update: [
{
id: 'woocommerce_store_address',
Expand All @@ -98,28 +104,28 @@ test.describe('Payment setup task', () => {
value: '94107',
},
],
});
await page.goto('wp-admin/admin.php?page=wc-admin&task=payments');
} );
await page.goto( 'wp-admin/admin.php?page=wc-admin&task=payments' );

// purposely no await -- close the help dialog if/when it appears
page.locator('.components-button.is-small.has-icon')
page.locator( '.components-button.is-small.has-icon' )
.click()
.catch(() => {});
await page.waitForLoadState('networkidle');
.catch( () => {} );
await page.waitForLoadState( 'networkidle' );

// purposely no await again
page.click('button.toggle-button');
page.click( 'button.toggle-button' );

// enable COD payment option
await page.click(
'div.woocommerce-task-payment-cod > div.woocommerce-task-payment__footer > button'
);
await page.waitForLoadState('networkidle');
await page.waitForLoadState( 'networkidle' );

await page.goto('wp-admin/admin.php?page=wc-settings&tab=checkout');
await page.goto( 'wp-admin/admin.php?page=wc-settings&tab=checkout' );

await expect(
page.locator('//tr[@data-gateway_id="cod"]/td[@class="status"]/a')
).toHaveClass('wc-payment-gateway-method-toggle-enabled');
});
});
page.locator( '//tr[@data-gateway_id="cod"]/td[@class="status"]/a' )
).toHaveClass( 'wc-payment-gateway-method-toggle-enabled' );
} );
} );