Plugin Directory

Changeset 3147354


Ignore:
Timestamp:
09/06/2024 05:38:13 AM (19 months ago)
Author:
themeparrot
Message:

release 1.1.6

Location:
weight-based-pricing-for-woocommerce/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • weight-based-pricing-for-woocommerce/trunk/App/Controllers/Frontend/CartAdjustments.php

    r2972088 r3147354  
    168168    {
    169169        $data = get_post_meta($product_id, 'wwbp_pricing_rule', false);
    170         if(isset($data[0]) && !empty($data[0])){
    171             $pricing_rules = $data[0];
    172         }else {
    173             $pricing_rules = [];
    174         }
    175 
    176         $i = 0;
    177         $rules = [];
    178         foreach ($pricing_rules as $pricing_rule) {
    179             $rules[$i] = $pricing_rule;
    180             $i++;
    181         }
    182 
    183         $special_price = 0;
    184         for ($i = 0; $i < count($rules); $i++) {
     170    if (isset($data[0]) && !empty($data[0])) {
     171        $pricing_rules = $data[0];
     172    } else {
     173        $pricing_rules = [];
     174    }
     175
     176    $i = 0;
     177    $rules = [];
     178    foreach ($pricing_rules as $pricing_rule) {
     179        $rules[$i] = $pricing_rule;
     180        $i++;
     181    }
     182
     183    $special_price = 0;
     184    for ($i = 0; $i < count($rules); $i++) {
     185        // Ensure 'wwbp_to_weight' and 'wwbp_from_weight' are present
     186        if (isset($rules[$i]['wwbp_from_weight']) && isset($rules[$i]['wwbp_to_weight'])) {
    185187            $from_weight = (float) $rules[$i]['wwbp_from_weight'];
    186188            $to_weight = (float) $rules[$i]['wwbp_to_weight'];
     
    190192            }
    191193        }
    192 
    193         if (0 < $special_price && $special_price < $product_price) {
    194             $custom_price = $special_price * $weight_qty;
    195         } else {
    196             $custom_price = $product_price * $weight_qty;
    197         }
    198 
    199         return (float) number_format($custom_price, wc_get_price_decimals(), '.', '');
     194    }
     195
     196    if (0 < $special_price && $special_price < $product_price) {
     197        $custom_price = $special_price * $weight_qty;
     198    } else {
     199        $custom_price = $product_price * $weight_qty;
     200    }
     201
     202    return (float) number_format($custom_price, wc_get_price_decimals(), '.', '');
    200203    }
    201204
  • weight-based-pricing-for-woocommerce/trunk/App/Views/Admin/PricingRule.php

    r2972088 r3147354  
    114114            {
    115115                $range_datas = $measure_ranges["$row_unique_id"];
    116                 $from_range = $range_datas['wwbp_from_weight'];
    117                 $to_range = $range_datas['wwbp_to_weight'];
    118                 $unit_price = $range_datas['wwbp_unit_price'];
    119                 $sale_price = $range_datas['wwbp_sale_price'];
     116                $from_range = isset($range_datas['wwbp_from_weight']) ? $range_datas['wwbp_from_weight'] : '';
     117                $to_range = isset($range_datas['wwbp_to_weight']) ? $range_datas['wwbp_to_weight'] : '';
     118                $unit_price = isset($range_datas['wwbp_unit_price']) ? $range_datas['wwbp_unit_price'] : '';
     119                $sale_price = isset($range_datas['wwbp_sale_price']) ? $range_datas['wwbp_sale_price'] : '';
     120               
    120121            }
    121122        }
     
    158159            {
    159160                $range_datas = $measure_ranges["$row_unique_id"];
    160                 $from_range = $range_datas['wwbp_from_weight'];
    161                 $to_range = $range_datas['wwbp_to_weight'];
    162                 $unit_price = $range_datas['wwbp_unit_price'];
    163                 $sale_price = $range_datas['wwbp_sale_price'];
     161                $from_range = isset($range_datas['wwbp_from_weight']) ? $range_datas['wwbp_from_weight'] : '';
     162                $to_range = isset($range_datas['wwbp_to_weight']) ? $range_datas['wwbp_to_weight'] : '';
     163                $unit_price = isset($range_datas['wwbp_unit_price']) ? $range_datas['wwbp_unit_price'] : '';
     164                $sale_price = isset($range_datas['wwbp_sale_price']) ? $range_datas['wwbp_sale_price'] : '';
     165               
    164166            }
    165167        }
  • weight-based-pricing-for-woocommerce/trunk/i18n/languages/weight-based-pricing-woocommerce.pot

    r2808455 r3147354  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Weight Based Pricing for WooCommerce 1.1.4\n"
     5"Project-Id-Version: Weight Based Pricing for WooCommerce 1.1.6\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/weight-based-pricing-for-woocommerce\n"
    77"Last-Translator: Anantharaj <anantharaj@w3cert.in>\n"
  • weight-based-pricing-for-woocommerce/trunk/readme.txt

    r2972088 r3147354  
    55Requires at least: 4.9.0
    66Requires PHP: 5.6
    7 Tested up to: 6.3
    8 Stable tag: 1.1.5
     7Tested up to: 6.6.1
     8Stable tag: 1.1.6
    99License: GPLv3 or later
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    5858== Changelog ==
    5959
     60= 1.1.6 - 05/09/2024
     61* Improvement - HPOS Compatibility added
     62* Fix - Undefined Variable Errors
     63
    6064= 1.1.5 - 25/09/2023 =
    61 * Fix - PHP Deprecated Function Errors and Functional Improvements
     65* Fix PHP Deprecated Function Errors and Functional Improvements
    6266
    6367= 1.1.4 - 31/10/2022 =
  • weight-based-pricing-for-woocommerce/trunk/weight-based-pricing-woocommerce.php

    r2972088 r3147354  
    44 * Plugin URI: https://www.themeparrot.com/
    55 * Description: Weight Based Product Pricing for WooCommerce helps you to set product price based on the weight.
    6  * Version: 1.1.5
     6 * Version: 1.1.6
    77 * Author: Themeparrot
    88 * Author URI: https://themeparrot.com/
     
    1212 * Requires PHP: 5.6
    1313 * WC requires at least: 3.0.0
    14  * WC tested up to: 8.1.1
     14 * WC tested up to: 9.2.3
    1515 * License: GNU General Public License v3.0
    1616 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
     17 *
     18 * WC HPOS Compatibility: yes
    1719 */
    1820
     
    2123// This plugin constants
    2224defined('WWBP_PLUGIN_NAME') or define('WWBP_PLUGIN_NAME', 'Weight Based Pricing for WooCommerce');
    23 defined('WWBP_PLUGIN_VERSION') or define('WWBP_PLUGIN_VERSION', '1.1.5');
     25defined('WWBP_PLUGIN_VERSION') or define('WWBP_PLUGIN_VERSION', '1.1.6');
    2426
    2527defined('WWBP_PLUGIN_FILE') or define('WWBP_PLUGIN_FILE', __FILE__);
     
    4042require_once WWBP_PLUGIN_PATH . '/vendor/autoload.php';
    4143new WWBP\App\Boot(); // Start Plugin
     44
     45add_action( 'before_woocommerce_init', function() {
     46    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     47        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     48    }
     49} );
Note: See TracChangeset for help on using the changeset viewer.