Skip to content

Commit 6a234c4

Browse files
authored
packaged version 4.7.0 (#251)
1 parent 643354b commit 6a234c4

File tree

13 files changed

+114
-20
lines changed

13 files changed

+114
-20
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [4.7.0]
4+
5+
### Added
6+
- Added a proxy server endpoint to add multiple products to the cart in a single request
7+
- Added support for Gift Certificate themes drop-down
8+
9+
### Fixed
10+
- Fixed an erorr when printing a failed import time message in the Settings panel
11+
312

413
## [4.6.0]
514

@@ -1346,6 +1355,7 @@
13461355
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.
13471356

13481357

1358+
[4.7.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.6.0...4.7.0
13491359
[4.6.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.5.0...4.6.0
13501360
[4.5.1]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.5.0...4.5.1
13511361
[4.5.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.4.0...4.5.0

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.6.0
6+
Version: 4.7.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', '6.34.12.18.2020');
2+
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '5.04.01.15.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.6.0
6+
Stable tag: 4.7.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/Forms/Purchase_Gift_Certificate_Handler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private function get_certificate_data( $submission ) {
170170
__( '%s Gift Certificate', 'bigcommerce' ),
171171
apply_filters( 'bigcommerce/currency/format', sprintf( '¤%0.2f', $amount ), $amount )
172172
);
173-
$theme = apply_filters( 'bigcommerce/gift_certificates/theme', 'General.html' );
173+
$theme = apply_filters( 'bigcommerce/gift_certificates/theme', $submission[ 'theme' ] );
174174
$data = [
175175
'name' => $name,
176176
'theme' => $theme,

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

99
protected static $_instance;
1010

src/BigCommerce/Proxy/Proxy_Controller.php

+40
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ public function register_routes() {
9292
],
9393
]
9494
);
95+
register_rest_route(
96+
$this->proxy_base,
97+
'/carts/(.*)/items',
98+
[
99+
[
100+
'methods' => [ WP_REST_SERVER::CREATABLE ],
101+
'callback' => [ $this, 'add_cart_items' ],
102+
'permission_callback' => '__return_true',
103+
],
104+
]
105+
);
95106
register_rest_route(
96107
$this->proxy_base,
97108
'/carts/(.*)/redirect_urls(\/?$)',
@@ -220,6 +231,35 @@ public function update_cart_item( $request ) {
220231

221232
return rest_ensure_response( json_decode( wp_remote_retrieve_body( $response ), true ) );
222233
}
234+
235+
/**
236+
* Add cart line items.
237+
*
238+
* @param WP_REST_Request $request Request instance.
239+
* @return WP_REST_Response
240+
*/
241+
public function add_cart_items( $request ) {
242+
$route = $this->route( $request );
243+
244+
$params = $request->get_body_params();
245+
if ( empty( $params ) ) {
246+
$params = json_decode( $request->get_body(), true );
247+
}
248+
$params = wp_parse_args( $params, [ 'line_items' => [], 'gift_certificates' => [] ] );
249+
250+
$args = [
251+
'method' => $request->get_method(),
252+
'headers' => $this->get_request_headers( $request, $route ),
253+
'body' => wp_json_encode( [
254+
'line_items' => $params['line_items'],
255+
'gift_certificates' => $params['gift_certificates'],
256+
] ),
257+
];
258+
259+
$response = wp_remote_request( $route, $args );
260+
261+
return rest_ensure_response( json_decode( wp_remote_retrieve_body( $response ), true ) );
262+
}
223263

224264
/**
225265
* Provides request headers for use in multiple methods.

src/BigCommerce/Settings/Import_Status.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function previous_status() {
181181
$status_string = sprintf( __( 'Last import completed on <strong>%s at %s (%s)</strong>.', 'bigcommerce' ), $date, $time, $this->get_timezone_string() );
182182
break;
183183
case Status::FAILED:
184-
$status_string = sprintf( __( 'Last import failed on <strong>%s at %s (%s)</strong>.', 'bigcommerce' ), $date, $time, $$this->get_timezone_string() );
184+
$status_string = sprintf( __( 'Last import failed on <strong>%s at %s (%s)</strong>.', 'bigcommerce' ), $date, $time, $this->get_timezone_string() );
185185
break;
186186
case Status::NOT_STARTED:
187187
$status_string = '';

src/BigCommerce/Templates/Gift_Certificate_Form.php

+33
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Gift_Certificate_Form extends Form_Controller {
1111
const DEFAULTS = 'defaults';
1212
const BUTTON_LABEL = 'button_label';
1313
const ERRORS = 'errors';
14+
const THEMES = 'themes';
1415

1516
protected $template = 'components/gift-certificates/purchase-form.php';
1617

@@ -26,18 +27,21 @@ public function get_data() {
2627
$data = parent::get_data();
2728

2829
$data[ self::BUTTON_LABEL ] = $this->get_button_label();
30+
$data[ self::THEMES ] = $this->get_themes();
2931

3032
return $data;
3133
}
3234

3335
protected function get_form_defaults() {
36+
$themes = $this->get_themes();
3437
return [
3538
'sender-name' => '',
3639
'sender-email' => '',
3740
'recipient-name' => '',
3841
'recipient-email' => '',
3942
'amount' => '',
4043
'message' => '',
44+
'theme' => array_key_exists( 'general', $themes ) ? $themes['general']['template'] : '',
4145
];
4246
}
4347

@@ -48,4 +52,33 @@ protected function get_button_label() {
4852
return get_option( Buttons::BUY_NOW, __( 'Buy Now', 'bigcommerce' ) );
4953
}
5054
}
55+
56+
protected function get_themes() {
57+
return apply_filters( 'bigcommerce/gift_certificates/themes', [
58+
'boy' => [
59+
'name' => __( 'Boy', 'bigcommerce' ),
60+
'template' => 'Boy.html',
61+
],
62+
'celebration' => [
63+
'name' => __( 'Celebration', 'bigcommerce' ),
64+
'template' => 'Celebration.html',
65+
],
66+
'christmas' => [
67+
'name' => __( 'Christmas', 'bigcommerce' ),
68+
'template' => 'Christmas.html',
69+
],
70+
'general' => [
71+
'name' => __( 'General', 'bigcommerce' ),
72+
'template' => 'General.html',
73+
],
74+
'girl' => [
75+
'name' => __( 'Girl', 'bigcommerce' ),
76+
'template' => 'Girl.html',
77+
],
78+
'birthday' => [
79+
'name' => __( 'Birthday', 'bigcommerce' ),
80+
'template' => 'Birthday.html',
81+
],
82+
] );
83+
}
5184
}

templates/public/components/gift-certificates/purchase-form.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@
5050
<textarea name="bc-gift-purchase[message]" id="bc-gift-purchase-message" data-form-field="bc-form-field-message"><?php echo esc_textarea( $defaults[ 'message' ] ); ?></textarea>
5151
</label>
5252

53-
<?php // TODO: theme selection when properly supported by the BigCommerce API ?>
53+
<?php if ( count( $themes ) === 1 ) : ?>
54+
<input type="hidden" name="bc-gift-purchase[theme]" id="bc-gift-purchase-theme" data-form-field="bc-form-field-theme" value="<?php echo esc_attr( reset( $themes )['template'] ); ?>">
55+
<?php else: ?>
56+
<label for="bc-gift-purchase-theme" class="bc-form__control <?php if ( in_array( 'theme', $errors ) ) { echo esc_attr( $error_class ); } ?>">
57+
<span class="bc-form__label bc-gift-purchase__form-label"><?php echo esc_html( __( 'Gift Certificate Theme', 'bigcommerce' ) ); ?></span>
58+
<select name="bc-gift-purchase[theme]" id="bc-gift-purchase-theme" data-form-field="bc-form-field-theme">
59+
<?php foreach ( $themes as $theme ) : ?>
60+
<option value="<?php echo esc_attr( $theme['template'] ); ?>" <?php selected( $theme['template'], $defaults['theme'], true ); ?>><?php echo esc_html( $theme['name'] ); ?></option>
61+
<?php endforeach; ?>
62+
</select>
63+
</label>
64+
<?php endif; ?>
5465
</div>
5566
</div>
5667

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 ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3::getLoader();
7+
return ComposerAutoloaderInitae1011587482f7df754cc66887517e50::getLoader();

vendor/composer/autoload_real.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3
5+
class ComposerAutoloaderInitae1011587482f7df754cc66887517e50
66
{
77
private static $loader;
88

@@ -19,15 +19,15 @@ public static function getLoader()
1919
return self::$loader;
2020
}
2121

22-
spl_autoload_register(array('ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3', 'loadClassLoader'), true, true);
22+
spl_autoload_register(array('ComposerAutoloaderInitae1011587482f7df754cc66887517e50', 'loadClassLoader'), true, true);
2323
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24-
spl_autoload_unregister(array('ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3', 'loadClassLoader'));
24+
spl_autoload_unregister(array('ComposerAutoloaderInitae1011587482f7df754cc66887517e50', 'loadClassLoader'));
2525

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

30-
call_user_func(\Composer\Autoload\ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::getInitializer($loader));
30+
call_user_func(\Composer\Autoload\ComposerStaticInitae1011587482f7df754cc66887517e50::getInitializer($loader));
3131
} else {
3232
$classMap = require __DIR__ . '/autoload_classmap.php';
3333
if ($classMap) {
@@ -39,19 +39,19 @@ public static function getLoader()
3939
$loader->register(true);
4040

4141
if ($useStaticLoader) {
42-
$includeFiles = Composer\Autoload\ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$files;
42+
$includeFiles = Composer\Autoload\ComposerStaticInitae1011587482f7df754cc66887517e50::$files;
4343
} else {
4444
$includeFiles = require __DIR__ . '/autoload_files.php';
4545
}
4646
foreach ($includeFiles as $fileIdentifier => $file) {
47-
composerRequire7f3498ce3a6fdaaedaef737925157ce3($fileIdentifier, $file);
47+
composerRequireae1011587482f7df754cc66887517e50($fileIdentifier, $file);
4848
}
4949

5050
return $loader;
5151
}
5252
}
5353

54-
function composerRequire7f3498ce3a6fdaaedaef737925157ce3($fileIdentifier, $file)
54+
function composerRequireae1011587482f7df754cc66887517e50($fileIdentifier, $file)
5555
{
5656
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
5757
require $file;

vendor/composer/autoload_static.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Composer\Autoload;
66

7-
class ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3
7+
class ComposerStaticInitae1011587482f7df754cc66887517e50
88
{
99
public static $files = array (
1010
'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
@@ -1068,10 +1068,10 @@ class ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3
10681068
public static function getInitializer(ClassLoader $loader)
10691069
{
10701070
return \Closure::bind(function () use ($loader) {
1071-
$loader->prefixLengthsPsr4 = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$prefixLengthsPsr4;
1072-
$loader->prefixDirsPsr4 = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$prefixDirsPsr4;
1073-
$loader->prefixesPsr0 = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$prefixesPsr0;
1074-
$loader->classMap = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$classMap;
1071+
$loader->prefixLengthsPsr4 = ComposerStaticInitae1011587482f7df754cc66887517e50::$prefixLengthsPsr4;
1072+
$loader->prefixDirsPsr4 = ComposerStaticInitae1011587482f7df754cc66887517e50::$prefixDirsPsr4;
1073+
$loader->prefixesPsr0 = ComposerStaticInitae1011587482f7df754cc66887517e50::$prefixesPsr0;
1074+
$loader->classMap = ComposerStaticInitae1011587482f7df754cc66887517e50::$classMap;
10751075

10761076
}, null, ClassLoader::class);
10771077
}

0 commit comments

Comments
 (0)