Skip to content

Commit 2aed8fa

Browse files
authored
packaged version 4.31.0 (#369)
1 parent a513fdc commit 2aed8fa

30 files changed

+667
-355
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## [4.31.0]
4+
5+
### Added
6+
- Added real-time shipping calculation with USPS. In order to enable it please go to Bigcommerce admin -> Settings -> Shipping and connect USPS service. Then on WordPress store make a full sync. The real-time shipping calculation will be added as a new option to 'Shipping Calculator' on the Cart page
7+
- Added ability to hide meta description set in Bigcommerce Admin. By default that option is on. In case you want to change it please go to WordPress Admin -> Customizer -> Bigcommerce -> Product Single and switch behavior in Meta Description section
8+
- Added a warning notice to Customizer -> Bigcommerce -> Product Catalog. It will be displayed on the 'Grid Columns' and 'Products per page' options when Divi theme is enabled.
9+
10+
### Changed
11+
- Allow writing reviews for non-customer users. In order to do that go to Wordpress Admin -> Settings -> Discussion and uncheck 'Users must be registered and logged in to comment' checkbox. If checkbox is checked only logged-in users(customers) can leave a review
12+
13+
### Fixed
14+
- Fixed issue when cart items change did not update cart totals/subtotals/taxes
15+
- Customers creation on Bigcommerce Admin with empty details issue resolved.
16+
317
## [4.30.0]
418

519
### Added
@@ -1795,6 +1809,7 @@
17951809
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.
17961810

17971811

1812+
[4.31.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.30.0...4.31.0
17981813
[4.30.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.29.0...4.30.0
17991814
[4.29.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.28.0...4.29.0
18001815
[4.28.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.27.1...4.28.0

assets/js/dist/admin/gutenberg/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/admin/gutenberg/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/dist/admin/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/admin/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/dist/scripts.js

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

assets/js/dist/scripts.min.js

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

assets/js/dist/vendor.js

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

assets/js/dist/vendor.min.js

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

assets/js/src/public/cart/ajax-items.js

+14
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ const updatedCartTotals = (data = {}) => {
116116
const taxTotal = tools.getNodes('.bc-cart-tax__amount', false, cart, true)[0];
117117
const cartTotal = tools.getNodes('.bc-cart-total__amount', false, cart, true)[0];
118118

119+
// update item totals
120+
if (cartData.items !== undefined) {
121+
// eslint-disable-next-line no-restricted-syntax
122+
for (const [key, item] of Object.entries(cartData.items)) {
123+
const itemNode = tools.getNodes(`.bc-cart-item[data-js="${key}"]`, false, cart, true)[0];
124+
const itemTotal = tools.getNodes('.bc-cart-item-total-price', false, itemNode, true)[0];
125+
126+
if (itemTotal) {
127+
itemTotal.innerHTML = item.total_sale_price.formatted !== undefined ? item.total_sale_price.formatted : item.total_price.formatted;
128+
}
129+
}
130+
}
131+
119132
subTotal.textContent = baseAmount;
120133

121134
if (taxTotal) {
@@ -150,6 +163,7 @@ const cartItemQtyUpdated = (data = {}) => {
150163
}
151164

152165
updateMenuQtyTotal(data);
166+
updatedCartTotals(data);
153167
handleFlatsomeTheme(data);
154168
};
155169

assets/js/src/public/cart/shipping-calculator.js

+52-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Spinner } from 'spin.js/spin';
1010
import { AJAX_CART_UPDATE, HANDLE_CART_STATE, HANDLE_COUPON_CODE } from 'bcConstants/events';
1111
import { SHIPPING_API_ZONES, SHIPPING_API_METHODS } from 'publicConfig/wp-settings';
1212
import { NLS } from 'publicConfig/i18n';
13-
import { wpAPIGetShippingZones, wpAPIGetShippingMethods } from 'utils/ajax';
13+
import { wpAPIGetShippingZones, wpAPIGetShippingMethods, wpAPIShippingEndicia } from 'utils/ajax';
1414
import { on, trigger } from 'utils/events';
1515

1616
const el = {
@@ -175,6 +175,56 @@ const getZones = () => {
175175
});
176176
};
177177

178+
/**
179+
* @function getMethods
180+
* @description get the shipping methods associated with the selected shipping zone.
181+
*/
182+
const getEndicia = () => {
183+
cartState.isFetching = true;
184+
handleSpinnerState();
185+
const country = tools.getNodes('.bc-calc-country', false, document, true)[0].value;
186+
const city = tools.getNodes('.bc-calc-city', false, document, true)[0].value;
187+
const province = tools.getNodes('.bc-calc-state', false, document, true)[0].value;
188+
const zip = tools.getNodes('.bc-calc-zip', false, document, true)[0].value;
189+
const query = {
190+
country,
191+
city,
192+
state: province,
193+
zip,
194+
};
195+
196+
wpAPIShippingEndicia(SHIPPING_API_METHODS, query)
197+
.end((err, res) => {
198+
cartState.isFetching = false;
199+
handleSpinnerState();
200+
201+
if (err) {
202+
state.hasError = true;
203+
handleShippingError();
204+
console.error(err);
205+
return;
206+
}
207+
const html = res.body.rendered;
208+
const fieldsWrapper = tools.getNodes('.bc-shipping-calculator-fields', false, el.calculator, true)[0];
209+
const methods = tools.getNodes('bc-shipping-methods', false, el.calculator)[0];
210+
211+
if (!fieldsWrapper) {
212+
return;
213+
}
214+
215+
// Remove any error messages on success.
216+
state.hasError = false;
217+
handleShippingError();
218+
219+
if (methods) {
220+
methods.parentNode.removeChild(methods);
221+
}
222+
223+
fieldsWrapper.insertAdjacentHTML('beforeend', html);
224+
el.currentSubtotal.innerText = state.subtotal;
225+
});
226+
};
227+
178228
/**
179229
* @function getMethods
180230
* @description get the shipping methods associated with the selected shipping zone.
@@ -267,6 +317,7 @@ const bindEvents = () => {
267317
delegate(el.calculator, '[data-js="shipping-calculator-toggle"]', 'click', getZones);
268318
delegate(el.calculator, '[data-js="bc-shipping-zones"]', 'change', getMethods);
269319
delegate(el.calculator, '[data-js="shipping-calculator-update"]', 'click', updateCartPrice);
320+
delegate(el.calculator, '[data-js="bc-calc-run"]', 'click', getEndicia);
270321
on(document, AJAX_CART_UPDATE, resetShippingCalculator);
271322
on(document, HANDLE_COUPON_CODE, resetShippingCalculator);
272323
};

assets/js/src/utils/ajax.js

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ export const wpAPIGetShippingZones = URL => request
6868
export const wpAPIGetShippingMethods = (url, zoneID = '') => request
6969
.get(`${url}/${zoneID}/methods/html`);
7070

71+
export const wpAPIShippingEndicia = (url, query) => request
72+
.post(`${url}/methods/endicia`)
73+
.set('Content-Type', 'application/json')
74+
.query(query);
75+
7176
export const wpAPICouponCodes = (couponCodeURL = '', queryObj = {}, couponsNonce = '') => request
7277
.post(couponCodeURL)
7378
.set('Content-Type', 'application/json')

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: 4.30.0
6+
Version: 4.31.0
77
Author URI: https://www.bigcommerce.com/wordpress
88
Requires PHP: 7.4.0
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', '4.11.06.20.2022');
2+
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.48.07.11.2022');

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: 5.9.2
6-
Stable tag: 4.30.0
6+
Stable tag: 4.31.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/Container/Forms.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private function actions( Container $container ) {
9494
return $container[ self::REVIEW ]->remove_form_messages_from_post_content( $show, $post_id );
9595
} ), 10, 2 );
9696
add_filter( 'bigcommerce/product/reviews/show_form', $this->create_callback( 'toggle_review_form', function ( $enabled, $post_id ) use ( $container ) {
97-
return $container[ self::REVIEW ]->disable_reviews_if_comments_disabled( $enabled, $post_id );
97+
return $container[ self::REVIEW ]->toggle_reviews_form_availability( $enabled, $post_id );
9898
} ), 10, 2 );
9999
}
100100

src/BigCommerce/Container/Post_Types.php

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace BigCommerce\Container;
55

66
use BigCommerce\Customizer\Sections\Product_Category as Customizer;
7+
use BigCommerce\Customizer\Sections\Product_Single;
78
use BigCommerce\Post_Types\Product;
89
use BigCommerce\Post_Types\Queue_Task;
910
use BigCommerce\Post_Types\Sync_Log;
@@ -367,6 +368,10 @@ private function product_seo( Container $container ) {
367368
return $container[ self::PRODUCT_SEO ]->filter_document_title( $title_parts );
368369
} ), 10, 1 );
369370
add_filter( 'wp_head', $this->create_callback( 'product_page_meta_description', function () use ( $container ) {
371+
if ( get_option( Product_Single::META_DESC_DISABLE, 'yes' ) !== 'yes' ) {
372+
return null;
373+
}
374+
370375
return $container[ self::PRODUCT_SEO ]->print_meta_description();
371376
} ), 0, 0 );
372377
}

src/BigCommerce/Container/Rest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function register( Container $container ) {
184184
};
185185

186186
$container[ self::SHIPPING ] = function ( Container $container ) {
187-
return new Shipping_Controller( $container[ self::NAMESPACE_BASE ], $container[ self::VERSION ], $container[ self::SHIPPING_BASE ], $container[ Api::FACTORY ]->shipping(), $container[ Api::FACTORY ]->cart() );
187+
return new Shipping_Controller( $container[ self::NAMESPACE_BASE ], $container[ self::VERSION ], $container[ self::SHIPPING_BASE ], $container[ Api::FACTORY ]->shipping(), $container[ Api::FACTORY ]->cart(), $container[ Api::FACTORY ]->checkout() );
188188
};
189189

190190
$container[ self::COUPON_CODE_BASE ] = function ( Container $container ) {

src/BigCommerce/Customizer/Sections/Product_Archive.php

+13
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ private function columns( \WP_Customize_Manager $wp_customize ) {
247247
'section' => self::NAME,
248248
'label' => __( 'Grid Columns', 'bigcommerce' ),
249249
'type' => 'select',
250+
'description' => $this->get_field_description(),
250251
'choices' => array_combine( $range, $range ),
251252
] ) );
252253
}
@@ -267,17 +268,29 @@ private function per_page( \WP_Customize_Manager $wp_customize ) {
267268
},
268269
'sanitize_callback' => 'absint',
269270
] ) );
271+
270272
$wp_customize->add_control( new \WP_Customize_Control( $wp_customize, self::PER_PAGE, [
271273
'section' => self::NAME,
272274
'label' => __( 'Products per Page', 'bigcommerce' ),
273275
'type' => 'number',
276+
'description' => $this->get_field_description(),
274277
'input_attrs' => [
275278
'min' => min( $range ),
276279
'max' => max( $range ),
277280
],
278281
] ) );
279282
}
280283

284+
public function get_field_description() {
285+
if ( ! ( function_exists( 'et_setup_theme' ) || function_exists( 'et_framework_setup' ) ) ) {
286+
return '';
287+
}
288+
289+
$description = __( 'Divi framework is enabled. The field value may be overwritten with Divi options. Check Divi builder/theme options in order to set proper values', 'bigcommerce' );
290+
291+
return sprintf( '<cite class="bc-form__error-message">%s</cite>', $description );
292+
}
293+
281294
private function quick_view( \WP_Customize_Manager $wp_customize ) {
282295
$wp_customize->add_setting( new \WP_Customize_Setting( $wp_customize, self::QUICK_VIEW, [
283296
'type' => 'option',

src/BigCommerce/Customizer/Sections/Product_Single.php

+19
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Product_Single {
1313
const PRICE_DISPLAY = 'bigcommerce_default_price_display';
1414
const INVENTORY_DISPLAY = 'bigcommerce_inventory_display';
1515
const VARIANTS_DISABLED = 'bigcommerce_variants_disabled';
16+
const META_DESC_DISABLE = 'bigcommerce_meta_description_disabled';
1617
const GALLERY_SIZE = 'bigcommerce_gallery_image_size';
1718
const ENABLE_ZOOM = 'bigcommerce_enable_zoom';
1819
const SIZE_DEFAULT = 'default';
@@ -36,6 +37,7 @@ public function register( $wp_customize ) {
3637
$this->pricing( $wp_customize );
3738
$this->inventory( $wp_customize );
3839
$this->variants( $wp_customize );
40+
$this->meta_description( $wp_customize );
3941
}
4042

4143
private function related( \WP_Customize_Manager $wp_customize ) {
@@ -161,4 +163,21 @@ private function variants( \WP_Customize_Manager $wp_customize ) {
161163
],
162164
] );
163165
}
166+
167+
protected function meta_description( \WP_Customize_Manager $wp_customize ) {
168+
$wp_customize->add_setting( new \WP_Customize_Setting( $wp_customize, self::META_DESC_DISABLE, [
169+
'type' => 'option',
170+
'default' => 'yes',
171+
'transport' => 'refresh',
172+
] ) );
173+
$wp_customize->add_control( self::META_DESC_DISABLE, [
174+
'section' => self::NAME,
175+
'type' => 'radio',
176+
'label' => __( 'Meta Description display', 'bigcommerce' ),
177+
'choices' => [
178+
'yes' => __( 'Show meta description set in BC admin on product page', 'bigcommerce' ),
179+
'no' => __( 'Disable meta description from BC admin', 'bigcommerce' ),
180+
],
181+
] );
182+
}
164183
}

src/BigCommerce/Forms/Product_Review_Handler.php

+15-5
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,29 @@ public function remove_form_messages_from_post_content( $show, $post_id ) {
170170
}
171171

172172
/**
173-
* If comments are disabled for a product, disable the review form
173+
* Handle reviews form visibility
174174
*
175175
* @param bool $enabled
176176
* @param int $post_id
177177
*
178178
* @return bool
179179
* @filter bigcommerce/product/reviews/show_form
180180
*/
181-
public function disable_reviews_if_comments_disabled( $enabled, $post_id ) {
182-
if ( ! $enabled ) {
183-
return $enabled; // don't enable it
181+
public function toggle_reviews_form_availability( bool $enabled, int $post_id ): bool {
182+
$is_comments_allowed_globally = get_option( 'default_comment_status' ) === 'open';
183+
$user_should_be_logged_in = ( int ) get_option( 'comment_registration' ) === 1;
184+
185+
// If comments are allowed and users can post them without registration
186+
if ( $is_comments_allowed_globally && ! $user_should_be_logged_in ) {
187+
return comments_open( $post_id );
188+
}
189+
190+
// If commenting is enabled for registered users only
191+
if ( $is_comments_allowed_globally && $user_should_be_logged_in ) {
192+
return is_user_logged_in();
184193
}
185194

186-
return comments_open( $post_id );
195+
// Return default value
196+
return $enabled;
187197
}
188198
}

src/BigCommerce/Forms/Registration_Handler.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,22 @@ public function handle_request( $submission ) {
105105
};
106106
add_filter( 'bigcommerce/customer/create/args', $profile_filter, 10, 1 );
107107

108+
$user = new \WP_User( $user_id );
109+
/** Create customer profile */
110+
// TODO: Add connection via V3 and channels
111+
$this->login->connect_customer_id( $submission[ 'bc-register' ][ 'email' ], $user );
112+
108113
remove_filter( 'bigcommerce/customer/create/args', $profile_filter, 10 );
109114

110-
$user = new \WP_User( $user_id );
115+
111116

112117
/** This filter is documented in src/BigCommerce/Accounts/Login.php */
113118
$role = apply_filters( 'bigcommerce/user/default_role', Customer_Role::NAME );
114119
$user->set_role( $role );
115120
// all future password validation will be against the API for this user
116121
update_user_meta( $user_id, User_Profile_Settings::SYNC_PASSWORD, true );
117122

118-
/** Create customer profile */
119-
// TODO: Add connection via V3 and channels
120-
$this->login->connect_customer_id( $submission[ 'bc-register' ][ 'email' ], $user );
123+
121124
$customer = new Customer( $user_id );
122125
$customer->add_address( $address );
123126

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 = '4.30.0';
7+
const VERSION = '4.31.0';
88

99
protected static $_instance;
1010

0 commit comments

Comments
 (0)