Skip to content

Commit c6db2a8

Browse files
authored
Merge pull request #205 from moderntribe/release/3.16.0
packaged version 3.16.0
2 parents 5cd95e5 + 2d59391 commit c6db2a8

24 files changed

+310
-28
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [3.16.0]
4+
5+
### Changed
6+
7+
- Removed the notification to finish setting up shipping methods. So long as at least one
8+
shipping zone exists (and it will always exist), the notification will not be displayed.
9+
- Webhooks can be toggled on or off.
10+
311
## [3.15.0]
412

513
### Added

bigcommerce.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: BigCommerce for WordPress
44
Description: Scale your ecommerce business with WordPress on the front-end and BigCommerce on the back end. Free up server resources from things like catalog management, processing payments, and managing fulfillment logistics.
55
Author: BigCommerce
6-
Version: 3.15.0
6+
Version: 3.16.0
77
Author URI: https://www.bigcommerce.com/wordpress
88
Requires PHP: 5.6.24
99
Text Domain: bigcommerce

build-timestamp.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?php
2-
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '5.36.03.13.2020');
2+
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '5.42.03.20.2020');

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: bigcommerce, moderntribe, jbrinley, becomevocal, vincentlistrani,
33
Tags: ecommerce, online store, sell online, storefront, retail, online shop, bigcommerce, big commerce, e-commerce, physical products, buy buttons, commerce, shopping cart, checkout, cart, shop, headless commerce, shipping, payments, fulfillment
44
Requires at least: 4.6
55
Tested up to: 5.3
6-
Stable tag: 3.15.0
6+
Stable tag: 3.16.0
77
Requires PHP: 5.6.24
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html

src/BigCommerce/Api/Webhooks_Api.php

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
namespace BigCommerce\Api;
99

1010
class Webhooks_Api extends v2ApiAdapter {
11+
public function listWebhooks( ) {
12+
return call_user_func( [ $this->client_class, 'listWebhooks' ] );
13+
}
14+
1115
public function createWebhook( $object ) {
1216
return call_user_func( [ $this->client_class, 'createWebhook' ], $object );
1317
}

src/BigCommerce/CLI/Reset_Plugin.php

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace BigCommerce\CLI;
55

6+
use BigCommerce\Webhooks\Webhook_Versioning;
7+
68
/**
79
* Class Reset_Plugin
810
*
@@ -28,6 +30,9 @@ public function run( $args, $assoc_args ) {
2830
'bigcommerce_account_id',
2931
'bigcommerce_store_id',
3032
'bigcommerce_channel_id',
33+
'bigcommerce_channel_id',
34+
'bigcommerce_webhooks',
35+
'schema-' . Webhook_Versioning::class,
3136
'bigcommerce_store_url',
3237
'bigcommerce_client_id',
3338
'bigcommerce_client_secret',

src/BigCommerce/Checkout/Requirements_Notice.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public function check_requirements() {
3636
$status = $this->status->get_current_status();
3737
$notices = [];
3838

39-
if ( empty( $status['shipping_methods'] ) ) {
39+
if ( empty( $status['shipping_zones'] ) ) {
4040
$notices[] = sprintf(
41-
__( 'Shipping has not been set up. %s', 'bigcommerce' ),
41+
__( 'Shipping Zones have not been set up. %s', 'bigcommerce' ),
4242
sprintf( '<a href="%s">%s</a>', esc_url( $this->status->get_shipping_configuration_url() ), __( 'Configure Shipping', 'bigcommerce' ) )
4343
);
4444
}

src/BigCommerce/Container/Settings.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use BigCommerce\Settings\Sections\Nav_Menu_Options;
3535
use BigCommerce\Settings\Sections\New_Account_Section;
3636
use BigCommerce\Settings\Sections\Next_Steps;
37+
use BigCommerce\Settings\Sections\Onboarding_Import_Settings;
3738
use BigCommerce\Settings\Sections\Reviews;
3839
use BigCommerce\Settings\Sections\Troubleshooting_Diagnostics;
3940
use BigCommerce\Settings\Site_Update;
@@ -64,6 +65,7 @@ class Settings extends Provider {
6465
const REVIEWS_SECTION = 'settings.section.reviews';
6566
const NEW_ACCOUNT_SECTION = 'settings.section.new_account';
6667
const SELECT_CHANNEL_SECTION = 'settings.section.select_channel';
68+
const IMPORT_SETTINGS_SECTION = 'settings.section.import_settings';
6769
const CHANNEL_SECTION = 'settings.section.channel';
6870
const DIAGNOSTICS_SECTION = 'settings.section.diagnostics';
6971
const MENU_OPTIONS_SECTION = 'settings.section.nav_menu_options';
@@ -461,11 +463,15 @@ private function onboarding( Container $container ) {
461463
$container[ self::CHANNEL_SCREEN ]->register_settings_page();
462464
} ), 10, 0 );
463465

464-
$container [ self::SELECT_CHANNEL_SECTION ] = function ( Container $container ) {
466+
$container [ self::SELECT_CHANNEL_SECTION ] = function ( Container $container ) {
465467
return new Channel_Select();
466468
};
469+
$container [ self::IMPORT_SETTINGS_SECTION ] = function ( Container $container ) {
470+
return new Onboarding_Import_Settings();
471+
};
467472
add_action( 'bigcommerce/settings/register/screen=' . Connect_Channel_Screen::NAME, $this->create_callback( 'select_channel_section_register', function () use ( $container ) {
468473
$container[ self::SELECT_CHANNEL_SECTION ]->register_settings_section();
474+
$container[ self::IMPORT_SETTINGS_SECTION ]->register_settings_section();
469475
} ), 10, 0 );
470476

471477
$container [ self::CHANNEL_SECTION ] = function ( Container $container ) {

src/BigCommerce/Container/Webhooks.php

+41-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
namespace BigCommerce\Container;
99

10+
use BigCommerce\Settings\Sections\Import as Import_Settings;
1011
use BigCommerce\Webhooks\Checkout_Complete_Webhook;
1112
use BigCommerce\Webhooks\Product_Inventory_Update_Webhook;
1213
use BigCommerce\Webhooks\Product_Update_Webhook;
1314
use BigCommerce\Webhooks\Product_Updater;
15+
use BigCommerce\Webhooks\Status;
1416
use BigCommerce\Webhooks\Webhook;
1517
use BigCommerce\Webhooks\Webhook_Cron_Tasks;
1618
use BigCommerce\Webhooks\Webhook_Listener;
@@ -22,6 +24,7 @@
2224
*/
2325
class Webhooks extends Provider {
2426
const WEBHOOKS = 'webhooks.webhooks';
27+
const WEBHOOKS_STATUS = 'webhooks.webhooks_status';
2528
const WEBHOOKS_LISTENER = 'webhooks.listener_webhook';
2629
const PRODUCT_UPDATE_WEBHOOK = 'webhooks.product_update_webhook';
2730
const PRODUCT_INVENTORY_UPDATE_WEBHOOK = 'webhooks.inventory_update_webhook';
@@ -32,12 +35,19 @@ class Webhooks extends Provider {
3235

3336
public function register( Container $container ) {
3437
$this->declare_webhooks( $container );
38+
$this->status( $container );
3539
$this->register_webhooks( $container );
40+
41+
3642
$this->handle_requests( $container );
3743
$this->webhook_actions( $container );
3844
$this->cron_actions( $container );
3945
}
4046

47+
private function webhooks_enabled() {
48+
return get_option( Import_Settings::ENABLE_WEBHOOKS, 1 );
49+
}
50+
4151
/**
4252
* Declare all of the webhooks that will be registered by the plugin.
4353
* The list of Webhook instances should be returned in $container[ self::WEBHOOKS ]
@@ -75,6 +85,24 @@ private function declare_webhooks( Container $container ) {
7585
};
7686
}
7787

88+
private function status( Container $container ) {
89+
$container[ self::WEBHOOKS_STATUS ] = function ( Container $container ) {
90+
return new Status( $container[ self::WEBHOOKS ], $container[ Api::FACTORY ]->webhooks() );
91+
};
92+
93+
add_action( 'update_option_' . Import_Settings::ENABLE_WEBHOOKS, function( $old_value, $new_value, $option_name ) use ($container) {
94+
$container[ self::WEBHOOKS_STATUS ]->update_option( $old_value, $new_value, $option_name );
95+
}, 10, 3 );
96+
97+
add_action( 'add_option_' . Import_Settings::ENABLE_WEBHOOKS, function( $option_name, $value ) use ($container) {
98+
$container[ self::WEBHOOKS_STATUS ]->update_option( null, $value, $option_name );
99+
}, 10, 2 );
100+
101+
add_filter( 'bigcommerce/diagnostics', $this->create_callback( 'webhook_diagnostics', function ( $data ) use ( $container ) {
102+
return $container[ self::WEBHOOKS_STATUS ]->diagnostic_data( $data );
103+
} ), 10, 1 );
104+
}
105+
78106
/**
79107
* Register the webhooks with the BigCommerce API
80108
*
@@ -87,7 +115,7 @@ private function register_webhooks( Container $container ) {
87115
return new Webhook_Versioning( $container[ self::WEBHOOKS ] );
88116
};
89117

90-
add_action( 'bigcommerce/import/fetched_store_settings', $this->create_callback( 'check_and_update_webhooks_version', function () use ( $container ) {
118+
add_action( 'bigcommerce/settings/webhoooks_updated', $this->create_callback( 'check_and_update_webhooks_version', function () use ( $container ) {
91119
$container[ self::WEBHOOKS_VERSIONING ]->maybe_update_webhooks();
92120
} ), 10, 0 );
93121
}
@@ -104,6 +132,10 @@ private function handle_requests( Container $container ) {
104132
return new Webhook_Listener( $container[ self::WEBHOOKS ] );
105133
};
106134

135+
if ( ! $this->webhooks_enabled() ) {
136+
return;
137+
}
138+
107139
// Listener for all webhook actions
108140
add_action( 'bigcommerce/action_endpoint/webhook', $this->create_callback( 'webhook_listener', function ( $args ) use ( $container ) {
109141
$container[ self::WEBHOOKS_LISTENER ]->handle_request( $args );
@@ -118,6 +150,10 @@ private function webhook_actions( Container $container ) {
118150
return new Webhook_Cron_Tasks();
119151
};
120152

153+
if ( ! $this->webhooks_enabled() ) {
154+
return;
155+
}
156+
121157
// Update product inventory webhook cron task
122158
add_action( 'bigcommerce/webhooks/product_inventory_updated', $this->create_callback( 'check_and_update_product_inventory_task', function ( $params ) use ( $container ) {
123159
$container[ self::WEBHOOKS_CRON_TASKS ]->set_product_update_cron_task( $params );
@@ -130,6 +166,10 @@ private function cron_actions( Container $container ) {
130166
return new Product_Updater( $container[ Api::FACTORY ]->catalog(), $container[ Api::FACTORY ]->channels() );
131167
};
132168

169+
if ( ! $this->webhooks_enabled() ) {
170+
return;
171+
}
172+
133173
add_action( Webhook_Cron_Tasks::UPDATE_PRODUCT, $this->create_callback( 'update_product_cron_handler', function ( $product_id ) use ( $container ) {
134174
$container[ self::PRODUCT_UPDATER ]->update( $product_id );
135175
} ), 10, 1 );

src/BigCommerce/Merchant/Setup_Status.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ public function get_required_steps() {
166166
];
167167
}
168168

169-
if ( empty( $status['shipping_methods'] ) ) {
169+
if ( empty( $status['shipping_zones'] ) ) {
170170
$steps['shipping'] = [
171-
'heading' => __( 'Update Your Shipping Address and Settings', 'bigcommerce' ),
171+
'heading' => __( 'Configure Your Shipping Zones', 'bigcommerce' ),
172172
'url' => $this->get_shipping_configuration_url(),
173173
'label' => __( 'Open BigCommerce', 'bigcommerce' ),
174174
'icon' => 'shipping_returns',

src/BigCommerce/Plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace BigCommerce;
55

66
class Plugin {
7-
const VERSION = '3.15.0';
7+
const VERSION = '3.16.0';
88

99
protected static $_instance;
1010

src/BigCommerce/Settings/Import_Status.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct( Task_Manager $manager ) {
3232
/**
3333
* @return void
3434
* @action bigcommerce/settings/onboarding/progress
35-
* @action bigcommerce/settings/section/after_fields/id= . Import_Settings::NAME
35+
* @action bigcommerce/settings/section/after_fields/id= . Onboarding_Import_Settings::NAME
3636
*/
3737
public function render_status() {
3838
$this->current_status_notice();

src/BigCommerce/Settings/Sections/Import.php

+15
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
use BigCommerce\Settings\Screens\Settings_Screen;
99

1010
class Import extends Settings_Section {
11+
use Webhooks;
12+
1113
const NAME = 'import';
1214
const OPTION_FREQUENCY = 'bigcommerce_import_frequency';
1315
const OPTION_NEW_PRODUCTS = 'bigcommerce_import_new_products';
1416
const BATCH_SIZE = 'bigcommerce_import_batch_size';
17+
const ENABLE_WEBHOOKS = 'bigcommerce_import_enable_webhooks';
1518
const MAX_CONCURRENT = 'bigcommerce_import_max_concurrent';
1619

1720
const FREQUENCY_FIVE = 'five_minutes';
@@ -91,6 +94,18 @@ public function register_settings_section() {
9194
self::BATCH_SIZE
9295
);
9396

97+
add_settings_field(
98+
self::ENABLE_WEBHOOKS,
99+
__( 'Enable Webhooks', 'bigcommerce' ),
100+
[ $this, 'enable_webhooks_toggle' ],
101+
Settings_Screen::NAME,
102+
self::NAME
103+
);
104+
105+
register_setting(
106+
Settings_Screen::NAME,
107+
self::ENABLE_WEBHOOKS
108+
);
94109

95110
/* // disabled until we figure out how to implement concurrent processing
96111
add_settings_field(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace BigCommerce\Settings\Sections;
4+
5+
6+
use BigCommerce\Settings\Screens\Connect_Channel_Screen;
7+
8+
class Onboarding_Import_Settings extends Settings_Section {
9+
use Webhooks;
10+
11+
const NAME = 'import_settings';
12+
13+
public function register_settings_section() {
14+
add_settings_section(
15+
self::NAME,
16+
__( 'Import Settings', 'bigcommerce' ),
17+
'__return_false',
18+
Connect_Channel_Screen::NAME
19+
);
20+
21+
add_settings_field(
22+
Import::ENABLE_WEBHOOKS,
23+
__( 'Enable Webhooks', 'bigcommerce' ),
24+
[ $this, 'enable_webhooks_toggle' ],
25+
Connect_Channel_Screen::NAME,
26+
self::NAME
27+
);
28+
29+
register_setting(
30+
Connect_Channel_Screen::NAME,
31+
Import::ENABLE_WEBHOOKS
32+
);
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace BigCommerce\Settings\Sections;
4+
5+
6+
trait Webhooks {
7+
8+
public function enable_webhooks_toggle() {
9+
$current = get_option( Import::ENABLE_WEBHOOKS, 0 );
10+
11+
printf( '<p class="description">%s</p>', __( 'Would you like to enable webhooks? Please be advised that some hosts do not handle this increased level of traffic well.', 'bigcommerce' ) );
12+
13+
echo '<fieldset>';
14+
printf(
15+
'<p><label><input type="radio" name="%s" value="1" %s /> %s</label></p>',
16+
esc_attr( Import::ENABLE_WEBHOOKS ),
17+
checked( 1, (int) $current, false ),
18+
__( 'Yes, I frequently update my catalog or require real-time product and inventory sync.', 'bigcommerce' )
19+
);
20+
printf(
21+
'<p><label><input type="radio" name="%s" value="0" %s /> %s</label></p>',
22+
esc_attr( Import::ENABLE_WEBHOOKS ),
23+
checked( 0, (int) $current, false ),
24+
__( "No, please disable Webhooks.", 'bigcommerce' )
25+
);
26+
echo '</fieldset>';
27+
}
28+
29+
}

src/BigCommerce/Taxonomies/Channel/Channel_Connector.php

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function create_first_channel() {
6464
do_action( 'bigcommerce/channel/promote', $term );
6565
}
6666
update_option( Import::OPTION_NEW_PRODUCTS, 1 );
67+
update_option( Import::ENABLE_WEBHOOKS, false );
6768
}
6869

6970
/**

0 commit comments

Comments
 (0)