google-listings-and-ads
google-listings-and-ads copied to clipboard
Show promo for setting up Google Ads on reports and product feed tabs
This will likely be blocked until #2599 is resolved.
@joemcgill I've added the IB. Can you kindly take a look and let me know please?
There is an existing issue with useAdsCampaigns that was discovered in https://github.com/woocommerce/google-listings-and-ads/pull/2242#issuecomment-2026060492, where the hook will not fetch existing Ads accounts in certain circumstances.
I think we can fix this by replacing the TODO comment in the useAdsCampaign hook with a check for whether there is a Google Ads connection. Here's the idea:
diff --git a/js/src/hooks/useAdsCampaigns.js b/js/src/hooks/useAdsCampaigns.js
index 5975aec45..235b12a6a 100644
--- a/js/src/hooks/useAdsCampaigns.js
+++ b/js/src/hooks/useAdsCampaigns.js
@@ -7,7 +7,7 @@ import { useSelect } from '@wordpress/data';
* Internal dependencies
*/
import { STORE_KEY } from '.~/data';
-import { glaData } from '.~/constants';
+import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
import useIsEqualRefValue from '.~/hooks/useIsEqualRefValue';
const selectorName = 'getAdsCampaigns';
@@ -30,16 +30,12 @@ const selectorName = 'getAdsCampaigns';
*/
const useAdsCampaigns = ( ...query ) => {
const queryRefValue = useIsEqualRefValue( query );
+ const { hasGoogleAdsConnection, hasFinishedResolution } =
+ useGoogleAdsAccount();
return useSelect(
( select ) => {
- // TODO: ideally adsSetupComplete should be retrieved from API endpoint
- // and then put into wp-data.
- // With that in place, then we don't need to depend on glaData
- // which requires force reload using window.location.href.
- const { adsSetupComplete } = glaData;
-
- if ( ! adsSetupComplete ) {
+ if ( hasFinishedResolution && ! hasGoogleAdsConnection ) {
return {
loading: false,
loaded: true,
I think we should reuse the AddPaidCampaignButton component directly here, rather than creating a different one. I've added info about what eventProps name to add, which we can change later based on feedback during WooCR (cc: @eason9487).
The eventProps for this requirement could be { context: 'product-feed-overview-promotion' }
Closing this as completed since it was part of the 2.9 release.