Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
fix phpcs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
senadir committed Sep 19, 2023
1 parent 6676c83 commit e11b507
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Domain/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function() {
$this->container->get( DraftOrders::class )->init();
$this->container->get( CreateAccount::class )->init();
$this->container->get( ShippingController::class )->init();
$this->container->get( JetpackWooCommerceAnalytics::class )->init();

// Load assets in admin and on the frontend.
if ( ! $is_rest ) {
Expand All @@ -138,7 +139,6 @@ function() {
$this->container->get( AssetsController::class );
$this->container->get( Installer::class )->init();
$this->container->get( GoogleAnalytics::class )->init();
$this->container->get( JetpackWooCommerceAnalytics::class )->init();
}

// Load assets unless this is a request specifically for the store API.
Expand Down
18 changes: 11 additions & 7 deletions src/Domain/Services/JetpackWooCommerceAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ public function __construct( AssetApi $asset_api, AssetDataRegistry $asset_data_
*/
public function init() {
add_action( 'init', array( $this, 'check_compatibility' ) );
add_action( 'init', array( $this, 'init_if_compatible' ), 20 );
add_action( 'rest_pre_serve_request', array( $this, 'track_local_pickup' ), 10, 4 );

$is_rest = wc()->is_rest_api_request();
if ( ! $is_rest ) {
add_action( 'init', array( $this, 'init_if_compatible' ), 20 );
}
}

/**
Expand Down Expand Up @@ -340,9 +344,9 @@ private function get_nested_blocks( $blocks, $exclude = array() ) {
/**
* Track local pickup settings changes via Store API
*
* @param bool $served
* @param \WP_REST_Response $result
* @param \WP_REST_Request $request
* @param bool $served Whether the request has already been served.
* @param \WP_REST_Response $result The response object.
* @param \WP_REST_Request $request The request object.
* @return bool
*/
public function track_local_pickup( $served, $result, $request ) {
Expand All @@ -365,16 +369,16 @@ public function track_local_pickup( $served, $result, $request ) {

$data = array(
'local_pickup_enabled' => 'yes' === $settings['enabled'] ? true : false,
'title' => $settings['title'],
'price' => '' === $settings['cost'],
'title' => __( 'Local Pickup', 'woo-gutenberg-products-block' ) === $settings['title'],
'price' => '' === $settings['cost'] ? true : false,
'cost' => '' === $settings['cost'] ? 0 : $settings['cost'],
'taxes' => $settings['tax_status'],
'total_pickup_locations' => count( $locations ),
'pickup_locations_enabled' => count(
array_filter(
$locations,
function( $location ) {
return 'yes' === $location['enabled']; }
return $location['enabled']; }
)
),
);
Expand Down

0 comments on commit e11b507

Please sign in to comment.