-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78e7988
commit f9017a5
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace RemoteDataBlocks\Example\Shopify; | ||
|
||
use RemoteDataBlocks\Integrations\Shopify\Queries\ShopifyGetProductQuery; | ||
use RemoteDataBlocks\Integrations\Shopify\Queries\ShopifySearchProductsQuery; | ||
use RemoteDataBlocks\Integrations\Shopify\ShopifyDataSource; | ||
use RemoteDataBlocks\Logging\LoggerManager; | ||
use function RemoteDataBlocks\Example\get_access_token; | ||
|
||
function register_shopify_block(): void { | ||
$block_name = 'Shopify Example'; | ||
$access_token = get_access_token( 'shopify' ); | ||
$store_name = 'stoph-test'; | ||
|
||
if ( empty( $access_token ) ) { | ||
$logger = LoggerManager::instance(); | ||
$logger->warning( sprintf( '%s is not defined, cannot register %s block', 'EXAMPLE_SHOPIFY_ACCESS_TOKEN', $block_name ) ); | ||
return; | ||
} | ||
|
||
$shopify_data_source = ShopifyDataSource::create( $access_token, $store_name ); | ||
$shopify_search_products_query = new ShopifySearchProductsQuery( $shopify_data_source ); | ||
$shopify_get_product_query = new ShopifyGetProductQuery( $shopify_data_source ); | ||
|
||
register_remote_data_block( $block_name, $shopify_get_product_query ); | ||
register_remote_data_search_query( $block_name, $shopify_search_products_query ); | ||
} | ||
add_action( 'init', __NAMESPACE__ . '\\register_shopify_block' ); |