Skip to content

Commit

Permalink
packaged version 4.34.0 (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
MlKilderkin committed Sep 15, 2022
1 parent fcce645 commit 0b594d6
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [4.34.0]

### Added
- Added a new option **Pricing nonce field** to Appearance → Customizer → Bigcommerce → Single → Product. The option allows nonce disabling in pricing requests on a single product page. If you use strong cache options that don't provide the ability to refresh page nonce, the disabling nonce option allows performing correct pricing requests.
- Added new filter `bigcommerce/product/variant_price`. Hook returns the calculated price for the variant and allows price changing per variant. The example usage is adding taxes or some custom calculations to variant price

## [4.33.0]

### Changed
Expand Down Expand Up @@ -1825,6 +1831,7 @@
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.


[4.34.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.33.0...4.34.0
[4.33.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.32.0...4.33.0
[4.32.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.31.0...4.32.0
[4.31.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.30.0...4.31.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.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions assets/js/src/utils/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ export const wpAdminAjax = (queryObj = {}) => request
deadline: 60000, // but allow 1 minute for the file to finish loading.
});

export const wpAPIProductPricing = (pricingURL = '', pricingNonce = '', productsObj = {}) => request
.post(pricingURL)
.set('Content-Type', 'application/json')
.set('X-WP-Nonce', pricingNonce)
.send(productsObj)
.timeout({
response: 15000, // Wait 15 seconds for the server to start sending,
deadline: 60000, // but allow 1 minute for the file to finish loading.
});
export const wpAPIProductPricing = (pricingURL = '', pricingNonce = '', productsObj = {}) => {
const priceRequest = request
.post(pricingURL)
.set('Content-Type', 'application/json');
if (pricingNonce) {
priceRequest.set('X-WP-Nonce', pricingNonce);
}
return priceRequest.send(productsObj)
.timeout({
response: 15000, // Wait 15 seconds for the server to start sending,
deadline: 60000, // but allow 1 minute for the file to finish loading.
});
};

export const wpAPIGetShippingZones = URL => request
.get(URL);
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.33.0
Version: 4.34.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', '2.11.08.22.2022');
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.00.09.12.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.33.0
Stable tag: 4.34.0
Requires PHP: 7.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
50 changes: 40 additions & 10 deletions src/BigCommerce/Customizer/Sections/Product_Single.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
namespace BigCommerce\Customizer\Sections;

use BigCommerce\Customizer\Panels;
use BigCommerce\Settings\Sections\Import;

class Product_Single {
const NAME = 'bigcommerce_product_single';

const RELATED_COUNT = 'bigcommerce_max_related_products';
const DEFAULT_IMAGE = 'bigcommerce_default_image_id';
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';
const SIZE_LARGE = 'large';
const RELATED_COUNT = 'bigcommerce_max_related_products';
const DEFAULT_IMAGE = 'bigcommerce_default_image_id';
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 ENABLE_PRICE_NONCE = 'bigcommerce_enable_zoom';
const SIZE_DEFAULT = 'default';
const SIZE_LARGE = 'large';

/**
* @param \WP_Customize_Manager $wp_customize
Expand All @@ -35,6 +37,7 @@ public function register( $wp_customize ) {
$this->gallery_size( $wp_customize );
$this->zoom( $wp_customize );
$this->pricing( $wp_customize );
$this->pricing_nonce( $wp_customize );
$this->inventory( $wp_customize );
$this->variants( $wp_customize );
$this->meta_description( $wp_customize );
Expand Down Expand Up @@ -180,4 +183,31 @@ protected function meta_description( \WP_Customize_Manager $wp_customize ) {
],
] );
}

/**
* Register pricing nonce option setting
*
* @param \WP_Customize_Manager $wp_customize
*/
protected function pricing_nonce( \WP_Customize_Manager $wp_customize ): void {
if ( ( int ) get_option( Import::HEADLESS_FLAG, 0 ) !== 1 ) {
return;
}

$wp_customize->add_setting( new \WP_Customize_Setting( $wp_customize, self::ENABLE_PRICE_NONCE, [
'type' => 'option',
'default' => 'yes',
'transport' => 'refresh',
] ) );
$wp_customize->add_control( self::ENABLE_PRICE_NONCE, [
'section' => self::NAME,
'type' => 'radio',
'label' => __( 'Pricing nonce field(for advanced use only)', 'bigcommerce' ),
'choices' => [
'yes' => __( 'Enable pricing nonce', 'bigcommerce' ),
'no' => __( 'Disable pricing nonce', 'bigcommerce' ),
],
'description' => __( 'Control pricing request option by adding or removing pricing nonce. The feature can be used on heavy cached environments to prevent issues with expired nonce when "Fast - Headless" import is on', 'bigcommerce' ),
] );
}
}
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.33.0';
const VERSION = '4.34.0';

protected static $_instance;

Expand Down
16 changes: 15 additions & 1 deletion src/BigCommerce/Rest/Pricing_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
use BigCommerce\Api\v3\Model\PricingRequest;
use BigCommerce\Api\v3\ObjectSerializer;
use BigCommerce\Currency\With_Currency;
use BigCommerce\Customizer\Sections\Product_Single;
use BigCommerce\Exceptions\Channel_Not_Found_Exception;
use BigCommerce\Settings\Sections\Currency;
use BigCommerce\Settings\Sections\Import;
use BigCommerce\Taxonomies\Channel\Channel;
use BigCommerce\Taxonomies\Channel\Connections;

Expand All @@ -36,12 +38,24 @@ public function __construct( $namespace_base, $version, $rest_base, PricingApi $
public function js_config( $config ) {
$config['pricing'] = [
'api_url' => $this->get_base_url(),
'ajax_pricing_nonce' => wp_create_nonce( 'wp_rest' ),
'ajax_pricing_nonce' => $this->is_nonce_enabled() ? wp_create_nonce( 'wp_rest' ) : false,
];

return $config;
}

/**
* Nonce should always be on non-headless setup or if it is enabled via Customizer
*
* @return bool
*/
public function is_nonce_enabled(): bool {
$is_headless = ( int ) get_option( Import::HEADLESS_FLAG, 0 ) === 1;
$is_nonce_on = get_option( Product_Single::ENABLE_PRICE_NONCE, 'yes' ) === 'yes';

return ! $is_headless || $is_nonce_on;
}

public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base, [
[
Expand Down
6 changes: 4 additions & 2 deletions src/BigCommerce/Templates/Product_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ private function get_variants( Product $product ) {
$purchasing_disabled = (bool) $variant->purchasing_disabled;
}

$price = apply_filters( 'bigcommerce/product/variant_price', $variant->calculated_price, $variant, $product );

$data = [
'variant_id' => $variant->id,
'options' => $variant->option_values,
Expand All @@ -201,8 +203,8 @@ private function get_variants( Product $product ) {
'disabled' => $purchasing_disabled,
'disabled_message' => $variant->purchasing_disabled ? $variant->purchasing_disabled_message : '',
'sku' => $variant->sku,
'price' => $variant->calculated_price,
'formatted_price' => $this->format_currency( $variant->calculated_price ),
'price' => $price,
'formatted_price' => $this->format_currency( $price ),
'image' => $product->is_headless() ? $this->headless_variant_image_data( $variant ) : $this->variant_image_data( $variant->id, $product->post_id(), $image_size ),
'zoom' => [ 'url' => '', 'width' => 0, 'height' => 0 ],
];
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

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

return ComposerAutoloaderInit2576231c7dc0e987480cb9dcebf7e406::getLoader();
return ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit2576231c7dc0e987480cb9dcebf7e406
class ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4
{
private static $loader;

Expand All @@ -19,15 +19,15 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit2576231c7dc0e987480cb9dcebf7e406', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit2576231c7dc0e987480cb9dcebf7e406', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand All @@ -39,19 +39,19 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire2576231c7dc0e987480cb9dcebf7e406($fileIdentifier, $file);
composerRequire7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequire2576231c7dc0e987480cb9dcebf7e406($fileIdentifier, $file)
function composerRequire7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406
class ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4
{
public static $files = array (
'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
Expand Down Expand Up @@ -1163,10 +1163,10 @@ class ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406::$prefixesPsr0;
$loader->classMap = ComposerStaticInit2576231c7dc0e987480cb9dcebf7e406::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixesPsr0;
$loader->classMap = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit 0b594d6

Please sign in to comment.