Skip to content

Commit

Permalink
packaged version 4.31.0 (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
MlKilderkin committed Jul 14, 2022
1 parent a513fdc commit 2aed8fa
Show file tree
Hide file tree
Showing 30 changed files with 667 additions and 355 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [4.31.0]

### Added
- 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
- 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
- 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.

### Changed
- 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

### Fixed
- Fixed issue when cart items change did not update cart totals/subtotals/taxes
- Customers creation on Bigcommerce Admin with empty details issue resolved.

## [4.30.0]

### Added
Expand Down Expand Up @@ -1795,6 +1809,7 @@
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.


[4.31.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.30.0...4.31.0
[4.30.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.29.0...4.30.0
[4.29.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.28.0...4.29.0
[4.28.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.27.1...4.28.0
Expand Down
2 changes: 1 addition & 1 deletion assets/js/dist/admin/gutenberg/scripts.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/dist/admin/gutenberg/scripts.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/dist/admin/scripts.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/dist/admin/scripts.min.js

Large diffs are not rendered by default.

348 changes: 174 additions & 174 deletions assets/js/dist/scripts.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions assets/js/dist/scripts.min.js

Large diffs are not rendered by default.

276 changes: 138 additions & 138 deletions assets/js/dist/vendor.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/js/dist/vendor.min.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions assets/js/src/public/cart/ajax-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ const updatedCartTotals = (data = {}) => {
const taxTotal = tools.getNodes('.bc-cart-tax__amount', false, cart, true)[0];
const cartTotal = tools.getNodes('.bc-cart-total__amount', false, cart, true)[0];

// update item totals
if (cartData.items !== undefined) {
// eslint-disable-next-line no-restricted-syntax
for (const [key, item] of Object.entries(cartData.items)) {
const itemNode = tools.getNodes(`.bc-cart-item[data-js="${key}"]`, false, cart, true)[0];
const itemTotal = tools.getNodes('.bc-cart-item-total-price', false, itemNode, true)[0];

if (itemTotal) {
itemTotal.innerHTML = item.total_sale_price.formatted !== undefined ? item.total_sale_price.formatted : item.total_price.formatted;
}
}
}

subTotal.textContent = baseAmount;

if (taxTotal) {
Expand Down Expand Up @@ -150,6 +163,7 @@ const cartItemQtyUpdated = (data = {}) => {
}

updateMenuQtyTotal(data);
updatedCartTotals(data);
handleFlatsomeTheme(data);
};

Expand Down
53 changes: 52 additions & 1 deletion assets/js/src/public/cart/shipping-calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Spinner } from 'spin.js/spin';
import { AJAX_CART_UPDATE, HANDLE_CART_STATE, HANDLE_COUPON_CODE } from 'bcConstants/events';
import { SHIPPING_API_ZONES, SHIPPING_API_METHODS } from 'publicConfig/wp-settings';
import { NLS } from 'publicConfig/i18n';
import { wpAPIGetShippingZones, wpAPIGetShippingMethods } from 'utils/ajax';
import { wpAPIGetShippingZones, wpAPIGetShippingMethods, wpAPIShippingEndicia } from 'utils/ajax';
import { on, trigger } from 'utils/events';

const el = {
Expand Down Expand Up @@ -175,6 +175,56 @@ const getZones = () => {
});
};

/**
* @function getMethods
* @description get the shipping methods associated with the selected shipping zone.
*/
const getEndicia = () => {
cartState.isFetching = true;
handleSpinnerState();
const country = tools.getNodes('.bc-calc-country', false, document, true)[0].value;
const city = tools.getNodes('.bc-calc-city', false, document, true)[0].value;
const province = tools.getNodes('.bc-calc-state', false, document, true)[0].value;
const zip = tools.getNodes('.bc-calc-zip', false, document, true)[0].value;
const query = {
country,
city,
state: province,
zip,
};

wpAPIShippingEndicia(SHIPPING_API_METHODS, query)
.end((err, res) => {
cartState.isFetching = false;
handleSpinnerState();

if (err) {
state.hasError = true;
handleShippingError();
console.error(err);
return;
}
const html = res.body.rendered;
const fieldsWrapper = tools.getNodes('.bc-shipping-calculator-fields', false, el.calculator, true)[0];
const methods = tools.getNodes('bc-shipping-methods', false, el.calculator)[0];

if (!fieldsWrapper) {
return;
}

// Remove any error messages on success.
state.hasError = false;
handleShippingError();

if (methods) {
methods.parentNode.removeChild(methods);
}

fieldsWrapper.insertAdjacentHTML('beforeend', html);
el.currentSubtotal.innerText = state.subtotal;
});
};

/**
* @function getMethods
* @description get the shipping methods associated with the selected shipping zone.
Expand Down Expand Up @@ -267,6 +317,7 @@ const bindEvents = () => {
delegate(el.calculator, '[data-js="shipping-calculator-toggle"]', 'click', getZones);
delegate(el.calculator, '[data-js="bc-shipping-zones"]', 'change', getMethods);
delegate(el.calculator, '[data-js="shipping-calculator-update"]', 'click', updateCartPrice);
delegate(el.calculator, '[data-js="bc-calc-run"]', 'click', getEndicia);
on(document, AJAX_CART_UPDATE, resetShippingCalculator);
on(document, HANDLE_COUPON_CODE, resetShippingCalculator);
};
Expand Down
5 changes: 5 additions & 0 deletions assets/js/src/utils/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export const wpAPIGetShippingZones = URL => request
export const wpAPIGetShippingMethods = (url, zoneID = '') => request
.get(`${url}/${zoneID}/methods/html`);

export const wpAPIShippingEndicia = (url, query) => request
.post(`${url}/methods/endicia`)
.set('Content-Type', 'application/json')
.query(query);

export const wpAPICouponCodes = (couponCodeURL = '', queryObj = {}, couponsNonce = '') => request
.post(couponCodeURL)
.set('Content-Type', 'application/json')
Expand Down
2 changes: 1 addition & 1 deletion bigcommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: BigCommerce for WordPress
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.
Author: BigCommerce
Version: 4.30.0
Version: 4.31.0
Author URI: https://www.bigcommerce.com/wordpress
Requires PHP: 7.4.0
Text Domain: bigcommerce
Expand Down
2 changes: 1 addition & 1 deletion build-timestamp.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '4.11.06.20.2022');
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.48.07.11.2022');
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: bigcommerce, moderntribe, jbrinley, becomevocal, vincentlistrani,
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
Requires at least: 5.2
Tested up to: 5.9.2
Stable tag: 4.30.0
Stable tag: 4.31.0
Requires PHP: 7.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
2 changes: 1 addition & 1 deletion src/BigCommerce/Container/Forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private function actions( Container $container ) {
return $container[ self::REVIEW ]->remove_form_messages_from_post_content( $show, $post_id );
} ), 10, 2 );
add_filter( 'bigcommerce/product/reviews/show_form', $this->create_callback( 'toggle_review_form', function ( $enabled, $post_id ) use ( $container ) {
return $container[ self::REVIEW ]->disable_reviews_if_comments_disabled( $enabled, $post_id );
return $container[ self::REVIEW ]->toggle_reviews_form_availability( $enabled, $post_id );
} ), 10, 2 );
}

Expand Down
5 changes: 5 additions & 0 deletions src/BigCommerce/Container/Post_Types.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace BigCommerce\Container;

use BigCommerce\Customizer\Sections\Product_Category as Customizer;
use BigCommerce\Customizer\Sections\Product_Single;
use BigCommerce\Post_Types\Product;
use BigCommerce\Post_Types\Queue_Task;
use BigCommerce\Post_Types\Sync_Log;
Expand Down Expand Up @@ -367,6 +368,10 @@ private function product_seo( Container $container ) {
return $container[ self::PRODUCT_SEO ]->filter_document_title( $title_parts );
} ), 10, 1 );
add_filter( 'wp_head', $this->create_callback( 'product_page_meta_description', function () use ( $container ) {
if ( get_option( Product_Single::META_DESC_DISABLE, 'yes' ) !== 'yes' ) {
return null;
}

return $container[ self::PRODUCT_SEO ]->print_meta_description();
} ), 0, 0 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/BigCommerce/Container/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function register( Container $container ) {
};

$container[ self::SHIPPING ] = function ( Container $container ) {
return new Shipping_Controller( $container[ self::NAMESPACE_BASE ], $container[ self::VERSION ], $container[ self::SHIPPING_BASE ], $container[ Api::FACTORY ]->shipping(), $container[ Api::FACTORY ]->cart() );
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() );
};

$container[ self::COUPON_CODE_BASE ] = function ( Container $container ) {
Expand Down
13 changes: 13 additions & 0 deletions src/BigCommerce/Customizer/Sections/Product_Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ private function columns( \WP_Customize_Manager $wp_customize ) {
'section' => self::NAME,
'label' => __( 'Grid Columns', 'bigcommerce' ),
'type' => 'select',
'description' => $this->get_field_description(),
'choices' => array_combine( $range, $range ),
] ) );
}
Expand All @@ -267,17 +268,29 @@ private function per_page( \WP_Customize_Manager $wp_customize ) {
},
'sanitize_callback' => 'absint',
] ) );

$wp_customize->add_control( new \WP_Customize_Control( $wp_customize, self::PER_PAGE, [
'section' => self::NAME,
'label' => __( 'Products per Page', 'bigcommerce' ),
'type' => 'number',
'description' => $this->get_field_description(),
'input_attrs' => [
'min' => min( $range ),
'max' => max( $range ),
],
] ) );
}

public function get_field_description() {
if ( ! ( function_exists( 'et_setup_theme' ) || function_exists( 'et_framework_setup' ) ) ) {
return '';
}

$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' );

return sprintf( '<cite class="bc-form__error-message">%s</cite>', $description );
}

private function quick_view( \WP_Customize_Manager $wp_customize ) {
$wp_customize->add_setting( new \WP_Customize_Setting( $wp_customize, self::QUICK_VIEW, [
'type' => 'option',
Expand Down
19 changes: 19 additions & 0 deletions src/BigCommerce/Customizer/Sections/Product_Single.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Product_Single {
const PRICE_DISPLAY = 'bigcommerce_default_price_display';
const INVENTORY_DISPLAY = 'bigcommerce_inventory_display';
const VARIANTS_DISABLED = 'bigcommerce_variants_disabled';
const META_DESC_DISABLE = 'bigcommerce_meta_description_disabled';
const GALLERY_SIZE = 'bigcommerce_gallery_image_size';
const ENABLE_ZOOM = 'bigcommerce_enable_zoom';
const SIZE_DEFAULT = 'default';
Expand All @@ -36,6 +37,7 @@ public function register( $wp_customize ) {
$this->pricing( $wp_customize );
$this->inventory( $wp_customize );
$this->variants( $wp_customize );
$this->meta_description( $wp_customize );
}

private function related( \WP_Customize_Manager $wp_customize ) {
Expand Down Expand Up @@ -161,4 +163,21 @@ private function variants( \WP_Customize_Manager $wp_customize ) {
],
] );
}

protected function meta_description( \WP_Customize_Manager $wp_customize ) {
$wp_customize->add_setting( new \WP_Customize_Setting( $wp_customize, self::META_DESC_DISABLE, [
'type' => 'option',
'default' => 'yes',
'transport' => 'refresh',
] ) );
$wp_customize->add_control( self::META_DESC_DISABLE, [
'section' => self::NAME,
'type' => 'radio',
'label' => __( 'Meta Description display', 'bigcommerce' ),
'choices' => [
'yes' => __( 'Show meta description set in BC admin on product page', 'bigcommerce' ),
'no' => __( 'Disable meta description from BC admin', 'bigcommerce' ),
],
] );
}
}
20 changes: 15 additions & 5 deletions src/BigCommerce/Forms/Product_Review_Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,29 @@ public function remove_form_messages_from_post_content( $show, $post_id ) {
}

/**
* If comments are disabled for a product, disable the review form
* Handle reviews form visibility
*
* @param bool $enabled
* @param int $post_id
*
* @return bool
* @filter bigcommerce/product/reviews/show_form
*/
public function disable_reviews_if_comments_disabled( $enabled, $post_id ) {
if ( ! $enabled ) {
return $enabled; // don't enable it
public function toggle_reviews_form_availability( bool $enabled, int $post_id ): bool {
$is_comments_allowed_globally = get_option( 'default_comment_status' ) === 'open';
$user_should_be_logged_in = ( int ) get_option( 'comment_registration' ) === 1;

// If comments are allowed and users can post them without registration
if ( $is_comments_allowed_globally && ! $user_should_be_logged_in ) {
return comments_open( $post_id );
}

// If commenting is enabled for registered users only
if ( $is_comments_allowed_globally && $user_should_be_logged_in ) {
return is_user_logged_in();
}

return comments_open( $post_id );
// Return default value
return $enabled;
}
}
11 changes: 7 additions & 4 deletions src/BigCommerce/Forms/Registration_Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,22 @@ public function handle_request( $submission ) {
};
add_filter( 'bigcommerce/customer/create/args', $profile_filter, 10, 1 );

$user = new \WP_User( $user_id );
/** Create customer profile */
// TODO: Add connection via V3 and channels
$this->login->connect_customer_id( $submission[ 'bc-register' ][ 'email' ], $user );

remove_filter( 'bigcommerce/customer/create/args', $profile_filter, 10 );

$user = new \WP_User( $user_id );


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

/** Create customer profile */
// TODO: Add connection via V3 and channels
$this->login->connect_customer_id( $submission[ 'bc-register' ][ 'email' ], $user );

$customer = new Customer( $user_id );
$customer->add_address( $address );

Expand Down
2 changes: 1 addition & 1 deletion src/BigCommerce/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace BigCommerce;

class Plugin {
const VERSION = '4.30.0';
const VERSION = '4.31.0';

protected static $_instance;

Expand Down
Loading

0 comments on commit 2aed8fa

Please sign in to comment.