PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
← All changes | app/Services/ShortCodeParser/Parsers/SubscriptionParser.php +11 -2 1.5.4 → 1.6.5 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace FluentCart\App\Services\ShortCodeParser\Parsers;
4 4
5 5 use FluentCart\App\Helpers\Helper;
6 +use FluentCart\App\Services\DateTime\DateFormatter;
6 7 use FluentCart\Framework\Support\Arr;
7 8
8 9 class SubscriptionParser extends BaseParser
9 10 {
@@ -8,11 +9,19 @@
8 9 class SubscriptionParser extends BaseParser
9 10 {
10 11 private $subscription;
11 12
13 + /**
14 + * Only used as the timezone context for DateFormatter — the order carries the
15 + * user_tz captured at checkout. Null when the shortcode runs without one, in
16 + * which case DateFormatter falls back to UTC.
17 + */
18 + private $order;
19 +
12 20 public function __construct($data)
13 21 {
14 22 $this->subscription = Arr::get($data, 'subscription');
23 + $this->order = Arr::get($data, 'order');
15 24 parent::__construct($data);
16 25 }
17 26
18 27 public function parse($accessor = null, $code = null, $transformer = null): ?string
@@ -39,9 +48,9 @@
39 48 case 'payment_info':
40 49 return wp_kses_post($subscription->payment_info);
41 50 case 'next_billing_date':
42 51 return $subscription->next_billing_date
43 - ? esc_html(date('M j, Y', strtotime($subscription->next_billing_date)))
52 + ? esc_html(DateFormatter::format($subscription->next_billing_date, false, $this->order))
44 53 : __('N/A', 'fluent-cart');
45 54 case 'bill_times':
46 55 return $subscription->bill_times
47 56 ? esc_html($subscription->bill_times)
@@ -51,9 +60,9 @@
51 60 case 'trial_days':
52 61 return esc_html($subscription->trial_days ?: '0');
53 62 case 'expire_at':
54 63 return $subscription->expire_at
55 - ? esc_html(date('M j, Y', strtotime($subscription->expire_at)))
64 + ? esc_html(DateFormatter::format($subscription->expire_at, false, $this->order))
56 65 : __('Never', 'fluent-cart');
57 66 default:
58 67 return Arr::get((array) $subscription, $accessor, '');
59 68 }