| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | use FluentCart\App\Models\Customer; |
| 12 | 12 | use FluentCart\App\Models\ProductVariation; |
| 13 | 13 | use FluentCart\App\Models\User; |
| 14 | 14 | use FluentCart\App\Services\DateTime\DateTime; |
| 15 | +use FluentCart\App\Services\Payments\PaymentHelper; | |
| 15 | 16 | use FluentCart\App\Services\Localization\LocalizationManager; |
| 16 | 17 | use FluentCart\App\Services\Translations\TransStrings; |
| 17 | 18 | use FluentCart\App\Services\URL; |
| 18 | 19 | use FluentCart\Framework\Http\URL as BaseUrl; |
| @@ -608,10 +609,12 @@ | ||
| 608 | 609 | if (!$user) { |
| 609 | 610 | return null; |
| 610 | 611 | } |
| 611 | 612 | |
| 613 | + // Identity only — see CustomerResource::getCurrentCustomer() for why an | |
| 614 | + // email match must never reach a customer row. | |
| 612 | 615 | return Customer::query()->where('user_id', $user->ID) |
| 613 | - ->orWhere('email', $user->user_email) | |
| 616 | + ->orderBy('id', 'ASC') | |
| 614 | 617 | ->first(); |
| 615 | 618 | } |
| 616 | 619 | |
| 617 | 620 | /** |
| @@ -1401,14 +1404,16 @@ | ||
| 1401 | 1404 | $month = (int) Arr::get($anchor, 'month', 0); |
| 1402 | 1405 | |
| 1403 | 1406 | if ($month && $day) { |
| 1404 | 1407 | /* translators: %s is a date, e.g. "on Aug 19" */ |
| 1405 | - return sprintf(__('on %s', 'fluent-cart'), gmdate('M', gmmktime(12, 0, 0, $month, 1, 2001)) . ' ' . $day); | |
| 1408 | + // wp_date(), not gmdate(): gmdate() has no locale, so this month | |
| 1409 | + // name stayed English inside an otherwise translated sentence. | |
| 1410 | + return sprintf(__('on %s', 'fluent-cart'), wp_date('M', gmmktime(12, 0, 0, $month, 1, 2001), new \DateTimeZone('UTC')) . ' ' . $day); | |
| 1406 | 1411 | } |
| 1407 | 1412 | |
| 1408 | 1413 | if ($month) { |
| 1409 | 1414 | /* translators: %s is a month name, e.g. "in August" */ |
| 1410 | - return sprintf(__('in %s', 'fluent-cart'), gmdate('F', gmmktime(12, 0, 0, $month, 1, 2001))); | |
| 1415 | + return sprintf(__('in %s', 'fluent-cart'), wp_date('F', gmmktime(12, 0, 0, $month, 1, 2001), new \DateTimeZone('UTC'))); | |
| 1411 | 1416 | } |
| 1412 | 1417 | |
| 1413 | 1418 | /* translators: %s is an ordinal day of month, e.g. "on the 10th" */ |
| 1414 | 1419 | return sprintf(__('on the %s', 'fluent-cart'), gmdate('jS', gmmktime(12, 0, 0, 1, $day, 2001))); |
| @@ -1923,26 +1928,9 @@ | ||
| 1923 | 1928 | } |
| 1924 | 1929 | |
| 1925 | 1930 | public static function subscriptionIntervalInDays($interval) |
| 1926 | 1931 | { |
| 1927 | - switch ($interval) { | |
| 1928 | - case 'daily': | |
| 1929 | - return 1; | |
| 1930 | - case 'weekly': | |
| 1931 | - return 7; | |
| 1932 | - case 'monthly': | |
| 1933 | - return 30; | |
| 1934 | - case 'quarterly': | |
| 1935 | - return 90; | |
| 1936 | - case 'half_yearly': | |
| 1937 | - return 182; | |
| 1938 | - case 'yearly': | |
| 1939 | - return 365; | |
| 1940 | - default: | |
| 1941 | - return apply_filters('fluent_cart/subscription_interval_in_days', 0, [ | |
| 1942 | - 'interval' => $interval, | |
| 1943 | - ]); | |
| 1944 | - } | |
| 1932 | + return PaymentHelper::getIntervalDays($interval); | |
| 1945 | 1933 | } |
| 1946 | 1934 | |
| 1947 | 1935 | public static function parseTermIdsForFilter($filters): array |
| 1948 | 1936 | { |
| @@ -1997,12 +1985,12 @@ | ||
| 1997 | 1985 | { |
| 1998 | 1986 | $allChildVariants = Arr::pluck($variants, 'other_info.bundle_child_ids'); |
| 1999 | 1987 | |
| 2000 | 1988 | $allChildVariants = array_unique(Arr::flatten($allChildVariants)); |
| 2001 | - $allChildVariants = Arr::except( | |
| 1989 | + $allChildVariants = array_values(array_diff( | |
| 2002 | 1990 | $allChildVariants, |
| 2003 | 1991 | Arr::pluck($variants, 'id') |
| 2004 | - ); | |
| 1992 | + )); | |
| 2005 | 1993 | $allChildVariants = array_filter($allChildVariants); |
| 2006 | 1994 | $childVariants = ProductVariation::query() |
| 2007 | 1995 | ->whereIn('id', $allChildVariants) |
| 2008 | 1996 | ->with('product:ID,post_title') |