Skip to content

API PULL Feature (Beta)

Miguel Pérez Pellicer edited this page Apr 8, 2024 · 3 revisions

Enabling the Feature

For enabling the feature we created a filter which is false by default. Add this filter to activate the feature:

add_filter( 'woocommerce_gla_notifications_enabled', '__return_true' );

Grant access to Data fetch

This step is mandatory to make the Notifications to work.

⚠️ Notice enabling the feature and granting access will deactivate the current Push data mechanism.

  1. Complete the Onboarding
  2. Enter to this URL /wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsettings&google_wpcom_app_status=approved

Test steps for the feature disabled

  • Add the filter add_filter( 'woocommerce_gla_notifications_enabled', '__return_false' ); in your site
  • Go to Settings
  • No banner appears, and no extra info appears in the GMC card
  • Go to Connection test page
  • Sync a product (no async) and see that it is successfully sent to Google.
  • Sync all products (no async) and see that they are successfully sent to Google.
  • Delete all synced products (no async) and see that they are successfully deleted from Google.
  • Sync a product (async) and see gla/jobs/update_product/process is loaded in AS. Notification jobs are not scheduled.
  • Sync all products (async) and see gla/jobs/update_all_products/create_batch is loaded in AS. Notification jobs are not scheduled.
  • Delete all synced products (async) and see gla/jobs/delete_all_products/create_batch is loaded in AS Notification jobs are not scheduled.
  • Create and publish a new product and see gla/jobs/update_product/process is loaded in AS. Notification jobs are not scheduled.
  • In connection test page. Run a Notification and see how it fails.
  • Verify the WC - Logs and see something like "Error sending notification for Item ID 34 with topic product.create. Notification was not sent because the Notification Service is not ready or the topic is not valid."

Test steps for feature enabled

  • Add the filter add_filter( 'woocommerce_gla_notifications_enabled', '__return_true' ); in your site
  • Go to Settings
  • A banner appears. But No extra info appears in the GMC card
  • Test steps for the feature disabled again
  • Enter the URL wp-admin/admin.php?page=wc-admin&path=/google/settings&google_wpcom_app_status=error ( this is to simulate the Google error response when granting access)
  • The banner disappears and some info appears in the GMC card
  •  Enter the URL wp-admin/admin.php?page=wc-admin&path=/google/settings&google_wpcom_app_status=approved ( this is to simulate the Google success response when granting access)
  • The banner disappears and some info success appears in the GMC card
  • Go to connection test and send a notification. See its a success.
  • Sync a product (no async) and see the error "Error submitting product to Google: Pushing products will not run if the automatic data fetching is enabled. Please review your configuration in Google Listing and Ads settings.".
  • Sync all products (no async) and see the error "Error submitting products to Google: Pushing products will not run if the automatic data fetching is enabled. Please review your configuration in Google Listing and Ads settings.".
  • Delete all synced products (no async) and see the error "Error deleting products from Google: Pushing products will not run if the automatic data fetching is enabled. Please review your configuration in Google Listing and Ads settings."

Test Notifications with feature enabled

  • Create and publish a new product and see gla/jobs/notifications/products/process_item is loaded in AS with product.create topic. Update Product jobs are not scheduled.
  • Run the job and update the product. See gla/jobs/notifications/products/process_item is loaded in AS with product.update topic. Update Product jobs are not scheduled.
  • Run the job and delete the product. See gla/jobs/notifications/products/process_item is loaded in AS with product.delete topic. Update Product jobs are not scheduled.
  • Run the job and create a new product but save it as draft. Notification Job is NOT loaded in AS. Update Product jobs are not scheduled.
  • Publish it and see gla/jobs/notifications/products/process_item is loaded in AS with product.create topic. Update Product jobs are not scheduled.
  • Run the job and set the product as "Dont sync and show" see gla/jobs/notifications/products/process_item is loaded in AS with product.delete topic. Update Product jobs are not scheduled.
  •  Go to the WC logs. See the debug logs with the notifications.

Exposed REST API Endpoints

ℹ️ For getting the expected metadata (GLA metadata) the param gla_syncable=1 should be added to the URL.

  • GET wc/v3/products | Only products with _wc_gla_visibility set to sync-and-show. Excludes private metadata (metadata that begins with _ unless it’s associated with GLA).
  • GET wc/v3/products/<productID> | Exclude private metadata (metadata that begins with _ unless it’s associated with GLA).
  • GET wc/v3/products/<productID>/variations | Exclude private metadata (metadata that begins with _ unless it’s associated with GLA).
  • GET wc/v3/products/<productID>/variations/<id> | Exclude private metadata (metadata that begins with _ unless it’s associated with GLA).
  • GET wc/v3/shipping/zones
  • GET wc/v3/shipping/zones/<id>
  • GET wc/v3/shipping/zones/<zone_id>/methods
  • GET wc/v3/shipping/zones/<zone_id>/methods/<id>
  • GET wc/v3/coupons | The response should only include coupons meeting the criteria of having _wc_gla_visibility set to sync-and-show and not containing email_restrictions.
  • GET wc/v3/coupons/<id>
  • GET wc/v3/settings/general | Including Shipping Times and Target Audiences