Skip to content

Commit

Permalink
Merge pull request #308 from Ecwid/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
meteor-ec authored Dec 5, 2024
2 parents 6f499d8 + b3306f8 commit bc78c3c
Show file tree
Hide file tree
Showing 49 changed files with 25,545 additions and 25 deletions.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.git
/.github
/node_modules
/gutenberg-blocks

.distignore
.gitignore
Expand Down
26 changes: 24 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
.idea
.vscode
/WordPress
Expand All @@ -9,4 +8,27 @@ bin/
composer.lock
phpunit.xml.dist
tests/
vendor/
vendor/

# Directories/files that may be generated by this project
build
build-module
build-style
build-types
node_modules
coverage
.phpunit.result.cache
.reassure

# Directories/files that may appear in your environment
*.log
yarn.lock
results
/artifacts
/test/e2e/artifacts
/perf-envs
/composer.lock

# Operating system specific files
.DS_Store
Thumbs.db
6 changes: 6 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"core": null,
"plugins": [
"."
]
}
33 changes: 20 additions & 13 deletions ecwid-shopping-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
add_action( 'wp_ajax_ecwid_hide_vote_message', 'ecwid_hide_vote_message' );
add_action( 'wp_ajax_ecwid_hide_message', 'ecwid_ajax_hide_message' );
add_action( 'wp_ajax_ecwid_reset_categories_cache', 'ecwid_reset_categories_cache' );
add_action( 'wp_ajax_ecwid_create_store', 'ecwid_create_store' );
add_action( 'wp_ajax_ecwid_create_store', 'ecwid_ajax_create_store' );
add_action( 'wp_ajax_ecwid_sync_products', 'ecwid_sync_products' );

add_action( 'admin_post_ecwid_sync_products', 'ecwid_sync_products' );
Expand Down Expand Up @@ -2199,34 +2199,41 @@ function ecwid_get_demo_store_public_key() {
return false;
}

function ecwid_create_store() {
function ecwid_create_store( $params = array() ) {
$api = new Ecwid_Api_V3();

$result = $api->create_store();
$result = $api->create_store( $params );

$is_store_created = is_array( $result ) && $result['response']['code'] == 200;

if ( is_array( $result ) && $result['response']['code'] == 200 ) {
if ( $is_store_created ) {
$data = json_decode( $result['body'] );

ecwid_update_store_id($data->id);
ecwid_update_store_id( $data->id );

$api->save_token( $data->token );

do_action( 'ecwid_authorization_success' );

update_option( 'ecwid_oauth_scope', 'read_profile ' . Ecwid_OAuth::SCOPE_READ_CATALOG . ' create_catalog update_catalog allow_sso create_customers public_storefront' );
}

header( 'HTTP/1.1 200 OK' );
return $result;
}

} else {

if( is_wp_error( $result ) ) {
header( 'HTTP/1.1 409 Error' );
die();
}
function ecwid_ajax_create_store() {
$result = ecwid_create_store();
$is_store_created = is_array( $result ) && $result['response']['code'] == 200;

if( $is_store_created ) {
header( 'HTTP/1.1 200 OK' );
} elseif ( is_wp_error( $result ) ) {
header( 'HTTP/1.1 409 Error' );
} else {
header( 'HTTP/1.1 ' . $result['response']['code'] . ' ' . $result['response']['message'] );
die();
}

die();
}

add_action('admin_post_ecwid-do-sso', 'ecwid_do_sso_redirect');
Expand Down
Loading

0 comments on commit bc78c3c

Please sign in to comment.