Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marketing: Do not show "Create a campaign" button if there are no campaign types #38825

Merged
merged 6 commits into from Jun 21, 2023

Conversation

ecgan
Copy link
Member

@ecgan ecgan commented Jun 20, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes #38805.

In this PR, we add conditions for rendering the "Create a campaign" button in the Introduction Banner card:

  • When there are no supported campaign types, the "Create a campaign" button and "Add channels" button will not be displayed (note that when there are no campaign types, the "Campaigns" card will not be displayed too):

image

  • When there are supported campaign types, the "Create a campaign" button will be displayed (the "Campaigns" card is displayed here, with a "Create new campaign" button in the card header):

image

I also added code for the "Create new campaign" button in the "Campaigns" card, so that "Create new campaign" button will not be shown when there are no campaign types. See the example screenshot below. Note that currently the "Campaigns" card is not displayed when there are no campaign types; this is because there is no match between the supported campaign types and the campaign types in the marketing campaigns, and the GET /marketing/campaigns API call returns an error instead of campaigns data. The code added is for "future proofing" just in case.

image

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Note: to test the changes, you may need to use some test data in some marketing channel extension. The following is an example of how to do that using Google Listings and Ads:

  1. Enable multichannel marketing for Google Listings and Ads using the following script:
add_filter( 'woocommerce_gla_enable_mcm', function( $enabled ) {
	return true;
});
  1. Modify the get_campaigns function in https://github.com/woocommerce/google-listings-and-ads/blob/33243ae88cf0b930d9956903738ececb5069a11e/src/MultichannelMarketing/GLAChannel.php#LL178C42-L178C42, so that it returns some sample marketing campaigns:
	public function get_campaigns(): array {
		return [
			new MarketingCampaign(
				'1',
				$this->campaign_types['google-ads'],
				'Test campaign',
				admin_url( 'admin.php?page=wc-admin&path=/google/settings&subpath=/campaigns/edit' ),
				new Price( '100', 'USD' ),
			),
			new MarketingCampaign(
				'2',
				$this->campaign_types['google-ads'],
				'Test campaign 2',
				admin_url( 'admin.php?page=wc-admin&path=/google/settings&subpath=/campaigns/edit' ),
				new Price( '100', 'USD' ),
			),
		];
	}
  1. Modify the generate_campaign_types function in https://github.com/woocommerce/google-listings-and-ads/blob/33243ae88cf0b930d9956903738ececb5069a11e/src/MultichannelMarketing/GLAChannel.php#L213-L224, so that it returns empty array for campaign types:
	protected function generate_campaign_types(): array {
		return [];
	}

Test Steps:

  1. Go to the WooCommerce > Marketing page: /wp-admin/admin.php?page=wc-admin&path=%2Fmarketing
  2. Without modifying generate_campaign_types, you should see "Create a campaign" button in the introduction banner, and you should see "Create a campaign" button in the "Campaigns" card.
  3. Modify the generate_campaign_types function to return empty array. You should NOT see "Create a campaign" button in the introduction banner. The "Campaigns" card should not be shown. In the browser network panel, you should see an error for the GET /marketing/campaigns API call.

@ecgan ecgan added the focus: marketing Marketing page in WooCommerce Admin, i.e. `/wp-admin/admin.php?page=wc-admin&path=%2Fmarketing`. label Jun 20, 2023
@ecgan ecgan requested review from a team June 20, 2023 13:48
@ecgan ecgan self-assigned this Jun 20, 2023
@github-actions github-actions bot added focus: react admin [team:Ghidorah] plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jun 20, 2023
@github-actions
Copy link
Contributor

Hi , @woocommerce/ventures, @woocommerce/automata

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

1 similar comment
@github-actions
Copy link
Contributor

Hi , @woocommerce/ventures, @woocommerce/automata

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@github-actions
Copy link
Contributor

github-actions bot commented Jun 20, 2023

Test Results Summary

Commit SHA: 04294c4

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202611m 0s
E2E Tests1900018020814m 16s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

Copy link
Contributor

@budzanowski budzanowski left a comment

Choose a reason for hiding this comment

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

Looks good. I have left one comment for the comment copy and one comment for the logic. It works if you disregard the comment so it is up to you if you want to use it. Either way approving. Nice change!

@ecgan ecgan merged commit f31eca2 into trunk Jun 21, 2023
17 checks passed
@ecgan ecgan deleted the feature/38805-create-campaign-button branch June 21, 2023 11:43
@github-actions github-actions bot added this to the 8.0.0 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: marketing Marketing page in WooCommerce Admin, i.e. `/wp-admin/admin.php?page=wc-admin&path=%2Fmarketing`. plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marketing: Do not show "Create a campaign" button if there are no campaign types
2 participants