Skip to content

Commit 8e11122

Browse files
authored
Merge pull request #413 from moderntribe/release/5.0.0
packaged version 5.0.0
2 parents b78dea3 + da6045d commit 8e11122

File tree

120 files changed

+3793
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+3793
-560
lines changed

CHANGELOG.md

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

3+
## [5.0.0]
4+
5+
### Added
6+
- Added support for Multi Storefront(MSF) functionality:
7+
- Pull products, product categories and brands that belongs to specified channel
8+
- Retrieve and save currencies during the import. They can be used in `Currency Switch` widget. You can add widget in Appearance -> Widgets. Just drop widget to registered widget area. After that each user can switch to required currency on the frontend
9+
- Apply channel settings(hide prices, hide reviews etc.) set in Bigcommerce Channel Manager to WordPress e-commerce pages.
10+
- Retrieve customer groups existed in Bigcommerce. If it is possible set default customer group for all new customer
11+
12+
### Changed
13+
- Creation of new channel for MSF stores won't create active channel in Bigcommerce anymore. Instead of that channel with pre-launch status will be created. Usual WordPres pages will be still accessible by regular users. However, any e-commerce pages(checkout, product single page and etc) won't be visible for anyone, except site administrator, and return 404 error. To make it visible please enable webhooks and go to Bigcommerce Channel Manager. Change channel status to active. After that e-commerce pages will become visible for everyone.
14+
315
## [4.37.0]
416

517
### Added
@@ -1860,6 +1872,7 @@
18601872
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.
18611873

18621874

1875+
[5.0.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.37.0...5.0.0
18631876
[4.37.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.36.0...4.37.0
18641877
[4.36.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.35.0...4.36.0
18651878
[4.35.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.34.0...4.35.0

assets/css/bc-gutenberg.css

+33-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/bc-gutenberg.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/master.css

+33-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/master.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/admin/gutenberg/scripts.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/admin/gutenberg/scripts.min.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/scripts.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/scripts.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/src/admin/gutenberg/blocks/product-components/instancedEdit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { GUTENBERG_PRODUCT_COMPONENTS as BLOCK } from '../../config/gutenberg-se
1010
import ProductId from './productId';
1111
import ProductComponentType from './productComponentType';
1212

13-
const { InspectorControls } = wp.editor;
13+
const { InspectorControls } = wp.blockEditor;
1414
const { PanelRow, PanelBody, BaseControl } = wp.components;
1515
const { Component, Fragment } = wp.element;
1616

assets/js/src/admin/gutenberg/blocks/product-reviews/edit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { GUTENBERG_PRODUCT_REVIEWS as BLOCK } from '../../config/gutenberg-settings';
88
import ShortcodeInput from './shortcodeInput';
99

10-
const { InspectorControls } = wp.editor;
10+
const { InspectorControls } = wp.blockEditor;
1111
const { PanelRow, PanelBody, BaseControl } = wp.components;
1212
const { withInstanceId } = wp.compose;
1313
const { Fragment } = wp.element;

assets/js/src/admin/gutenberg/blocks/products/inspector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { trigger } from '../../../../utils/events';
66
import shortcodeState from '../../../config/shortcode-state';
77

88
const { Component } = wp.element;
9-
const { InspectorControls } = wp.editor;
9+
const { InspectorControls } = wp.blockEditor;
1010
const { PanelRow, PanelBody, Button } = wp.components;
1111

1212
export default class Inspector extends Component {

assets/js/src/public/page/dynamicStateField.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ const parseCountryObject = (selectedCountry = '', stateControlContainer = '') =>
7373
const storeInitialFieldStates = () => {
7474
const countryControl = tools.getNodes('bc-dynamic-country-select')[0];
7575
const stateControl = tools.getNodes('bc-dynamic-state-control')[0];
76-
const stateFieldType = stateControl.tagName.toLowerCase();
76+
let stateFieldType = '';
77+
78+
if (!stateControl || !countryControl) {
79+
return;
80+
}
81+
82+
stateFieldType = stateControl.tagName.toLowerCase();
7783

7884
if (stateFieldType === 'select') {
7985
countryState.initialStateValue = stateControl.options[stateControl.selectedIndex].value;

assets/pcss/content/components/_all.pcss

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
@import "images";
2323
@import "wish-lists";
2424
@import "banner";
25+
@import "currency-widget";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.bc-currency-switcher {
2+
padding: 0;
3+
margin: 0;
4+
5+
.bc-form {
6+
display: flex;
7+
flex-direction: row;
8+
flex-wrap: wrap;
9+
align-items: flex-end;
10+
}
11+
12+
.bc-form__control {
13+
margin-bottom: 0;
14+
15+
select {
16+
padding-right: 20px;
17+
}
18+
}
19+
20+
.bc-form__actions {
21+
margin-top: 0;
22+
width: auto;
23+
margin-left: 16px;
24+
25+
.bc-btn {
26+
border: 1px solid transparent;
27+
}
28+
}
29+
}

assets/pcss/wp-themes/_twenty-twenty-theme.pcss

-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@
6363
}
6464
}
6565

66-
/* Case: All BC related buttons should inherit the bc styles from the customizer. */
67-
button:not(.toggle) {
68-
background-color: inherit;
69-
}
70-
7166
label.bc-product-form__quantity-label {
7267
font-size: inherit;
7368
}

bigcommerce.php

+49-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
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: 4.37.0
6+
Version: 5.0.0
77
Author URI: https://www.bigcommerce.com/wordpress
88
Requires PHP: 7.4.0
99
Text Domain: bigcommerce
1010
License: GPLv2 or later
1111
*/
1212

13+
use BigCommerce\Pages\Login_Page;
14+
use BigCommerce\Taxonomies\Channel\BC_Status;
15+
1316
define( 'BIGCOMMERCE_PHP_MINIMUM_VERSION', '7.0' );
1417
define( 'BIGCOMMERCE_PHP_OPTIMAL_VERSION', '7.4' );
1518
define( 'BIGCOMMERCE_WP_MINIMUM_VERSION', '4.8' );
@@ -43,14 +46,17 @@
4346
*/
4447
function bigcommerce_init() {
4548
// Don't load on frontend for non-active channel status
46-
if ( ! defined( 'WP_CLI' )
47-
&& ! is_admin()
48-
&& bigcommerce_get_primary_channel_status() !== null
49-
&& bigcommerce_get_primary_channel_status() !== \BigCommerce\Taxonomies\Channel\BC_Status::STATUS_ACTIVE
50-
) {
49+
$channel_status = bigcommerce_get_primary_channel_status();
50+
$is_front_page = ! defined( 'WP_CLI' ) && ! is_admin() && $channel_status !== null;
51+
// Don't load on frontend for non-active channel status
52+
if ( $is_front_page && ! in_array( $channel_status, [ BC_Status::STATUS_ACTIVE, BC_Status::STATUS_PRE_LAUNCH ] ) ) {
5153
return;
5254
}
5355

56+
if ( ! defined( 'DOING_CRON' ) && $is_front_page && $channel_status === BC_Status::STATUS_PRE_LAUNCH && ! current_user_can( 'publish_posts' ) ) {
57+
handle_404_redirect_in_prelaunch();
58+
return;
59+
}
5460
$container = new \Pimple\Container( [ 'plugin_file' => __FILE__ ] );
5561
$plugin = \BigCommerce\Plugin::instance( $container );
5662
$plugin->init();
@@ -66,6 +72,41 @@ function bigcommerce_init() {
6672
return $plugin;
6773
}
6874

75+
function handle_404_redirect_in_prelaunch() {
76+
// We have to do that here because we don't initialize the plugin in case of prelaunch status
77+
add_filter( 'pre_handle_404', function ( $preempt ) {
78+
if ( is_admin() || ! ( is_page() && is_main_query() ) ) {
79+
return $preempt;
80+
}
81+
82+
$plugin_pages = [
83+
\BigCommerce\Pages\Account_Page::SLUG,
84+
\BigCommerce\Pages\Address_Page::SLUG,
85+
\BigCommerce\Pages\Cart_Page::SLUG,
86+
\BigCommerce\Pages\Check_Balance_Page::SLUG,
87+
\BigCommerce\Pages\Checkout_Complete_Page::SLUG,
88+
\BigCommerce\Pages\Checkout_Page::SLUG,
89+
\BigCommerce\Pages\Login_Page::SLUG,
90+
\BigCommerce\Pages\Gift_Certificate_Page::SLUG,
91+
\BigCommerce\Pages\Orders_Page::SLUG,
92+
\BigCommerce\Pages\Registration_Page::SLUG,
93+
\BigCommerce\Pages\Shipping_Returns_Page::SLUG,
94+
\BigCommerce\Pages\Wishlist_Page::SLUG
95+
];
96+
97+
if ( ! in_array( get_queried_object()->post_name, $plugin_pages ) ) {
98+
return $preempt;
99+
}
100+
101+
global $wp_query;
102+
$wp_query->set_404();
103+
status_header( 404 );
104+
nocache_headers();
105+
106+
return '';
107+
}, 10, 1 );
108+
}
109+
69110
function bigcommerce() {
70111
try {
71112
return \BigCommerce\Plugin::instance();
@@ -100,7 +141,7 @@ function bigcommerce_get_env( $key ) {
100141
function bigcommerce_get_primary_channel_status() {
101142
$cache_key = 'bigcommerce_primary_channel_status';
102143
$status = wp_cache_get( $cache_key );
103-
if ( $status === false ) {
144+
if ( empty( $status ) ) {
104145
global $wpdb;
105146

106147
$sql = "SELECT tm.meta_value
@@ -110,7 +151,7 @@ function bigcommerce_get_primary_channel_status() {
110151

111152
$status = $wpdb->get_var( $wpdb->prepare(
112153
$sql,
113-
\BigCommerce\Taxonomies\Channel\BC_Status::STATUS,
154+
BC_Status::STATUS,
114155
\BigCommerce\Taxonomies\Channel\Channel::STATUS,
115156
\BigCommerce\Taxonomies\Channel\Channel::STATUS_PRIMARY
116157
) );

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', '3.11.02.06.2023');
2+
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '6.15.02.15.2023');

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: 5.2
55
Tested up to: 6.0.3
6-
Stable tag: 4.37.0
6+
Stable tag: 5.0.0
77
Requires PHP: 7.4.0
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html

src/BigCommerce/Accounts/Customer.php

+40-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
use Bigcommerce\Api\Resources\Address;
1010
use Bigcommerce\Api\Resources\Order;
1111
use Bigcommerce\Api\Resources\OrderProduct;
12+
use BigCommerce\Import\Processors\Default_Customer_Group;
13+
use BigCommerce\Logging\Error_Log;
1214
use BigCommerce\Settings\Sections\Troubleshooting_Diagnostics;
15+
use BigCommerce\Taxonomies\Channel\Channel;
16+
use BigCommerce\Taxonomies\Channel\Connections;
1317

1418
/**
1519
* Class Customer
@@ -335,10 +339,12 @@ public function set_customer_id( $customer_id ) {
335339
public function get_group_id() {
336340
$customer_id = is_user_logged_in() || defined( 'DOING_CRON' ) ? get_user_option( self::CUSTOMER_ID_META, $this->wp_user_id ) : 0;
337341
if ( ! $customer_id ) {
342+
$default_guest_group = $this->get_guests_default_group();
343+
$default_guest_group = ! empty( $default_guest_group ) ? reset( $default_guest_group ) : null;
338344
/**
339345
* This filter is documented in src/BigCommerce/Accounts/Customer.php
340346
*/
341-
return apply_filters( 'bigcommerce/customer/group_id', null, $this );
347+
return apply_filters( 'bigcommerce/customer/group_id', $default_guest_group ?: null, $this );
342348
}
343349
$transient_key = sprintf( 'bccustomergroup%d', $customer_id );
344350
$group_id = get_transient( $transient_key );
@@ -349,14 +355,17 @@ public function get_group_id() {
349355
$group_id = isset( $profile['customer_group_id'] ) ? absint( $profile['customer_group_id'] ) : 0;
350356
$expiration = get_option( Troubleshooting_Diagnostics::USERS_TRANSIENT, 12 * HOUR_IN_SECONDS ); // TODO: a future webhook to flush this cache when the customer's group changes
351357
if ( $group_id === 0 ) {
352-
set_transient( $transient_key, 'zero', $expiration ); // workaround for storing empty values in cache
358+
$default_group = get_option( Default_Customer_Group::DEFAULT_GROUP, 0 );
359+
$value = $default_group ?: 'zero';
360+
361+
set_transient( $transient_key, $value, $expiration ); // workaround for storing empty values in cache
353362
} else {
354363
set_transient( $transient_key, $group_id, $expiration );
355364
}
356365
}
357366

358367
if ( $group_id === 'zero' ) {
359-
$group_id = 0;
368+
$group_id = get_option( Default_Customer_Group::DEFAULT_GROUP, 0 );
360369
}
361370

362371
/**
@@ -370,6 +379,34 @@ public function get_group_id() {
370379
return absint( $group_id );
371380
}
372381

382+
/**
383+
* @return array|null
384+
*/
385+
public function get_guests_default_group() {
386+
$args = [
387+
'is_group_for_guests' => true,
388+
];
389+
$query = '?' . http_build_query( $args );
390+
391+
$customer_groups = Client::getCustomerGroups( $query );
392+
393+
if ( empty( $customer_groups ) ) {
394+
do_action( 'bigcommerce/log', Error_Log::INFO, __( 'Customer groups are empty', 'bigcommerce' ), [] );
395+
return null;
396+
}
397+
$connections = new Connections();
398+
$channel = $connections->current();
399+
$channel_id = get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true );
400+
return array_filter( array_map( function ( $group ) use ( $channel_id ) {
401+
// Exit if group is not default
402+
if ( ( int ) $group->channel_id !== ( int ) $channel_id ) {
403+
return;
404+
}
405+
406+
return $group->id;
407+
}, $customer_groups ) );
408+
}
409+
373410
/**
374411
* Get the customer group associated with this customer
375412
*

0 commit comments

Comments
 (0)