woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
44 stars 21 forks source link

API Pull - Enable pull and push mechanism to work together #2428

Closed jorgemd24 closed 2 months ago

jorgemd24 commented 2 months ago

Changes proposed in this Pull Request:

Part of https://github.com/woocommerce/google-listings-and-ads/issues/2146

For the initial launch, we want to keep both the pull and push mechanisms working together. This PR enables sending the notification (pull mechanism) and the usual job to push the data.

Screenshots:

Detailed test instructions:

  1. Enable the Pull mechanism with the following filter: add_filter( 'woocommerce_gla_notifications_enabled', '__return_true' ); and run this command wp option update gla_wpcom_rest_api_status "approved"

Create Product

  1. Create a product with the visibility "Sync and Show"
  2. Go to WC -> Status -> Scheduled jobs
  3. See that there is a job gla/jobs/update_products/process_item with the product that you created
  4. See that there is a job gla/jobs/notifications/products/process_item with the itemID = the product ID that you created and the topic product.create

Update Product

  1. Update a product
  2. See that there is a job gla/jobs/update_products/process_item with the product that you updated
  3. See that there is a job gla/jobs/notifications/products/process_item with the itemID = the product ID that you updated and the topic product.update

Delete Product

  1. Delete a product
  2. See that there is a job gla/jobs/delete_products/process_item with the product that you deleted.
  3. See that there is a job gla/jobs/notifications/products/process_item with the itemID = the product ID that you deleted and the topic product.delete

Create Coupon

  1. Create a coupon with the visibility "Show Coupon on Google"
  2. See that there is a job gla/jobs/update_coupon/process_item with the coupon that you created
  3. See that there is a job gla/jobs/notifications/coupons/process_item with the itemID = the coupon ID that you created and the topic coupon.create

Update Coupon

  1. Update a coupon
  2. See that there is a job gla/jobs/update_coupon/process_item with the coupon that you updated
  3. See that there is a job gla/jobs/notifications/coupons/process_item with the itemID = the coupon ID that you updated and the topic product.update

Delete Coupon

  1. Delete a product
  2. See that there is a job gla/jobs/delete_coupon/process_item with the coupon that you deleted.
  3. See that there is a job gla/jobs/notifications/coupons/process_item with the itemID = the coupon ID that you deleted and the topic coupon.delete

Update Shipping Settings

  1. Go to WC -> Settings -> Shippings and edit one of the shipping methods
  2. See that there is a job gla/jobs/update_shipping_settings/process_item` scheduled
  3. See that there is a job gla/jobs/notifications/shipping/process_item with the topic shipping.update

Additional details:

Currently, for shipping notifications, we haven't included the topic in the body, only in the header. For consistency, I think it's better to include it in the body as well, so I added it here.: https://github.com/woocommerce/google-listings-and-ads/pull/2428/files#diff-f9aaeb6620028c10c8ce8c3178abf2f6db34168939ba33c4d8bcef410a5125b5R148

Changelog entry