From 6a234c4e9d5107ec2c780f754a439649324e466f Mon Sep 17 00:00:00 2001 From: vladanost Date: Fri, 15 Jan 2021 18:16:24 +0100 Subject: [PATCH] packaged version 4.7.0 (#251) --- CHANGELOG.md | 10 +++++ bigcommerce.php | 2 +- build-timestamp.php | 2 +- readme.txt | 2 +- .../Purchase_Gift_Certificate_Handler.php | 2 +- src/BigCommerce/Plugin.php | 2 +- src/BigCommerce/Proxy/Proxy_Controller.php | 40 +++++++++++++++++++ src/BigCommerce/Settings/Import_Status.php | 2 +- .../Templates/Gift_Certificate_Form.php | 33 +++++++++++++++ .../gift-certificates/purchase-form.php | 13 +++++- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++---- vendor/composer/autoload_static.php | 10 ++--- 13 files changed, 114 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef933c0e..a83aba9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] @@ -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 diff --git a/bigcommerce.php b/bigcommerce.php index 95afabc9..bc829422 100644 --- a/bigcommerce.php +++ b/bigcommerce.php @@ -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 diff --git a/build-timestamp.php b/build-timestamp.php index 0e71f4d1..f867bd7a 100644 --- a/build-timestamp.php +++ b/build-timestamp.php @@ -1,2 +1,2 @@ $name, 'theme' => $theme, diff --git a/src/BigCommerce/Plugin.php b/src/BigCommerce/Plugin.php index a774e649..3eca9f4f 100644 --- a/src/BigCommerce/Plugin.php +++ b/src/BigCommerce/Plugin.php @@ -4,7 +4,7 @@ namespace BigCommerce; class Plugin { - const VERSION = '4.6.0'; + const VERSION = '4.7.0'; protected static $_instance; diff --git a/src/BigCommerce/Proxy/Proxy_Controller.php b/src/BigCommerce/Proxy/Proxy_Controller.php index 2c2568bf..72bdcf00 100644 --- a/src/BigCommerce/Proxy/Proxy_Controller.php +++ b/src/BigCommerce/Proxy/Proxy_Controller.php @@ -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(\/?$)', @@ -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. diff --git a/src/BigCommerce/Settings/Import_Status.php b/src/BigCommerce/Settings/Import_Status.php index 157a120a..0b48401f 100644 --- a/src/BigCommerce/Settings/Import_Status.php +++ b/src/BigCommerce/Settings/Import_Status.php @@ -181,7 +181,7 @@ private function previous_status() { $status_string = sprintf( __( 'Last import completed on %s at %s (%s).', 'bigcommerce' ), $date, $time, $this->get_timezone_string() ); break; case Status::FAILED: - $status_string = sprintf( __( 'Last import failed on %s at %s (%s).', 'bigcommerce' ), $date, $time, $$this->get_timezone_string() ); + $status_string = sprintf( __( 'Last import failed on %s at %s (%s).', 'bigcommerce' ), $date, $time, $this->get_timezone_string() ); break; case Status::NOT_STARTED: $status_string = ''; diff --git a/src/BigCommerce/Templates/Gift_Certificate_Form.php b/src/BigCommerce/Templates/Gift_Certificate_Form.php index d30b684f..c6b19290 100644 --- a/src/BigCommerce/Templates/Gift_Certificate_Form.php +++ b/src/BigCommerce/Templates/Gift_Certificate_Form.php @@ -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'; @@ -26,11 +27,13 @@ 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' => '', @@ -38,6 +41,7 @@ protected function get_form_defaults() { 'recipient-email' => '', 'amount' => '', 'message' => '', + 'theme' => array_key_exists( 'general', $themes ) ? $themes['general']['template'] : '', ]; } @@ -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', + ], + ] ); + } } \ No newline at end of file diff --git a/templates/public/components/gift-certificates/purchase-form.php b/templates/public/components/gift-certificates/purchase-form.php index 52b4abfc..72a2ab9e 100644 --- a/templates/public/components/gift-certificates/purchase-form.php +++ b/templates/public/components/gift-certificates/purchase-form.php @@ -50,7 +50,18 @@ - + + + + + diff --git a/vendor/autoload.php b/vendor/autoload.php index 368d52d9..39185282 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3::getLoader(); +return ComposerAutoloaderInitae1011587482f7df754cc66887517e50::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 2a7e4776..7b079eb5 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit7f3498ce3a6fdaaedaef737925157ce3 +class ComposerAutoloaderInitae1011587482f7df754cc66887517e50 { private static $loader; @@ -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) { @@ -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; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 9bd00ecf..e2c160b9 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit7f3498ce3a6fdaaedaef737925157ce3 +class ComposerStaticInitae1011587482f7df754cc66887517e50 { public static $files = array ( '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', @@ -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); }