Plugin Directory


Ignore:
Timestamp:
10/14/2026 01:03:30 PM (6 days ago)
Author:
adreastrian
Message:

releasing v2.0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fluent-cart/trunk/app/Models/Subscription.php

    r3719064 r3746418  
    33namespace FluentCart\App\Models;
    44
    5 use FluentCart\Api\CurrencySettings;
     5use FluentCart\App\Modules\MultiCurrency\Services\BaseCurrency;
     6use FluentCart\App\Modules\MultiCurrency\Services\CurrencySnapshot;
    67use FluentCart\Api\StoreSettings;
    78use FluentCart\App\App;
    … …  
    5152        'product_id',
    5253        'item_name',
     54        'currency',
    5355        'variation_id',
    5456        'billing_interval',
    … …  
    8486                $model->uuid = md5(time() . wp_generate_uuid4());
    8587            }
     88
     89            // Currency column + the parent order's snapshot, which renewals carry.
     90            CurrencySnapshot::applyToNewSubscription($model);
    8691        });
    8792    }
    … …  
    418423    public function getCurrencyAttribute(): string
    419424    {
    420         $currency = '';
    421 
    422         if (empty($this->config)) {
    423             // get from store settings
    424             $currency = CurrencySettings::get('currency');
    425             return strtoupper($currency);
    426         }
    427 
    428         $definedCurrency = Arr::get($this->config, 'currency', '');
    429 
    430         if(empty($definedCurrency)) {
    431             $currency = CurrencySettings::get('currency');
    432             return strtoupper($currency);
    433         }
    434 
    435         return strtoupper($definedCurrency);
     425        $column = (string) Arr::get($this->attributes, 'currency', '');
     426        if ($column !== '') {
     427            return strtoupper($column);
     428        }
     429
     430        $definedCurrency = Arr::get((array) $this->config, 'currency', '');
     431        if ($definedCurrency) {
     432            return strtoupper($definedCurrency);
     433        }
     434
     435        // Not CurrencySettings::get(): on storefront requests that is the visitor's currency
     436        $parentCurrency = $this->parent_order_id
     437            ? Order::query()->where('id', $this->parent_order_id)->value('currency')
     438            : '';
     439        if ($parentCurrency) {
     440            return strtoupper($parentCurrency);
     441        }
     442
     443        return BaseCurrency::get();
    436444    }
    437445
Note: See TracChangeset for help on using the changeset viewer.