Plugin Directory

Changeset 2798482


Ignore:
Timestamp:
10/13/2022 07:02:20 PM (3 years ago)
Author:
bigcommerce
Message:

Update to version 4.35.0 from GitHub

Location:
bigcommerce
Files:
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • bigcommerce/tags/4.35.0/CHANGELOG.md

    r2785458 r2798482  
    11# 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
    212
    313## [4.34.0]
     
    18321842
    18331843
     1844[4.35.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.34.0...4.35.0
    18341845[4.34.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.33.0...4.34.0
    18351846[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  
    44Description:  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.
    55Author:       BigCommerce
    6 Version:      4.34.0
     6Version:      4.35.0
    77Author URI:   https://www.bigcommerce.com/wordpress
    88Requires PHP: 7.4.0
  • bigcommerce/tags/4.35.0/build-timestamp.php

    r2785458 r2798482  
    11<?php
    2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.00.09.12.2022');
     2define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.47.10.10.2022');
  • bigcommerce/tags/4.35.0/readme.txt

    r2785458 r2798482  
    44Requires at least: 5.2
    55Tested up to: 5.9.2
    6 Stable tag: 4.34.0
     6Stable tag: 4.35.0
    77Requires PHP: 7.4.0
    88License: GPLv2 or later
  • bigcommerce/tags/4.35.0/src/BigCommerce/Accounts/Customer.php

    r2700846 r2798482  
    334334     */
    335335    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;
    337337        if ( ! $customer_id ) {
    338338            /**
  • bigcommerce/tags/4.35.0/src/BigCommerce/Import/Processors/Cleanup.php

    r2766960 r2798482  
    116116        $users_ids = get_users( [ 'fields' => 'ID' ] );
    117117        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() ) );
    119121            $transient_key = sprintf( 'bccustomergroup%d', $customer_id );
    120122            delete_transient( $transient_key );
     123            delete_transient( sprintf( 'bccustomervisibleterms%d', $users_id ) );
    121124        }
    122125    }
  • bigcommerce/tags/4.35.0/src/BigCommerce/Plugin.php

    r2785458 r2798482  
    55
    66class Plugin {
    7     const VERSION = '4.34.0';
     7    const VERSION = '4.35.0';
    88
    99    protected static $_instance;
  • bigcommerce/tags/4.35.0/src/BigCommerce/Proxy/AMP_Cart_Controller.php

    r2383942 r2798482  
    117117        }
    118118
     119        $query_params = [
     120            'include' => [
     121                'line_items.physical_items.options',
     122                'line_items.digital_items.options',
     123                'redirect_urls',
     124            ],
     125        ];
     126
    119127        $request = new WP_REST_Request(
    120128            '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 ) ),
    122130        );
    123131
     
    137145        );
    138146
     147        $data = $this->get_cart_totals( $data );
     148
    139149        return rest_ensure_response( $data );
    140150    }
     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    }
    141228}
  • bigcommerce/tags/4.35.0/templates/public/amp/archive-bigcommerce_product.php

    r2292957 r2798482  
    44 * Override this template in your own theme by creating a file at
    55 * [your-theme]/bigcommerce/archive-bigcommerce_product.php
    6  * 
     6 *
    77 * @version 1.0.0
    88 */
     
    1212}
    1313
    14 amp_add_post_template_actions();
    1514$post              = get_post();
    1615$amp_post_template = new AMP_Post_Template( $post );
  • bigcommerce/tags/4.35.0/templates/public/amp/components/cart/cart-items.php

    r2342514 r2798482  
    5252                    on="submit:AMP.setState({savingItem: true});submit-success:product-list.refresh,subtotal.refresh,AMP.setState({savingItem: false})"
    5353                    >
    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" />
    5555                    <button
    5656                            class="bc-link bc-cart-item__remove-button"
     
    7171                    <span class="bc-cart-item__product-brand">{{ brand }}</span>
    7272                {{ /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 }}
    7382            </div>
    7483
    7584            <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>
    77105            </div>
    78106
  • bigcommerce/tags/4.35.0/templates/public/amp/components/cart/cart-summary.php

    r2292957 r2798482  
    2424    >
    2525    <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>
    2849    </template>
    2950</amp-list>
  • bigcommerce/tags/4.35.0/templates/public/amp/components/products/product-form.php

    r2354720 r2798482  
    2626<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">
    2727    <?php echo $options; // WPCS: XSS ok. Already escaped data. ?>
    28     <?php echo $modifiers; // WPCS: XSS ok. Already escaped data. ?>
    2928    <div class="bc-product-form__product-message" data-js="bc-product-message"></div>
    3029    <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  
    2727            <?php echo $price; // WPCS: XSS ok. Already escaped data. ?>
    2828            <?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; ?>
    3830            <?php echo $form; // WPCS: XSS ok. Already escaped data. ?>
    3931        </div>
  • bigcommerce/tags/4.35.0/vendor/autoload.php

    r2785458 r2798482  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4::getLoader();
     7return ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53::getLoader();
  • bigcommerce/tags/4.35.0/vendor/composer/autoload_real.php

    r2785458 r2798482  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4
     5class ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53
    66{
    77    private static $loader;
     
    2020        }
    2121
    22         spl_autoload_register(array('ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'), true, true);
     22        spl_autoload_register(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader'), true, true);
    2323        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'));
     24        spl_autoload_unregister(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader'));
    2525
    2626        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    2828            require_once __DIR__ . '/autoload_static.php';
    2929
    30             call_user_func(\Composer\Autoload\ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::getInitializer($loader));
     30            call_user_func(\Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::getInitializer($loader));
    3131        } else {
    3232            $classMap = require __DIR__ . '/autoload_classmap.php';
     
    4040
    4141        if ($useStaticLoader) {
    42             $includeFiles = Composer\Autoload\ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$files;
     42            $includeFiles = Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$files;
    4343        } else {
    4444            $includeFiles = require __DIR__ . '/autoload_files.php';
    4545        }
    4646        foreach ($includeFiles as $fileIdentifier => $file) {
    47             composerRequire7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file);
     47            composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file);
    4848        }
    4949
     
    5252}
    5353
    54 function composerRequire7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file)
     54function composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file)
    5555{
    5656    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • bigcommerce/tags/4.35.0/vendor/composer/autoload_static.php

    r2785458 r2798482  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4
     7class ComposerStaticInitbc47ae46b55b55c82ca9433553970f53
    88{
    99    public static $files = array (
     
    11641164    {
    11651165        return \Closure::bind(function () use ($loader) {
    1166             $loader->prefixLengthsPsr4 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixLengthsPsr4;
    1167             $loader->prefixDirsPsr4 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixDirsPsr4;
    1168             $loader->prefixesPsr0 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixesPsr0;
    1169             $loader->classMap = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$classMap;
     1166            $loader->prefixLengthsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixLengthsPsr4;
     1167            $loader->prefixDirsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixDirsPsr4;
     1168            $loader->prefixesPsr0 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixesPsr0;
     1169            $loader->classMap = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$classMap;
    11701170
    11711171        }, null, ClassLoader::class);
  • bigcommerce/trunk/CHANGELOG.md

    r2785458 r2798482  
    11# 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
    212
    313## [4.34.0]
     
    18321842
    18331843
     1844[4.35.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.34.0...4.35.0
    18341845[4.34.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.33.0...4.34.0
    18351846[4.33.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.32.0...4.33.0
  • bigcommerce/trunk/bigcommerce.php

    r2785458 r2798482  
    44Description:  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.
    55Author:       BigCommerce
    6 Version:      4.34.0
     6Version:      4.35.0
    77Author URI:   https://www.bigcommerce.com/wordpress
    88Requires PHP: 7.4.0
  • bigcommerce/trunk/build-timestamp.php

    r2785458 r2798482  
    11<?php
    2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.00.09.12.2022');
     2define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.47.10.10.2022');
  • bigcommerce/trunk/readme.txt

    r2785458 r2798482  
    44Requires at least: 5.2
    55Tested up to: 5.9.2
    6 Stable tag: 4.34.0
     6Stable tag: 4.35.0
    77Requires PHP: 7.4.0
    88License: GPLv2 or later
  • bigcommerce/trunk/src/BigCommerce/Accounts/Customer.php

    r2700846 r2798482  
    334334     */
    335335    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;
    337337        if ( ! $customer_id ) {
    338338            /**
  • bigcommerce/trunk/src/BigCommerce/Import/Processors/Cleanup.php

    r2766960 r2798482  
    116116        $users_ids = get_users( [ 'fields' => 'ID' ] );
    117117        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() ) );
    119121            $transient_key = sprintf( 'bccustomergroup%d', $customer_id );
    120122            delete_transient( $transient_key );
     123            delete_transient( sprintf( 'bccustomervisibleterms%d', $users_id ) );
    121124        }
    122125    }
  • bigcommerce/trunk/src/BigCommerce/Plugin.php

    r2785458 r2798482  
    55
    66class Plugin {
    7     const VERSION = '4.34.0';
     7    const VERSION = '4.35.0';
    88
    99    protected static $_instance;
  • bigcommerce/trunk/src/BigCommerce/Proxy/AMP_Cart_Controller.php

    r2383942 r2798482  
    117117        }
    118118
     119        $query_params = [
     120            'include' => [
     121                'line_items.physical_items.options',
     122                'line_items.digital_items.options',
     123                'redirect_urls',
     124            ],
     125        ];
     126
    119127        $request = new WP_REST_Request(
    120128            '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 ) ),
    122130        );
    123131
     
    137145        );
    138146
     147        $data = $this->get_cart_totals( $data );
     148
    139149        return rest_ensure_response( $data );
    140150    }
     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    }
    141228}
  • bigcommerce/trunk/templates/public/amp/archive-bigcommerce_product.php

    r2292957 r2798482  
    44 * Override this template in your own theme by creating a file at
    55 * [your-theme]/bigcommerce/archive-bigcommerce_product.php
    6  * 
     6 *
    77 * @version 1.0.0
    88 */
     
    1212}
    1313
    14 amp_add_post_template_actions();
    1514$post              = get_post();
    1615$amp_post_template = new AMP_Post_Template( $post );
  • bigcommerce/trunk/templates/public/amp/components/cart/cart-items.php

    r2342514 r2798482  
    5252                    on="submit:AMP.setState({savingItem: true});submit-success:product-list.refresh,subtotal.refresh,AMP.setState({savingItem: false})"
    5353                    >
    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" />
    5555                    <button
    5656                            class="bc-link bc-cart-item__remove-button"
     
    7171                    <span class="bc-cart-item__product-brand">{{ brand }}</span>
    7272                {{ /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 }}
    7382            </div>
    7483
    7584            <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>
    77105            </div>
    78106
  • bigcommerce/trunk/templates/public/amp/components/cart/cart-summary.php

    r2292957 r2798482  
    2424    >
    2525    <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>
    2849    </template>
    2950</amp-list>
  • bigcommerce/trunk/templates/public/amp/components/products/product-form.php

    r2354720 r2798482  
    2626<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">
    2727    <?php echo $options; // WPCS: XSS ok. Already escaped data. ?>
    28     <?php echo $modifiers; // WPCS: XSS ok. Already escaped data. ?>
    2928    <div class="bc-product-form__product-message" data-js="bc-product-message"></div>
    3029    <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  
    2727            <?php echo $price; // WPCS: XSS ok. Already escaped data. ?>
    2828            <?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; ?>
    3830            <?php echo $form; // WPCS: XSS ok. Already escaped data. ?>
    3931        </div>
  • bigcommerce/trunk/vendor/autoload.php

    r2785458 r2798482  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4::getLoader();
     7return ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53::getLoader();
  • bigcommerce/trunk/vendor/composer/autoload_real.php

    r2785458 r2798482  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4
     5class ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53
    66{
    77    private static $loader;
     
    2020        }
    2121
    22         spl_autoload_register(array('ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'), true, true);
     22        spl_autoload_register(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader'), true, true);
    2323        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInit7f327a3a3b1eac49a00726c87c0fc0d4', 'loadClassLoader'));
     24        spl_autoload_unregister(array('ComposerAutoloaderInitbc47ae46b55b55c82ca9433553970f53', 'loadClassLoader'));
    2525
    2626        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    2828            require_once __DIR__ . '/autoload_static.php';
    2929
    30             call_user_func(\Composer\Autoload\ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::getInitializer($loader));
     30            call_user_func(\Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::getInitializer($loader));
    3131        } else {
    3232            $classMap = require __DIR__ . '/autoload_classmap.php';
     
    4040
    4141        if ($useStaticLoader) {
    42             $includeFiles = Composer\Autoload\ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$files;
     42            $includeFiles = Composer\Autoload\ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$files;
    4343        } else {
    4444            $includeFiles = require __DIR__ . '/autoload_files.php';
    4545        }
    4646        foreach ($includeFiles as $fileIdentifier => $file) {
    47             composerRequire7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file);
     47            composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file);
    4848        }
    4949
     
    5252}
    5353
    54 function composerRequire7f327a3a3b1eac49a00726c87c0fc0d4($fileIdentifier, $file)
     54function composerRequirebc47ae46b55b55c82ca9433553970f53($fileIdentifier, $file)
    5555{
    5656    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • bigcommerce/trunk/vendor/composer/autoload_static.php

    r2785458 r2798482  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4
     7class ComposerStaticInitbc47ae46b55b55c82ca9433553970f53
    88{
    99    public static $files = array (
     
    11641164    {
    11651165        return \Closure::bind(function () use ($loader) {
    1166             $loader->prefixLengthsPsr4 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixLengthsPsr4;
    1167             $loader->prefixDirsPsr4 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixDirsPsr4;
    1168             $loader->prefixesPsr0 = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$prefixesPsr0;
    1169             $loader->classMap = ComposerStaticInit7f327a3a3b1eac49a00726c87c0fc0d4::$classMap;
     1166            $loader->prefixLengthsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixLengthsPsr4;
     1167            $loader->prefixDirsPsr4 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixDirsPsr4;
     1168            $loader->prefixesPsr0 = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$prefixesPsr0;
     1169            $loader->classMap = ComposerStaticInitbc47ae46b55b55c82ca9433553970f53::$classMap;
    11701170
    11711171        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.