Skip to content
Closed
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
35 changes: 34 additions & 1 deletion .github/workflows/product-creation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ on:
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
use-marketplace-version:
description: 'Should this use marketplace version of the plugin'
required: false
type: boolean
default: false
pull_request:
branches: [ main, master, develop ]

Expand Down Expand Up @@ -149,7 +156,18 @@ jobs:
cd /tmp/wordpress
fi

# Activate the plugin
# Configure Facebook connection before activation
wp option update wc_facebook_access_token "${{ secrets.FB_ACCESS_TOKEN }}" --allow-root
wp option update wc_facebook_merchant_access_token "${{ secrets.FB_ACCESS_TOKEN }}" --allow-root
wp option update wc_facebook_business_manager_id "${{ secrets.FB_BUSINESS_MANAGER_ID }}" --allow-root
wp option update wc_facebook_external_business_id "${{ secrets.FB_EXTERNAL_BUSINESS_ID }}" --allow-root
wp option update wc_facebook_product_catalog_id "${{ secrets.FB_PRODUCT_CATALOG_ID }}" --allow-root
wp option update wc_facebook_pixel_id "${{ secrets.FB_PIXEL_ID }}" --allow-root
wp option update wc_facebook_has_connected_fbe_2 "yes" --allow-root
Copy link
Contributor

Choose a reason for hiding this comment

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

The following rows we might also wanna add as repo variables

wp option update wc_facebook_has_authorized_pages_read_engagement "yes" --allow-root
wp option update wc_facebook_enable_product_sync "yes" --allow-root
wp option update wc_facebook_page_id "${{ secrets.FB_PAGE_ID }}" --allow-root
# Activate the plugin (this triggers automatic sync)
wp plugin activate facebook-for-woocommerce --allow-root


Expand All @@ -166,6 +184,21 @@ jobs:
# Test if site is accessible
curl -f http://localhost:8080 || exit 1

- name: Verify Facebook for WooCommerce setup
run: |
cd /tmp/wordpress
echo "=== Facebook for WooCommerce Info ==="
wp eval "
if (function_exists('facebook_for_woocommerce')) {
\$connection = facebook_for_woocommerce()->get_connection_handler();
echo 'Connected: ' . (\$connection->is_connected() ? 'YES' : 'NO') . PHP_EOL;
echo 'Access Token: ' . (\$connection->get_access_token() ? 'Present' : 'Missing') . PHP_EOL;
echo 'External Business ID: ' . \$connection->get_external_business_id() . PHP_EOL;
echo 'Business Manager ID: ' . \$connection->get_business_manager_id() . PHP_EOL;
} else {
echo 'Facebook plugin not loaded properly';
}" --allow-root

- name: Install Playwright
run: |
npm install
Expand Down
17 changes: 17 additions & 0 deletions includes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,23 @@ public function get_product_facebook_ids( string $facebook_product_catalog_id, s
}


/**
* Returns requested fields from Facebook for the given product.
*
* @param string $facebook_product_catalog_id
* @param string $facebook_retailer_id
* @param string $fields_string Comma-separated string of fields to request from Facebook API.
* @return API\Response|API\ProductCatalog\Products\Id\Response
* @throws ApiException In case of network request error.
* @throws API\Exceptions\Request_Limit_Reached In case of rate limit error.
*/
public function get_product_facebook_fields( string $facebook_product_catalog_id, string $facebook_retailer_id, string $fields_string = 'id,product_group{id}' ): API\ProductCatalog\Products\Id\Response {
$request = new API\ProductCatalog\Products\Id\Request( $facebook_product_catalog_id, $facebook_retailer_id, $fields_string );
$this->set_response_handler( API\ProductCatalog\Products\Id\Response::class );
return $this->perform_request( $request );
}


/**
* @param string $product_catalog_id
* @param array $data
Expand Down
5 changes: 3 additions & 2 deletions includes/API/ProductCatalog/Products/Id/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class Request extends ApiRequest {
/**
* @param string $facebook_product_catalog_id Facebook Product Catalog ID.
* @param string $facebook_product_retailer_id Facebook Product Retailer ID.
* @param string $fields_string Comma-separated string of fields to request from Facebook API.
*/
public function __construct( string $facebook_product_catalog_id, string $facebook_product_retailer_id ) {
public function __construct( string $facebook_product_catalog_id, string $facebook_product_retailer_id, string $fields_string = 'id,product_group{id}' ) {

/**
* We use the endpoint with filter to get the product id and group id for new products to check if the product is already synced to Facebook.
Expand All @@ -29,7 +30,7 @@ public function __construct( string $facebook_product_catalog_id, string $facebo
$this->set_params(
array(
'filter' => '{"retailer_id":{"eq":"' . $facebook_product_retailer_id . '"}}',
'fields' => 'id,product_group{id}',
'fields' => $fields_string,
)
);
}
Expand Down
Loading
Loading