Skip to content

Commit

Permalink
packaged version 4.7.0 (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladanost committed Jan 15, 2021
1 parent 643354b commit 6a234c4
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 20 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [4.7.0]

### Added
- Added a proxy server endpoint to add multiple products to the cart in a single request
- Added support for Gift Certificate themes drop-down

### Fixed
- Fixed an erorr when printing a failed import time message in the Settings panel


## [4.6.0]

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


[4.7.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.6.0...4.7.0
[4.6.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.5.0...4.6.0
[4.5.1]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.5.0...4.5.1
[4.5.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.4.0...4.5.0
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.6.0
Version: 4.7.0
Author URI: https://www.bigcommerce.com/wordpress
Requires PHP: 7.2.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', '6.34.12.18.2020');
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '5.04.01.15.2021');
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.5
Stable tag: 4.6.0
Stable tag: 4.7.0
Requires PHP: 7.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private function get_certificate_data( $submission ) {
__( '%s Gift Certificate', 'bigcommerce' ),
apply_filters( 'bigcommerce/currency/format', sprintf( '¤%0.2f', $amount ), $amount )
);
$theme = apply_filters( 'bigcommerce/gift_certificates/theme', 'General.html' );
$theme = apply_filters( 'bigcommerce/gift_certificates/theme', $submission[ 'theme' ] );
$data = [
'name' => $name,
'theme' => $theme,
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.6.0';
const VERSION = '4.7.0';

protected static $_instance;

Expand Down
40 changes: 40 additions & 0 deletions src/BigCommerce/Proxy/Proxy_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ public function register_routes() {
],
]
);
register_rest_route(
$this->proxy_base,
'/carts/(.*)/items',
[
[
'methods' => [ WP_REST_SERVER::CREATABLE ],
'callback' => [ $this, 'add_cart_items' ],
'permission_callback' => '__return_true',
],
]
);
register_rest_route(
$this->proxy_base,
'/carts/(.*)/redirect_urls(\/?$)',
Expand Down Expand Up @@ -220,6 +231,35 @@ public function update_cart_item( $request ) {

return rest_ensure_response( json_decode( wp_remote_retrieve_body( $response ), true ) );
}

/**
* Add cart line items.
*
* @param WP_REST_Request $request Request instance.
* @return WP_REST_Response
*/
public function add_cart_items( $request ) {
$route = $this->route( $request );

$params = $request->get_body_params();
if ( empty( $params ) ) {
$params = json_decode( $request->get_body(), true );
}
$params = wp_parse_args( $params, [ 'line_items' => [], 'gift_certificates' => [] ] );

$args = [
'method' => $request->get_method(),
'headers' => $this->get_request_headers( $request, $route ),
'body' => wp_json_encode( [
'line_items' => $params['line_items'],
'gift_certificates' => $params['gift_certificates'],
] ),
];

$response = wp_remote_request( $route, $args );

return rest_ensure_response( json_decode( wp_remote_retrieve_body( $response ), true ) );
}

/**
* Provides request headers for use in multiple methods.
Expand Down
2 changes: 1 addition & 1 deletion src/BigCommerce/Settings/Import_Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private function previous_status() {
$status_string = sprintf( __( 'Last import completed on <strong>%s at %s (%s)</strong>.', 'bigcommerce' ), $date, $time, $this->get_timezone_string() );
break;
case Status::FAILED:
$status_string = sprintf( __( 'Last import failed on <strong>%s at %s (%s)</strong>.', 'bigcommerce' ), $date, $time, $$this->get_timezone_string() );
$status_string = sprintf( __( 'Last import failed on <strong>%s at %s (%s)</strong>.', 'bigcommerce' ), $date, $time, $this->get_timezone_string() );
break;
case Status::NOT_STARTED:
$status_string = '';
Expand Down
33 changes: 33 additions & 0 deletions src/BigCommerce/Templates/Gift_Certificate_Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Gift_Certificate_Form extends Form_Controller {
const DEFAULTS = 'defaults';
const BUTTON_LABEL = 'button_label';
const ERRORS = 'errors';
const THEMES = 'themes';

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

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

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

return $data;
}

protected function get_form_defaults() {
$themes = $this->get_themes();
return [
'sender-name' => '',
'sender-email' => '',
'recipient-name' => '',
'recipient-email' => '',
'amount' => '',
'message' => '',
'theme' => array_key_exists( 'general', $themes ) ? $themes['general']['template'] : '',
];
}

Expand All @@ -48,4 +52,33 @@ protected function get_button_label() {
return get_option( Buttons::BUY_NOW, __( 'Buy Now', 'bigcommerce' ) );
}
}

protected function get_themes() {
return apply_filters( 'bigcommerce/gift_certificates/themes', [
'boy' => [
'name' => __( 'Boy', 'bigcommerce' ),
'template' => 'Boy.html',
],
'celebration' => [
'name' => __( 'Celebration', 'bigcommerce' ),
'template' => 'Celebration.html',
],
'christmas' => [
'name' => __( 'Christmas', 'bigcommerce' ),
'template' => 'Christmas.html',
],
'general' => [
'name' => __( 'General', 'bigcommerce' ),
'template' => 'General.html',
],
'girl' => [
'name' => __( 'Girl', 'bigcommerce' ),
'template' => 'Girl.html',
],
'birthday' => [
'name' => __( 'Birthday', 'bigcommerce' ),
'template' => 'Birthday.html',
],
] );
}
}
13 changes: 12 additions & 1 deletion templates/public/components/gift-certificates/purchase-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@
<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>
</label>

<?php // TODO: theme selection when properly supported by the BigCommerce API ?>
<?php if ( count( $themes ) === 1 ) : ?>
<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'] ); ?>">
<?php else: ?>
<label for="bc-gift-purchase-theme" class="bc-form__control <?php if ( in_array( 'theme', $errors ) ) { echo esc_attr( $error_class ); } ?>">
<span class="bc-form__label bc-gift-purchase__form-label"><?php echo esc_html( __( 'Gift Certificate Theme', 'bigcommerce' ) ); ?></span>
<select name="bc-gift-purchase[theme]" id="bc-gift-purchase-theme" data-form-field="bc-form-field-theme">
<?php foreach ( $themes as $theme ) : ?>
<option value="<?php echo esc_attr( $theme['template'] ); ?>" <?php selected( $theme['template'], $defaults['theme'], true ); ?>><?php echo esc_html( $theme['name'] ); ?></option>
<?php endforeach; ?>
</select>
</label>
<?php endif; ?>
</div>
</div>

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 ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3::getLoader();
return ComposerAutoloaderInitae1011587482f7df754cc66887517e50::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 ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3
class ComposerAutoloaderInitae1011587482f7df754cc66887517e50
{
private static $loader;

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

spl_autoload_register(array('ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitae1011587482f7df754cc66887517e50', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitae1011587482f7df754cc66887517e50', '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\ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitae1011587482f7df754cc66887517e50::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\ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitae1011587482f7df754cc66887517e50::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire7f3498ce3a6fdaaedaef737925157ce3($fileIdentifier, $file);
composerRequireae1011587482f7df754cc66887517e50($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequire7f3498ce3a6fdaaedaef737925157ce3($fileIdentifier, $file)
function composerRequireae1011587482f7df754cc66887517e50($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 ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3
class ComposerStaticInitae1011587482f7df754cc66887517e50
{
public static $files = array (
'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
Expand Down Expand Up @@ -1068,10 +1068,10 @@ class ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$prefixesPsr0;
$loader->classMap = ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitae1011587482f7df754cc66887517e50::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitae1011587482f7df754cc66887517e50::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitae1011587482f7df754cc66887517e50::$prefixesPsr0;
$loader->classMap = ComposerStaticInitae1011587482f7df754cc66887517e50::$classMap;

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

0 comments on commit 6a234c4

Please sign in to comment.