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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 40 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 33 additions & 0 deletions
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

Lines changed: 12 additions & 1 deletion
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

0 commit comments

Comments
 (0)