Skip to content

Commit 890317d

Browse files
authored
packaged version 4.13.0 (#284)
1 parent c23c033 commit 890317d

23 files changed

+247
-62
lines changed

CHANGELOG.md

+28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# Changelog
22

3+
4+
## [4.13.0]
5+
6+
### Added
7+
8+
- Added support for password reset for users that exist only on BC (not yet synced with WP)
9+
- Delete all channels from the WP database on plugin uninstall so a fresh channel list is pulled when reinstalling and connecting to a new store
10+
- Added support for changing the SKU element when selecting variants. This adds a wrapper
11+
around the SKU value where JS targets the wrapper and updates the text.
12+
13+
**NOTE:** Update your templates accordingly. *product-sku.php*
14+
15+
### Changed
16+
- Within Embedded Checkout, logging out using the EC sign out buttonnow triggers
17+
a callback to log the user out of wordpress as well via `wp_logout()`
18+
19+
- The SKU text now updates after changing options on a product.
20+
21+
**NOTE: product-sku.php template updated to v.1.1.0**
22+
23+
### Fixed
24+
25+
- Fixed background colors in 2021 theme
26+
- Fixed banner overlaps the mobile menu icon on 2021 theme
27+
- Fixed top/bottom banners set for WordPress Twenty-Seventeen theme not showing up on home page.
28+
29+
330
## [4.12.0]
431

532
### Added
@@ -1419,6 +1446,7 @@
14191446
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.
14201447

14211448

1449+
[4.13.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.12.0...4.13.0
14221450
[4.12.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.11.0...4.12.0
14231451
[4.11.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.10.0...4.11.0
14241452
[4.10.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.9.0...4.10.0

assets/css/master.css

+21-2
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/scripts.js

+37-31
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

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

assets/js/dist/vendor.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/public/checkout/embedded-checkout.js

+20
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as tools from 'utils/tools';
99
import scrollTo from 'utils/dom/scroll-to';
1010
import { trigger } from 'utils/events';
1111
import { CART_ID_COOKIE_NAME, CART_ITEM_COUNT_COOKIE } from 'bcConstants/cookies';
12+
import bigcommerceConfig from 'bigcommerce_config';
1213
import { cartEmpty } from '../cart/cart-templates';
1314

1415
const el = {
@@ -52,12 +53,28 @@ const scrollIframe = () => {
5253
_.delay(() => scrollTo(options), 1000);
5354
};
5455

56+
/**
57+
* @function handleOrderCompleteEvents
58+
* @description Clear the cart data and scroll the order into view on the page if the order is successfully completed.
59+
*/
5560
const handleOrderCompleteEvents = () => {
5661
trigger({ event: 'bigcommerce/order_complete', data: { cart_id: Cookie.get(CART_ID_COOKIE_NAME) }, native: false });
5762
clearCartData();
5863
scrollIframe();
5964
};
6065

66+
/**
67+
* @function handleLogoutEvents
68+
* @description Log the user out of wordpress if they have successfully logged out of BC via the Embedded Checkout SDK.
69+
*/
70+
const handleLogoutEvents = () => {
71+
if (!bigcommerceConfig.logout_url) {
72+
return;
73+
}
74+
75+
window.location = bigcommerceConfig.logout_url;
76+
};
77+
6178
/**
6279
* @function loadEmbeddedCheckout
6380
* @description Create an instance of the BC embedded checkout.
@@ -76,6 +93,9 @@ const loadEmbeddedCheckout = async () => {
7693
// Set the onComplete callback to use the clearCartData function.
7794
config.onComplete = handleOrderCompleteEvents;
7895

96+
// Set the onComplete callback to use the clearCartData function.
97+
config.onSignOut = handleLogoutEvents;
98+
7999
// Embed the checkout.
80100
checkoutCDN.embedCheckout(config);
81101
};

assets/js/src/public/product/variants.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ const setSelectedVariantPrice = (wrapper = '') => {
159159
priceElement.textContent = state.variantPrice;
160160
};
161161

162+
/**
163+
* @function setVariantSKU
164+
* @description Update the variant SKU after successful variant selection;
165+
* @param wrapper
166+
*/
167+
const setVariantSKU = (wrapper = '') => {
168+
if (!wrapper) {
169+
return;
170+
}
171+
172+
const skuWrapper = tools.getNodes('bc-product-sku', false, wrapper)[0];
173+
if (!skuWrapper) { // No SKU template wrapper. No SKU
174+
return;
175+
}
176+
177+
skuWrapper.textContent = state.sku.length > 0 ? state.sku : '';
178+
};
179+
162180
/**
163181
* @function showVariantImage
164182
* @description Shows the variant image if one is available from state.variantImage.url.
@@ -239,7 +257,12 @@ const showHideVariantImage = (e, wrapper = '') => {
239257
state.variantImage.template = variantContainer.innerHTML;
240258
const swiperWrapper = tools.getNodes('bc-gallery-container', false, currentWrapper)[0];
241259
const swiperInstance = swiperWrapper.swiper;
242-
const swiperNavInstance = tools.getNodes(`[data-id="${swiperWrapper.dataset.controls}"]`, false, document, true)[0].swiper;
260+
const swiperNavWrapper = tools.getNodes(`[data-id="${swiperWrapper.dataset.controls}"]`, false, document, true)[0];
261+
// Check that the proper thumbnail slider present in the DOM before calling the swiper object.
262+
if (!swiperNavWrapper) {
263+
return;
264+
}
265+
const swiperNavInstance = swiperNavWrapper.swiper;
243266

244267
// hide the image after each variant request.
245268
removeVariantImage(swiperInstance, swiperNavInstance);
@@ -456,6 +479,7 @@ const handleSelections = (e, node = '') => {
456479
setProductURLParameter();
457480
setVariantIDHiddenField(formWrapper);
458481
setSelectedVariantPrice(metaWrapper);
482+
setVariantSKU(metaWrapper);
459483
setInventory();
460484
showHideVariantImage(null, metaWrapper);
461485
setButtonState(submitButton);

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

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
.bc-wp-twenty-seventeen-theme {
22

3+
.bc-banners {
4+
position: relative;
5+
z-index: 1;
6+
}
7+
38
.entry-content {
49

510
ul,

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

+23-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
}
77

88
.bc-wp-twenty-twenty-one-theme {
9+
/* Case: Make room for banners */
10+
.bc-banners {
11+
12+
~ .site {
13+
position: relative;
14+
15+
.primary-navigation {
16+
--global--admin-bar--height: 0;
17+
}
18+
}
19+
}
20+
921
/* Case: Remove browser-defined border style. */
1022
.site .button,
1123
button,
@@ -17,6 +29,11 @@
1729
border: none;
1830
}
1931

32+
/* Case: Remove focus background color. */
33+
.site a:focus:not(.wp-block-button__link):not(.wp-block-file__button) {
34+
background: none;
35+
}
36+
2037
.bc-btn:not(:hover):not(:active):not(.has-background) {
2138
--global--color-background: var(--color-white);
2239
--global--color-primary: var(--color-primary);
@@ -27,6 +44,11 @@
2744
--global--color-primary: transparent;
2845
}
2946

47+
.bc-load-items__trigger-btn {
48+
--global--color-primary: transparent;
49+
--global--color-background: #5273f4;
50+
}
51+
3052
/* Case: Content widths need to be wider for bc content pages. */
3153
.entry-content > * {
3254
max-width: var(--container-960) !important;
@@ -279,7 +301,7 @@
279301
}
280302
}
281303

282-
/* CASE: dialog gets added outside <body > */
304+
/* CASE: dialog gets added outside <body> */
283305
+ .bc-wish-list-dialog__wrapper {
284306

285307
.site .button,

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.12.0
6+
Version: 4.13.0
77
Author URI: https://www.bigcommerce.com/wordpress
88
Requires PHP: 7.2.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', '3.49.05.21.2021');
2+
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '1.46.06.16.2021');

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.5
6-
Stable tag: 4.12.0
6+
Stable tag: 4.13.0
77
Requires PHP: 7.2.0
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html

src/BigCommerce/Accounts/Login.php

+46
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,52 @@ public function lostpassword_url( $login_url, $redirect ) {
174174
return $login_url;
175175
}
176176

177+
178+
/**
179+
* If a user exists only on BC, try to sync before reset pasword email is sent.
180+
*
181+
* @param WP_User|false $user_data WP_User object if found, false if the user does not exist.
182+
* @param WP_Error $errors A WP_Error object containing any errors generated
183+
* by using invalid credentials.
184+
*
185+
* @return \WP_User|false
186+
* @action lostpassword_user_data
187+
*/
188+
public function before_reset_password_email( $user_data, $errors ) {
189+
if ( $errors->get_error_code() === 'invalid_email' ) {
190+
$user_login = filter_input( INPUT_POST, 'user_login', FILTER_SANITIZE_STRING );
191+
$customer_id = $this->find_customer_id_by_email( $user_login );
192+
193+
if ( ! $customer_id ) {
194+
return false;
195+
}
196+
197+
$user_id = wp_create_user( $user_login, wp_generate_password(), $user_login );
198+
if ( is_wp_error( $user_id ) ) {
199+
return false;
200+
}
201+
$user = new \WP_User( $user_id );
202+
203+
/**
204+
* Filter the default role given to new users
205+
*
206+
* @param string $role
207+
*/
208+
$role = apply_filters( 'bigcommerce/user/default_role', Customer_Role::NAME );
209+
$user->set_role( $role );
210+
211+
// all future password validation will be against the API for this user
212+
update_user_meta( $user_id, User_Profile_Settings::SYNC_PASSWORD, true );
213+
214+
$customer = new Customer( $user_id );
215+
$customer->set_customer_id( $customer_id );
216+
217+
return $user;
218+
}
219+
220+
return $user_data;
221+
}
222+
177223
/**
178224
* @param \WP_Error $error
179225
*

src/BigCommerce/Assets/Theme/JS_Config.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function get_data() {
4040
],
4141
'channel' => $this->get_current_channel_data(),
4242
'currency_code' => get_option( Currency::CURRENCY_CODE, 'USD' ),
43+
'logout_url' => esc_url( wp_logout_url( '/' ) ),
4344
];
4445
$this->data = apply_filters( 'bigcommerce/js_config', $this->data );
4546
}
@@ -57,7 +58,7 @@ private function get_current_channel_data() {
5758
];
5859
}
5960
} catch (\Exception $e) {
60-
61+
6162
}
6263

6364
return false;

src/BigCommerce/Container/Accounts.php

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ private function login( Container $container ) {
7272
return $container[ self::LOGIN ]->lostpassword_url( $url, $redirect );
7373
} ), 10, 2 );
7474

75+
add_filter( 'lostpassword_user_data', $this->create_callback( 'lostpassword_user_data', function ( $user_data, $errors ) use ( $container ) {
76+
return $container[ self::LOGIN ]->before_reset_password_email( $user_data, $errors );
77+
} ), 10, 2 );
78+
7579
add_action( 'lostpassword_post', $this->create_callback( 'lostpassword_post', function ( $error ) use ( $container ) {
7680
return $container[ self::LOGIN ]->lostpassword_error_handler( $error );
7781
} ), 10, 1 );
@@ -92,6 +96,7 @@ private function login( Container $container ) {
9296

9397
return $user;
9498
} ), 40, 3 );
99+
95100
add_filter( 'check_password', $this->create_callback( 'check_password', function ( $match, $password, $hash, $user_id ) use ( $container ) {
96101
if ( $container[ Api::CONFIG_COMPLETE ] ) {
97102
return $container[ self::LOGIN ]->check_password_for_linked_accounts( $match, $password, $hash, $user_id );

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.12.0';
7+
const VERSION = '4.13.0';
88

99
protected static $_instance;
1010

templates/public/components/products/product-sku.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @var string $sku
88
* @var Product $product
9-
* @version 1.0.0
9+
* @version 1.1.0
1010
*/
1111

1212
use BigCommerce\Post_Types\Product\Product;
@@ -20,4 +20,7 @@
2020
<?php esc_html_e( 'SKU:', 'bigcommerce' ); ?>
2121
</span>
2222

23-
<?php echo esc_html( $sku ); ?>
23+
<!-- data-js="bc-product-sku" is required -->
24+
<span class="bc-product-single__meta-sku" data-js="bc-product-sku">
25+
<?php echo esc_html( $sku ); ?>
26+
</span>

uninstall.php

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use BigCommerce\Taxonomies\Flag\Flag;
2626
use BigCommerce\Taxonomies\Product_Category\Product_Category;
2727
use BigCommerce\Taxonomies\Product_Type\Product_Type;
28+
use BigCommerce\Taxonomies\Channel\Channel;
2829
use BigCommerce\Webhooks\Product_Update_Webhook;
2930
use BigCommerce\Webhooks\Webhook;
3031
use BigCommerce\Webhooks\Webhook_Versioning;
@@ -107,11 +108,15 @@ function get_taxonomy_list() {
107108
Flag::NAME,
108109
Product_Category::NAME,
109110
Product_Type::NAME,
111+
Channel::NAME,
110112
];
111113
}
112114

113115
function delete_terms() {
114116
foreach ( get_taxonomy_list() as $tax ) {
117+
// In order to get the terms, taxonomy must first be registered
118+
register_taxonomy( $tax, Product::NAME );
119+
115120
$terms = \get_terms( [
116121
'taxonomy' => $tax,
117122
'hide_empty' => false,

vendor/autoload.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
require_once __DIR__ . '/composer/autoload_real.php';
66

7-
return ComposerAutoloaderInit2a06cc13023ee7d7b1065937fab5a739::getLoader();
7+
return ComposerAutoloaderInit68705a7491b6295557bc227cc54192cb::getLoader();

0 commit comments

Comments
 (0)