Plugin Directory

Changeset 2975391


Ignore:
Timestamp:
10/06/2023 03:30:45 AM (2 years ago)
Author:
breadintegrations
Message:

Compatible with composite products and product bundle

Location:
bread-finance/trunk
Files:
11 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • bread-finance/trunk/README.md

    r2966824 r2975391  
    44Requires at least: 4.9
    55Tested up to: 6.1.1
    6 Stable tag: 3.3.5
     6Stable tag: 3.3.6
    77Requires PHP: 5.6
    88WC requires at least: 3.0
     
    7373== Changelog ==
    7474
     75= 3.3.6
     76* Current release
     77* Compatiblity with WooCommerce Composite Products and Product Bundles
     78
    7579= 3.3.5
    76 * Current release
    7780* Added unit tests
    7881* Added Embedded Checkout feature to display on same page instead of modal
  • bread-finance/trunk/assets/js/v2/main.js

    r2966782 r2975391  
    358358
    359359        var self = this,
    360                 validators = {
    361                     simple: function () {
    362                         return true;
    363                     },
    364 
    365                     grouped: function () {
    366                         return self.$form.find('input.qty').filter(function (index, element) {
    367                             return parseInt(element.value) > 0;
    368                         }).length > 0;
    369                     },
    370 
    371                     variable: function () {
    372                         return self.variation !== undefined;
    373                     },
    374 
    375                     composite: function () {
    376                         return (self.composite && self.composite.api.get_composite_validation_status() === 'pass');
    377                     }
    378                 };
     360            validators = {
     361                simple: function() {
     362                    return true;
     363                },
     364                grouped: function() {
     365                    return self.$form.find('input.qty').filter(function(index, element) {
     366                        return parseInt(element.value) > 0;
     367                    }).length > 0;
     368                },
     369                variable: function() {
     370                    return self.variation !== undefined;
     371                },
     372                composite: function() {
     373                    return (self.composite && self.composite.api.get_composite_validation_status() === 'pass');
     374                },
     375                bundle: function () {
     376                    return true;
     377                },
     378            };
    379379
    380380        if (!validators[breadController.local.product_type]) {
  • bread-finance/trunk/bread-finance.php

    r2966782 r2975391  
    66 * Author: Bread Pay
    77 * Author URI: https://payments.breadfinancial.com/
    8  * Version: 3.3.5
     8 * Version: 3.3.6
    99 * Text Domain: bread-finance
    1010 * Domain Path: /i18n/languages/
     
    2222
    2323//Require minimums and constants
    24 define('WC_BREAD_FINANCE_VERSION', '3.3.5');
     24define('WC_BREAD_FINANCE_VERSION', '3.3.6');
    2525define('WC_BREAD_FINANCE_MIN_PHP_VER', '5.6.0');
    2626define('WC_BREAD_FINANCE_MIN_WC_VER', '3.4.0');
  • bread-finance/trunk/classes/class-bread-finance-options-category.php

    r2966782 r2975391  
    9898            case 'composite':
    9999                return $this->getItemsComposite($options, $config);
     100            case 'bundle':
     101                return $this->getItemsBundle($options, $config);
    100102            default:
    101103                return array();
     
    177179    }
    178180
     181    public function getItemsBundle(&$options, $config) {
     182
     183        /** @var \WC_Product_Bundle $product */
     184        $product = wc_get_product($config['productId']);
     185        $bundlePrice = $product->get_bundle_price() ?: 0;
     186        $productTotal = $product->get_price() ?: 0;
     187
     188        $options['allowCheckout'] = false;
     189        $options['asLowAs'] = true;
     190        $options['customTotal'] = $this->bread_finance_utilities->priceToCents($bundlePrice) ?: $this->bread_finance_utilities->priceToCents($productTotal);
     191
     192        return array();
     193    }
     194
    179195}
  • bread-finance/trunk/classes/class-bread-finance-options-product.php

    r2886136 r2975391  
    103103        $productType = $config['productType'];
    104104        $customTotal = 0;
     105
     106        $product = wc_get_product($config['productId']);
    105107       
    106108        //Simple products
    107109        if($productType === 'simple') {
    108             $product = wc_get_product($config['productId']);
    109110
    110111            if (!is_object($product)) {
     
    120121        //Variable products
    121122        if ($productType === 'variable') {
    122             $product = wc_get_product($config['productId']);
    123123
    124124            if (!is_object($product)) {
     
    147147        if($productType === 'grouped') {
    148148            $customTotal = 0;
    149             $product = wc_get_product($config['productId']);
    150149           
    151150            if (!is_object($product)) {
     
    175174       
    176175        if($productType === 'composite') {
    177             $product = wc_get_product($config['productId']);
    178             $item = $this->getItem($product, $quantity);
     176            $item = $this->getItemForPlatform($product, $options['currency'], $quantity);
    179177            $compositePrice = $product->get_composite_price() ?: 0;
    180178            $item['unitPrice']['value'] = $this->bread_finance_utilities->priceToCents($compositePrice);   
     
    182180            $customTotal = $item['unitPrice']['value'];
    183181            $options['customTotal'] = $customTotal;
     182        }
     183
     184        if (class_exists('WC_Product_Bundle') && $productType === 'bundle') {
     185            $item = $this->getItemForPlatform($product, $options['currency'], $quantity);
     186            $bundlePrice = $product->get_bundle_price() ?: 0;
     187            $item['unitPrice']['value'] = $this->bread_finance_utilities->priceToCents($bundlePrice);   
     188            $options['items'][] = $item;
     189            $options['customTotal'] = $item['unitPrice']['value'] * $item['quantity'];
    184190        }
    185191       
  • bread-finance/trunk/classes/class-bread-finance-plugin.php

    r2726687 r2975391  
    2727     * @var array   Supported product-types
    2828     */
    29     public $supported_products = array('simple', 'grouped', 'variable', 'composite');
     29    public $supported_products = array('simple', 'grouped', 'variable', 'composite', 'bundle');
    3030
    3131    /**
Note: See TracChangeset for help on using the changeset viewer.