Plugin Directory

Changeset 3258560


Ignore:
Timestamp:
03/19/2025 01:38:14 PM (13 days ago)
Author:
woobewoo
Message:

version 2.1.4

Location:
woo-currency/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • woo-currency/trunk/classes/helpers/SxGeo.php

    r2398076 r3258560  
    2626    protected $m_idx_len;
    2727    protected $db_items;
     28    protected $id_len;
     29    protected $block_len;
     30    protected $max_region;
     31    protected $max_city;
     32    protected $max_country;
     33    protected $pack;
     34    protected $b_idx_len;
    2835    protected $country_size;
    2936    protected $db;
  • woo-currency/trunk/config.php

    r3226453 r3258560  
    4949
    5050    define('WCU_PLUGIN_INSTALLED', true);
    51     define('WCU_VERSION', '2.1.3');
     51    define('WCU_VERSION', '2.1.4');
    5252    define('WCU_DEV_VER', 1);
    5353    define('WCU_USER', 'user');
  • woo-currency/trunk/js/core.js

    r2395561 r3258560  
    390390    window.sessionStorage.clear();
    391391}
     392document.addEventListener('DOMContentLoaded', () => {
     393    if (wp && wp.data) {
     394        wp.data.subscribe(() => {
     395            wcuReplaceShippingCost(100);
     396        });
     397        jQuery(document.body).on('click', '.wc-block-components-panel__button', function() {
     398            wcuReplaceShippingCost(0);
     399            wcuReplaceShippingCost(100);
     400        });
     401    }
     402});
     403function wcuReplaceShippingCost ( tt ) {
     404    if (WCU_DATA.shippingCosts) {
     405        setTimeout(function () {
     406            for(var key in WCU_DATA.shippingCosts) {
     407                var $input = jQuery('.wc-block-components-radio-control__input[value="'+key+'"]');
     408                if ($input.length) {
     409                    $input.parent().find('.wc-block-formatted-money-amount').html(WCU_DATA.shippingCosts[key]);
     410                }
     411            }
     412        }, tt);
     413    }
     414}
  • woo-currency/trunk/modules/currency/mod.php

    r3203588 r3258560  
    2929    public $isYithProductAddon = false;
    3030    public $customCache = null;
     31    public $shippingCosts = false;
    3132
    3233    public static $orderId = null;
     
    163164        add_filter('woocommerce_hydration_dispatch_request', array($this, 'restApiRequest'), 9999, 4);
    164165    }
    165    
    166166    public function enableYithAddonConverter() {
    167167        $this->isYithProductAddon = true;
     
    288288        add_filter('woocommerce_cart_get_subtotal', array($this, 'getCurrencyPriceCart'), 9999);
    289289        add_filter('woocommerce_cart_get_total', array($this, 'getCurrencyPriceCart'), 9999);
     290        add_filter('woocommerce_cart_get_shipping_total', array($this, 'getShippingTotal'), 9999);
     291        add_filter('woocommerce_package_rates', array($this, 'calcShippingCosts'), 2);
    290292        add_action('woocommerce_calculate_totals', array($this, 'calcLineSubtotal'), 9999);
     293        dispatcherWcu::addFilter('jsInitVariables', array($this, 'addShippingCosts'));
     294    }
     295    public function addShippingCosts($js) {
     296        if (!empty($this->shippingCosts)) {
     297            $js['shippingCosts'] = $this->shippingCosts;
     298        }
     299        return $js;
     300    }
     301    public function calcShippingCosts($methods) {
     302        if (!has_block('woocommerce/cart') && !has_block('woocommerce/checkout')) {
     303            return $methods;
     304        }
     305        $costs = array();
     306        foreach ( $methods as $key => $method ) {
     307            if (!empty($method->cost)) {
     308                $costs[$key] = wc_price($method->cost);
     309            }
     310        }
     311        $this->shippingCosts = $costs;
     312        return $methods;
     313    }
     314    public function getShippingTotal($price) {
     315        if (!has_block('woocommerce/cart') && !has_block('woocommerce/checkout') && !$this->isBlocksAPI()) {
     316            return $price;
     317        }
     318        return $this->getModel()->getCurrencyPrice($price, null);
    291319    }
    292320    public function restApiRequest($response, $request, $path, $handler) {
     
    296324        return $response;
    297325    }
     326    public function isBlocksAPI(  ) {
     327        $uri = empty($_SERVER['REQUEST_URI']) ? '' : sanitize_text_field($_SERVER['REQUEST_URI']);
     328        return strpos( $uri, 'wp-json/wc/store/') && strpos( $uri, '/batch?');
     329    }
    298330    public function calcLineSubtotal( $cart ) {
    299         if (has_block('woocommerce/cart') || has_block('woocommerce/checkout')) {
     331        if (has_block('woocommerce/cart') || has_block('woocommerce/checkout') || $this->isBlocksAPI()) {
     332
    300333            foreach ( $cart->get_cart() as $key => $cartItem ) {
    301334                if (!empty($cartItem['line_subtotal']) && !empty($cart->cart_contents[$key])) {
     
    316349            }
    317350        }
    318         if (!has_block('woocommerce/cart') && !has_block('woocommerce/checkout')) {
     351        if (!has_block('woocommerce/cart') && !has_block('woocommerce/checkout') && !$this->isBlocksAPI()) {
    319352            return $price;
    320353        }
  • woo-currency/trunk/readme.txt

    r3226453 r3258560  
    44Donate link: https://woobewoo.com/product/woo-currency/
    55Tested up to: 6.7
    6 Stable tag: 2.1.3
     6Stable tag: 2.1.4
    77 
    88WBW Currency Switcher for WooCommerce allows customers to switch products prices to any currencies. Get rates converted in the real-time with dynamic currency switcher
     
    145145== Changelog ==
    146146
     147= 2.1.4 =
     148 * Fixed shipping total for cart-blocks
     149 * Fixed shipping costs for cart-blocks
     150 * Minor code fix
     151
    147152= 2.1.3 =
    148 * Minor code fix
     153 * Minor code fix
    149154
    150155= 2.1.2 =
    151 * Added compatibility with Woocommerce Checkout-block
    152 * Minor code fix
     156 * Added compatibility with Woocommerce Checkout-block
     157 * Minor code fix
    153158
    154159= 2.1.1 =
     
    156161
    157162= 2.1.0 =
    158 * Minor code fix
     163 * Minor code fix
    159164
    160165= 2.0.9 =
    161 * Fixed compatibility with WooCommerce PayPal Payments
     166 * Fixed compatibility with WooCommerce PayPal Payments
    162167
    163168= 2.0.8 =
    164 * Minor code fix
     169 * Minor code fix
    165170
    166171= 2.0.7 =
  • woo-currency/trunk/wcu.php

    r3226453 r3258560  
    33 * Plugin Name: WBW Currency Switcher for WooCommerce
    44 * Description: WBW Currency Switcher for WooCommerce allows the customers switch products prices to any currencies. Get rates converted in the real time with dynamic currency switcher
    5  * Version: 2.1.3
     5 * Version: 2.1.4
    66 * Author: woobewoo
    77 * Author URI: https://woobewoo.com
    88 * WC requires at least: 3.4.0
    9  * WC tested up to: 9.6.0
     9 * WC tested up to: 9.7.1
    1010 * Text Domain: woo-currency
    1111 * Domain Path: /languages
Note: See TracChangeset for help on using the changeset viewer.