Changeset 2798482
- Timestamp:
- 10/13/2022 07:02:20 PM (3 years ago)
- Location:
- bigcommerce
- Files:
-
- 32 edited
- 1 copied
-
tags/4.35.0 (copied) (copied from bigcommerce/trunk)
-
tags/4.35.0/CHANGELOG.md (modified) (2 diffs)
-
tags/4.35.0/bigcommerce.php (modified) (1 diff)
-
tags/4.35.0/build-timestamp.php (modified) (1 diff)
-
tags/4.35.0/readme.txt (modified) (1 diff)
-
tags/4.35.0/src/BigCommerce/Accounts/Customer.php (modified) (1 diff)
-
tags/4.35.0/src/BigCommerce/Import/Processors/Cleanup.php (modified) (1 diff)
-
tags/4.35.0/src/BigCommerce/Plugin.php (modified) (1 diff)
-
tags/4.35.0/src/BigCommerce/Proxy/AMP_Cart_Controller.php (modified) (2 diffs)
-
tags/4.35.0/templates/public/amp/archive-bigcommerce_product.php (modified) (2 diffs)
-
tags/4.35.0/templates/public/amp/components/cart/cart-items.php (modified) (2 diffs)
-
tags/4.35.0/templates/public/amp/components/cart/cart-summary.php (modified) (1 diff)
-
tags/4.35.0/templates/public/amp/components/products/product-form.php (modified) (1 diff)
-
tags/4.35.0/templates/public/amp/components/products/product-single.php (modified) (1 diff)
-
tags/4.35.0/vendor/autoload.php (modified) (1 diff)
-
tags/4.35.0/vendor/composer/autoload_real.php (modified) (5 diffs)
-
tags/4.35.0/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/CHANGELOG.md (modified) (2 diffs)
-
trunk/bigcommerce.php (modified) (1 diff)
-
trunk/build-timestamp.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/src/BigCommerce/Accounts/Customer.php (modified) (1 diff)
-
trunk/src/BigCommerce/Import/Processors/Cleanup.php (modified) (1 diff)
-
trunk/src/BigCommerce/Plugin.php (modified) (1 diff)
-
trunk/src/BigCommerce/Proxy/AMP_Cart_Controller.php (modified) (2 diffs)
-
trunk/templates/public/amp/archive-bigcommerce_product.php (modified) (2 diffs)
-
trunk/templates/public/amp/components/cart/cart-items.php (modified) (2 diffs)
-
trunk/templates/public/amp/components/cart/cart-summary.php (modified) (1 diff)
-
trunk/templates/public/amp/components/products/product-form.php (modified) (1 diff)
-
trunk/templates/public/amp/components/products/product-single.php (modified) (1 diff)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (5 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bigcommerce/tags/4.35.0/CHANGELOG.md
r2785458 r2798482 1 1 # Changelog 2 3 ## [4.35.0] 4 5 ### Added 6 - Added subtotal and taxes display on AMP cart template 7 - Added ability to change quantity on AMP cart template 8 - Display product options(if applicable) on AMP cart template 9 10 ### Changed 11 - Changed customer cache flush logic. Prevent situations when customer group rules don't apply after they have been changed in Bigcommerce Control Panel. To flush customers data go to plugin settings: Bigcommerce → Settings → Diagnostics → Flush users cache 2 12 3 13 ## [4.34.0] … … 1832 1842 1833 1843 1844 [4.35.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.34.0...4.35.0 1834 1845 [4.34.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.33.0...4.34.0 1835 1846 [4.33.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.32.0...4.33.0 -
bigcommerce/tags/4.35.0/bigcommerce.php
r2785458 r2798482 4 4 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. 5 5 Author: BigCommerce 6 Version: 4.3 4.06 Version: 4.35.0 7 7 Author URI: https://www.bigcommerce.com/wordpress 8 8 Requires PHP: 7.4.0 -
bigcommerce/tags/4.35.0/build-timestamp.php
r2785458 r2798482 1 1 <?php 2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3. 00.09.12.2022');2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.47.10.10.2022'); -
bigcommerce/tags/4.35.0/readme.txt
r2785458 r2798482 4 4 Requires at least: 5.2 5 5 Tested up to: 5.9.2 6 Stable tag: 4.3 4.06 Stable tag: 4.35.0 7 7 Requires PHP: 7.4.0 8 8 License: GPLv2 or later -
bigcommerce/tags/4.35.0/src/BigCommerce/Accounts/Customer.php
r2700846 r2798482 334 334 */ 335 335 public function get_group_id() { 336 $customer_id = is_user_logged_in() ? get_user_option( self::CUSTOMER_ID_META, $this->wp_user_id ) : 0;336 $customer_id = is_user_logged_in() || defined( 'DOING_CRON' ) ? get_user_option( self::CUSTOMER_ID_META, $this->wp_user_id ) : 0; 337 337 if ( ! $customer_id ) { 338 338 /** -
bigcommerce/tags/4.35.0/src/BigCommerce/Import/Processors/Cleanup.php
r2766960 r2798482 116 116 $users_ids = get_users( [ 'fields' => 'ID' ] ); 117 117 foreach ( $users_ids as $users_id ) { 118 $customer_id = get_user_option( Customer::CUSTOMER_ID_META, $users_id ); 118 $customer_id = get_user_option( Customer::CUSTOMER_ID_META, $users_id ); 119 $customer = new Customer( $users_id ); 120 delete_transient( sprintf( 'bccustgroupinfo%d', $customer->get_group_id() ) ); 119 121 $transient_key = sprintf( 'bccustomergroup%d', $customer_id ); 120 122 delete_transient( $transient_key ); 123 delete_transient( sprintf( 'bccustomervisibleterms%d', $users_id ) ); 121 124 } 122 125 } -
bigcommerce/tags/4.35.0/src/BigCommerce/Plugin.php
r2785458 r2798482 5 5 6 6 class Plugin { 7 const VERSION = '4.3 4.0';7 const VERSION = '4.35.0'; 8 8 9 9 protected static $_instance; -
bigcommerce/tags/4.35.0/src/BigCommerce/Proxy/AMP_Cart_Controller.php
r2383942 r2798482 117 117 } 118 118 119 $query_params = [ 120 'include' => [ 121 'line_items.physical_items.options', 122 'line_items.digital_items.options', 123 'redirect_urls', 124 ], 125 ]; 126 119 127 $request = new WP_REST_Request( 120 128 'GET', 121 sprintf( '/%scarts/%s ', trailingslashit( $this->proxy_base ), $cart_id )129 sprintf( '/%scarts/%s?%s', trailingslashit( $this->proxy_base ), $cart_id, http_build_query( $query_params ) ), 122 130 ); 123 131 … … 137 145 ); 138 146 147 $data = $this->get_cart_totals( $data ); 148 139 149 return rest_ensure_response( $data ); 140 150 } 151 152 protected function get_cart_totals( $data ) { 153 $cart = [ 154 'base_amount' => [ 155 'raw' => $data['base_amount'], 156 'formatted' => $this->get_formatted_price( $data['base_amount'] ), 157 ], 158 'discount_amount' => [ 159 'raw' => $data['discount_amount'], 160 'formatted' => $this->get_formatted_price( $data['discount_amount'] ), 161 ], 162 'cart_amount' => [ 163 'raw' => $data['cart_amount'], 164 'formatted' => $this->get_formatted_price( $data['cart_amount'] ), 165 ], 166 'tax_included' => (bool) $data['tax_included'], 167 'coupons' => $data['coupons'], 168 ]; 169 170 $coupons_discount_amount = $this->get_coupons_discount_amount( $data['coupons'] ); 171 172 $cart[ 'coupons_discount_amount' ] = [ 173 'raw' => $coupons_discount_amount, 174 'formatted' => $this->get_formatted_price( $coupons_discount_amount ), 175 ]; 176 177 $tax_amount = $this->calculate_total_tax( 178 $cart[ 'cart_amount' ][ 'raw' ], 179 $cart[ 'discount_amount' ][ 'raw' ], 180 $coupons_discount_amount, 181 $data[ 'items' ] 182 ); 183 184 $cart[ 'tax_amount' ] = [ 185 'raw' => $tax_amount, 186 'formatted' => $this->get_formatted_price( $tax_amount ), 187 ]; 188 189 if ( $data[ 'tax_included' ] || $tax_amount < 0 ) { 190 $subtotal = $cart[ 'cart_amount' ][ 'raw' ]; 191 } else { 192 $subtotal = $cart[ 'cart_amount' ][ 'raw' ] - $tax_amount; 193 } 194 195 $cart[ 'subtotal' ] = [ 196 'raw' => $subtotal, 197 'formatted' => $this->get_formatted_price( $subtotal ), 198 ]; 199 200 return array_merge( $data, $cart ); 201 } 202 203 private function get_formatted_price( $value ) { 204 return apply_filters( 'bigcommerce/currency/format', sprintf( '¤%0.2f', $value ), $value ); 205 } 206 207 /** 208 * @param float $cart_amount The `cart_amount` value for the cart 209 * @param float $discount_amount The `discount_amount` value for the cart 210 * @param float $coupons_discount_amount The `coupons_discount_amount` value for the cart 211 * @param array $items The items in the cart 212 * 213 * @return float 214 */ 215 private function calculate_total_tax( $cart_amount, $discount_amount, $coupons_discount_amount, $items ) { 216 $item_sum = array_sum( array_map( function ( $item ) { 217 return isset( $item[ 'sale_price' ] ) ? $item[ 'sale_price' ] * $item['quantity'] : 0; 218 }, $items ) ); 219 220 return $cart_amount + $discount_amount + $coupons_discount_amount - $item_sum; 221 } 222 223 private function get_coupons_discount_amount( array $coupons ) { 224 return array_reduce( $coupons, function( $carry, $coupon ) { 225 return $carry + $coupon['discounted_amount']; 226 }, 0 ); 227 } 141 228 } -
bigcommerce/tags/4.35.0/templates/public/amp/archive-bigcommerce_product.php
r2292957 r2798482 4 4 * Override this template in your own theme by creating a file at 5 5 * [your-theme]/bigcommerce/archive-bigcommerce_product.php 6 * 6 * 7 7 * @version 1.0.0 8 8 */ … … 12 12 } 13 13 14 amp_add_post_template_actions();15 14 $post = get_post(); 16 15 $amp_post_template = new AMP_Post_Template( $post ); -
bigcommerce/tags/4.35.0/templates/public/amp/components/cart/cart-items.php
r2342514 r2798482 52 52 on="submit:AMP.setState({savingItem: true});submit-success:product-list.refresh,subtotal.refresh,AMP.setState({savingItem: false})" 53 53 > 54 <input type="hidden" name="cartId" value="CLIENT_ID( bigcommerce_cart_id)" data-amp-replace="CLIENT_ID" />54 <input type="hidden" name="cartId" value="CLIENT_ID(<?php echo Cart::CART_COOKIE; ?>)" data-amp-replace="CLIENT_ID" /> 55 55 <button 56 56 class="bc-link bc-cart-item__remove-button" … … 71 71 <span class="bc-cart-item__product-brand">{{ brand }}</span> 72 72 {{ /brand }} 73 74 {{ #options }} 75 <div class="bc-cart-item__product-options"> 76 <span class="bc-cart-item__product-option"> 77 <span class="bc-cart-item__product-option-label">{{ name }}</span> 78 <span class="bc-cart-item__product-option-value">{{ value }}</span> 79 </span> 80 </div> 81 {{ /options }} 73 82 </div> 74 83 75 84 <div class="bc-cart-item-quantity"> 76 {{ quantity }} 85 <form 86 id="item-{{ id }}-quantity" 87 action-xhr="<?php echo esc_url( rest_url( sprintf( '/%s/carts/_cart_id_/items/', $proxy_base ) ) ); ?>{{ id }}?qty=true'" 88 on="submit:AMP.setState({savingItem: true});submit-success:product-list.refresh,subtotal.refresh,AMP.setState({savingItem: false})" 89 method="post" 90 > 91 <input type="hidden" name="product_id" value="{{ product_id }}" /> 92 <input type="hidden" name="variant_id" value="{{ variant_id }}" /> 93 <input type="hidden" name="cartId" value="CLIENT_ID(<?php echo Cart::CART_COOKIE; ?>)" data-amp-replace="CLIENT_ID" /> 94 <input 95 type="number" 96 97 name="quantity" 98 class="bc-cart-item__quantity-input" 99 data-js="bc-cart-item__quantity" 100 value="{{ quantity }}" 101 on="change:item-{{ id }}-quantity.submit" 102 min="1" 103 /> 104 </form> 77 105 </div> 78 106 -
bigcommerce/tags/4.35.0/templates/public/amp/components/cart/cart-summary.php
r2292957 r2798482 24 24 > 25 25 <template type="amp-mustache"> 26 <span class="bc-cart-subtotal__label"><?php esc_html_e( 'Subtotal: ', 'bigcommerce' ); ?></span> 27 <span class="bc-cart-subtotal__amount">{{ total }}</span> 26 <div class="bc-cart-subtotal"> 27 <span class="bc-cart-subtotal__label"><?php esc_html_e( 'Subtotal: ', 'bigcommerce' ); ?></span> 28 <span class="bc-cart-subtotal__amount">{{ subtotal.formatted }}</span> 29 </div> 30 {{ #tax_amount }} 31 <div class="bc-cart-tax"> 32 <span class="bc-cart-tax__label"> 33 {{ #tax_included }} 34 <?php echo __( 'Estimated Tax Included in Subtotal: ', 'bigcommerce' ); ?> 35 {{ /tax_included }} 36 {{ ^tax_included }} 37 <?php echo __( 'Estimated Taxes: ', 'bigcommerce' ); ?> 38 {{ /tax_included }} 39 </span> 40 <span class="bc-cart-tax__amount"> 41 {{ tax_amount.formatted }} 42 </span> 43 </div> 44 {{ /tax_amount }} 45 <div class="bc-cart-total"> 46 <span class="bc-cart-total__label"><?php echo esc_html( __( 'Cart Total: ', 'bigcommerce' ) ); ?></span> 47 <span class="bc-cart-total__amount">{{ total }}</span> 48 </div> 28 49 </template> 29 50 </amp-list> -
bigcommerce/tags/4.35.0/templates/public/amp/components/products/product-form.php
r2354720 r2798482 26 26 <form action-xhr="<?php echo esc_url( trailingslashit( $product->purchase_url() ) ); ?>" method="post" enctype="multipart/form-data" class="bc-form bc-product-form" target="_top"> 27 27 <?php echo $options; // WPCS: XSS ok. Already escaped data. ?> 28 <?php echo $modifiers; // WPCS: XSS ok. Already escaped data. ?>29 28 <div class="bc-product-form__product-message" data-js="bc-product-message"></div> 30 29 <input type="hidden" name="variant_id" class="variant_id" [value]="<?php echo esc_attr( $variant_id_expression ); ?>"> -
bigcommerce/tags/4.35.0/templates/public/amp/components/products/product-single.php
r2292957 r2798482 27 27 <?php echo $price; // WPCS: XSS ok. Already escaped data. ?> 28 28 <?php echo $rating; // WPCS: XSS ok. Already escaped data. ?> 29 30 <?php if ( $sku ) { ?> 31 <span class="bc-product__sku"> 32 <span class="bc-product-single__meta-label"> 33 <?php esc_html_e( 'SKU:', 'bigcommerce' ); ?> 34 </span> 35 <?php echo esc_html( $sku ); ?> 36 </span> 37 <?php } ?> 29 <?php echo $sku; ?> 38 30 <?php echo $form; // WPCS: XSS ok. Already escaped data. ?> 39 31 </div> -
bigcommerce/tags/4.35.0/vendor/autoload.php
r2785458 r2798482 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d4::getLoader();7 return ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53::getLoader(); -
bigcommerce/tags/4.35.0/vendor/composer/autoload_real.php
r2785458 r2798482 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d45 class ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader')); 25 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 28 28 require_once __DIR__ . '/autoload_static.php'; 29 29 30 call_user_func(\Composer\Autoload\ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::getInitializer($loader)); 31 31 } else { 32 32 $classMap = require __DIR__ . '/autoload_classmap.php'; … … 40 40 41 41 if ($useStaticLoader) { 42 $includeFiles = Composer\Autoload\ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$files;42 $includeFiles = Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$files; 43 43 } else { 44 44 $includeFiles = require __DIR__ . '/autoload_files.php'; 45 45 } 46 46 foreach ($includeFiles as $fileIdentifier => $file) { 47 composerRequire 7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file);47 composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file); 48 48 } 49 49 … … 52 52 } 53 53 54 function composerRequire 7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file)54 function composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file) 55 55 { 56 56 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
bigcommerce/tags/4.35.0/vendor/composer/autoload_static.php
r2785458 r2798482 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d47 class ComposerStaticInitbc47ae46b55b55c82ca9433553970f53 8 8 { 9 9 public static $files = array ( … … 1164 1164 { 1165 1165 return \Closure::bind(function () use ($loader) { 1166 $loader->prefixLengthsPsr4 = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$prefixLengthsPsr4;1167 $loader->prefixDirsPsr4 = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$prefixDirsPsr4;1168 $loader->prefixesPsr0 = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$prefixesPsr0;1169 $loader->classMap = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$classMap;1166 $loader->prefixLengthsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixLengthsPsr4; 1167 $loader->prefixDirsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixDirsPsr4; 1168 $loader->prefixesPsr0 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixesPsr0; 1169 $loader->classMap = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$classMap; 1170 1170 1171 1171 }, null, ClassLoader::class); -
bigcommerce/trunk/CHANGELOG.md
r2785458 r2798482 1 1 # Changelog 2 3 ## [4.35.0] 4 5 ### Added 6 - Added subtotal and taxes display on AMP cart template 7 - Added ability to change quantity on AMP cart template 8 - Display product options(if applicable) on AMP cart template 9 10 ### Changed 11 - Changed customer cache flush logic. Prevent situations when customer group rules don't apply after they have been changed in Bigcommerce Control Panel. To flush customers data go to plugin settings: Bigcommerce → Settings → Diagnostics → Flush users cache 2 12 3 13 ## [4.34.0] … … 1832 1842 1833 1843 1844 [4.35.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.34.0...4.35.0 1834 1845 [4.34.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.33.0...4.34.0 1835 1846 [4.33.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.32.0...4.33.0 -
bigcommerce/trunk/bigcommerce.php
r2785458 r2798482 4 4 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. 5 5 Author: BigCommerce 6 Version: 4.3 4.06 Version: 4.35.0 7 7 Author URI: https://www.bigcommerce.com/wordpress 8 8 Requires PHP: 7.4.0 -
bigcommerce/trunk/build-timestamp.php
r2785458 r2798482 1 1 <?php 2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3. 00.09.12.2022');2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.47.10.10.2022'); -
bigcommerce/trunk/readme.txt
r2785458 r2798482 4 4 Requires at least: 5.2 5 5 Tested up to: 5.9.2 6 Stable tag: 4.3 4.06 Stable tag: 4.35.0 7 7 Requires PHP: 7.4.0 8 8 License: GPLv2 or later -
bigcommerce/trunk/src/BigCommerce/Accounts/Customer.php
r2700846 r2798482 334 334 */ 335 335 public function get_group_id() { 336 $customer_id = is_user_logged_in() ? get_user_option( self::CUSTOMER_ID_META, $this->wp_user_id ) : 0;336 $customer_id = is_user_logged_in() || defined( 'DOING_CRON' ) ? get_user_option( self::CUSTOMER_ID_META, $this->wp_user_id ) : 0; 337 337 if ( ! $customer_id ) { 338 338 /** -
bigcommerce/trunk/src/BigCommerce/Import/Processors/Cleanup.php
r2766960 r2798482 116 116 $users_ids = get_users( [ 'fields' => 'ID' ] ); 117 117 foreach ( $users_ids as $users_id ) { 118 $customer_id = get_user_option( Customer::CUSTOMER_ID_META, $users_id ); 118 $customer_id = get_user_option( Customer::CUSTOMER_ID_META, $users_id ); 119 $customer = new Customer( $users_id ); 120 delete_transient( sprintf( 'bccustgroupinfo%d', $customer->get_group_id() ) ); 119 121 $transient_key = sprintf( 'bccustomergroup%d', $customer_id ); 120 122 delete_transient( $transient_key ); 123 delete_transient( sprintf( 'bccustomervisibleterms%d', $users_id ) ); 121 124 } 122 125 } -
bigcommerce/trunk/src/BigCommerce/Plugin.php
r2785458 r2798482 5 5 6 6 class Plugin { 7 const VERSION = '4.3 4.0';7 const VERSION = '4.35.0'; 8 8 9 9 protected static $_instance; -
bigcommerce/trunk/src/BigCommerce/Proxy/AMP_Cart_Controller.php
r2383942 r2798482 117 117 } 118 118 119 $query_params = [ 120 'include' => [ 121 'line_items.physical_items.options', 122 'line_items.digital_items.options', 123 'redirect_urls', 124 ], 125 ]; 126 119 127 $request = new WP_REST_Request( 120 128 'GET', 121 sprintf( '/%scarts/%s ', trailingslashit( $this->proxy_base ), $cart_id )129 sprintf( '/%scarts/%s?%s', trailingslashit( $this->proxy_base ), $cart_id, http_build_query( $query_params ) ), 122 130 ); 123 131 … … 137 145 ); 138 146 147 $data = $this->get_cart_totals( $data ); 148 139 149 return rest_ensure_response( $data ); 140 150 } 151 152 protected function get_cart_totals( $data ) { 153 $cart = [ 154 'base_amount' => [ 155 'raw' => $data['base_amount'], 156 'formatted' => $this->get_formatted_price( $data['base_amount'] ), 157 ], 158 'discount_amount' => [ 159 'raw' => $data['discount_amount'], 160 'formatted' => $this->get_formatted_price( $data['discount_amount'] ), 161 ], 162 'cart_amount' => [ 163 'raw' => $data['cart_amount'], 164 'formatted' => $this->get_formatted_price( $data['cart_amount'] ), 165 ], 166 'tax_included' => (bool) $data['tax_included'], 167 'coupons' => $data['coupons'], 168 ]; 169 170 $coupons_discount_amount = $this->get_coupons_discount_amount( $data['coupons'] ); 171 172 $cart[ 'coupons_discount_amount' ] = [ 173 'raw' => $coupons_discount_amount, 174 'formatted' => $this->get_formatted_price( $coupons_discount_amount ), 175 ]; 176 177 $tax_amount = $this->calculate_total_tax( 178 $cart[ 'cart_amount' ][ 'raw' ], 179 $cart[ 'discount_amount' ][ 'raw' ], 180 $coupons_discount_amount, 181 $data[ 'items' ] 182 ); 183 184 $cart[ 'tax_amount' ] = [ 185 'raw' => $tax_amount, 186 'formatted' => $this->get_formatted_price( $tax_amount ), 187 ]; 188 189 if ( $data[ 'tax_included' ] || $tax_amount < 0 ) { 190 $subtotal = $cart[ 'cart_amount' ][ 'raw' ]; 191 } else { 192 $subtotal = $cart[ 'cart_amount' ][ 'raw' ] - $tax_amount; 193 } 194 195 $cart[ 'subtotal' ] = [ 196 'raw' => $subtotal, 197 'formatted' => $this->get_formatted_price( $subtotal ), 198 ]; 199 200 return array_merge( $data, $cart ); 201 } 202 203 private function get_formatted_price( $value ) { 204 return apply_filters( 'bigcommerce/currency/format', sprintf( '¤%0.2f', $value ), $value ); 205 } 206 207 /** 208 * @param float $cart_amount The `cart_amount` value for the cart 209 * @param float $discount_amount The `discount_amount` value for the cart 210 * @param float $coupons_discount_amount The `coupons_discount_amount` value for the cart 211 * @param array $items The items in the cart 212 * 213 * @return float 214 */ 215 private function calculate_total_tax( $cart_amount, $discount_amount, $coupons_discount_amount, $items ) { 216 $item_sum = array_sum( array_map( function ( $item ) { 217 return isset( $item[ 'sale_price' ] ) ? $item[ 'sale_price' ] * $item['quantity'] : 0; 218 }, $items ) ); 219 220 return $cart_amount + $discount_amount + $coupons_discount_amount - $item_sum; 221 } 222 223 private function get_coupons_discount_amount( array $coupons ) { 224 return array_reduce( $coupons, function( $carry, $coupon ) { 225 return $carry + $coupon['discounted_amount']; 226 }, 0 ); 227 } 141 228 } -
bigcommerce/trunk/templates/public/amp/archive-bigcommerce_product.php
r2292957 r2798482 4 4 * Override this template in your own theme by creating a file at 5 5 * [your-theme]/bigcommerce/archive-bigcommerce_product.php 6 * 6 * 7 7 * @version 1.0.0 8 8 */ … … 12 12 } 13 13 14 amp_add_post_template_actions();15 14 $post = get_post(); 16 15 $amp_post_template = new AMP_Post_Template( $post ); -
bigcommerce/trunk/templates/public/amp/components/cart/cart-items.php
r2342514 r2798482 52 52 on="submit:AMP.setState({savingItem: true});submit-success:product-list.refresh,subtotal.refresh,AMP.setState({savingItem: false})" 53 53 > 54 <input type="hidden" name="cartId" value="CLIENT_ID( bigcommerce_cart_id)" data-amp-replace="CLIENT_ID" />54 <input type="hidden" name="cartId" value="CLIENT_ID(<?php echo Cart::CART_COOKIE; ?>)" data-amp-replace="CLIENT_ID" /> 55 55 <button 56 56 class="bc-link bc-cart-item__remove-button" … … 71 71 <span class="bc-cart-item__product-brand">{{ brand }}</span> 72 72 {{ /brand }} 73 74 {{ #options }} 75 <div class="bc-cart-item__product-options"> 76 <span class="bc-cart-item__product-option"> 77 <span class="bc-cart-item__product-option-label">{{ name }}</span> 78 <span class="bc-cart-item__product-option-value">{{ value }}</span> 79 </span> 80 </div> 81 {{ /options }} 73 82 </div> 74 83 75 84 <div class="bc-cart-item-quantity"> 76 {{ quantity }} 85 <form 86 id="item-{{ id }}-quantity" 87 action-xhr="<?php echo esc_url( rest_url( sprintf( '/%s/carts/_cart_id_/items/', $proxy_base ) ) ); ?>{{ id }}?qty=true'" 88 on="submit:AMP.setState({savingItem: true});submit-success:product-list.refresh,subtotal.refresh,AMP.setState({savingItem: false})" 89 method="post" 90 > 91 <input type="hidden" name="product_id" value="{{ product_id }}" /> 92 <input type="hidden" name="variant_id" value="{{ variant_id }}" /> 93 <input type="hidden" name="cartId" value="CLIENT_ID(<?php echo Cart::CART_COOKIE; ?>)" data-amp-replace="CLIENT_ID" /> 94 <input 95 type="number" 96 97 name="quantity" 98 class="bc-cart-item__quantity-input" 99 data-js="bc-cart-item__quantity" 100 value="{{ quantity }}" 101 on="change:item-{{ id }}-quantity.submit" 102 min="1" 103 /> 104 </form> 77 105 </div> 78 106 -
bigcommerce/trunk/templates/public/amp/components/cart/cart-summary.php
r2292957 r2798482 24 24 > 25 25 <template type="amp-mustache"> 26 <span class="bc-cart-subtotal__label"><?php esc_html_e( 'Subtotal: ', 'bigcommerce' ); ?></span> 27 <span class="bc-cart-subtotal__amount">{{ total }}</span> 26 <div class="bc-cart-subtotal"> 27 <span class="bc-cart-subtotal__label"><?php esc_html_e( 'Subtotal: ', 'bigcommerce' ); ?></span> 28 <span class="bc-cart-subtotal__amount">{{ subtotal.formatted }}</span> 29 </div> 30 {{ #tax_amount }} 31 <div class="bc-cart-tax"> 32 <span class="bc-cart-tax__label"> 33 {{ #tax_included }} 34 <?php echo __( 'Estimated Tax Included in Subtotal: ', 'bigcommerce' ); ?> 35 {{ /tax_included }} 36 {{ ^tax_included }} 37 <?php echo __( 'Estimated Taxes: ', 'bigcommerce' ); ?> 38 {{ /tax_included }} 39 </span> 40 <span class="bc-cart-tax__amount"> 41 {{ tax_amount.formatted }} 42 </span> 43 </div> 44 {{ /tax_amount }} 45 <div class="bc-cart-total"> 46 <span class="bc-cart-total__label"><?php echo esc_html( __( 'Cart Total: ', 'bigcommerce' ) ); ?></span> 47 <span class="bc-cart-total__amount">{{ total }}</span> 48 </div> 28 49 </template> 29 50 </amp-list> -
bigcommerce/trunk/templates/public/amp/components/products/product-form.php
r2354720 r2798482 26 26 <form action-xhr="<?php echo esc_url( trailingslashit( $product->purchase_url() ) ); ?>" method="post" enctype="multipart/form-data" class="bc-form bc-product-form" target="_top"> 27 27 <?php echo $options; // WPCS: XSS ok. Already escaped data. ?> 28 <?php echo $modifiers; // WPCS: XSS ok. Already escaped data. ?>29 28 <div class="bc-product-form__product-message" data-js="bc-product-message"></div> 30 29 <input type="hidden" name="variant_id" class="variant_id" [value]="<?php echo esc_attr( $variant_id_expression ); ?>"> -
bigcommerce/trunk/templates/public/amp/components/products/product-single.php
r2292957 r2798482 27 27 <?php echo $price; // WPCS: XSS ok. Already escaped data. ?> 28 28 <?php echo $rating; // WPCS: XSS ok. Already escaped data. ?> 29 30 <?php if ( $sku ) { ?> 31 <span class="bc-product__sku"> 32 <span class="bc-product-single__meta-label"> 33 <?php esc_html_e( 'SKU:', 'bigcommerce' ); ?> 34 </span> 35 <?php echo esc_html( $sku ); ?> 36 </span> 37 <?php } ?> 29 <?php echo $sku; ?> 38 30 <?php echo $form; // WPCS: XSS ok. Already escaped data. ?> 39 31 </div> -
bigcommerce/trunk/vendor/autoload.php
r2785458 r2798482 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d4::getLoader();7 return ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53::getLoader(); -
bigcommerce/trunk/vendor/composer/autoload_real.php
r2785458 r2798482 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d45 class ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit 7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader')); 25 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 28 28 require_once __DIR__ . '/autoload_static.php'; 29 29 30 call_user_func(\Composer\Autoload\ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::getInitializer($loader)); 31 31 } else { 32 32 $classMap = require __DIR__ . '/autoload_classmap.php'; … … 40 40 41 41 if ($useStaticLoader) { 42 $includeFiles = Composer\Autoload\ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$files;42 $includeFiles = Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$files; 43 43 } else { 44 44 $includeFiles = require __DIR__ . '/autoload_files.php'; 45 45 } 46 46 foreach ($includeFiles as $fileIdentifier => $file) { 47 composerRequire 7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file);47 composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file); 48 48 } 49 49 … … 52 52 } 53 53 54 function composerRequire 7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file)54 function composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file) 55 55 { 56 56 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
bigcommerce/trunk/vendor/composer/autoload_static.php
r2785458 r2798482 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d47 class ComposerStaticInitbc47ae46b55b55c82ca9433553970f53 8 8 { 9 9 public static $files = array ( … … 1164 1164 { 1165 1165 return \Closure::bind(function () use ($loader) { 1166 $loader->prefixLengthsPsr4 = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$prefixLengthsPsr4;1167 $loader->prefixDirsPsr4 = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$prefixDirsPsr4;1168 $loader->prefixesPsr0 = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$prefixesPsr0;1169 $loader->classMap = ComposerStaticInit 7f327a3a3b1eac49a00726c87c0fc0d4::$classMap;1166 $loader->prefixLengthsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixLengthsPsr4; 1167 $loader->prefixDirsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixDirsPsr4; 1168 $loader->prefixesPsr0 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixesPsr0; 1169 $loader->classMap = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$classMap; 1170 1170 1171 1171 }, null, ClassLoader::class);
Note: See TracChangeset
for help on using the changeset viewer.