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/Helpers/CartCheckoutHelper.php +31 -6 1.3.20 → 1.6.5 View file →
@@ -44,15 +44,25 @@
44 44 }
45 45
46 46 public static function make($disableCoupon = false): ?CartCheckoutHelper
47 47 {
48 - static $instance = null;
48 + if (!self::$instance) {
49 + self::$instance = new self($disableCoupon);
50 + }
49 51
50 - if (!$instance) {
51 - $instance = new self($disableCoupon);
52 - }
52 + return self::$instance;
53 + }
53 54
54 - return $instance;
55 + /**
56 + * Drop the request-scoped instance so the next make() re-initializes from
57 + * the current request's cart. Production runs one request per process and
58 + * never needs this; long-lived processes (the test suites) call it before
59 + * each dispatched request so a helper bound to an earlier cart cannot leak
60 + * into the next checkout.
61 + */
62 + public static function resetInstance(): void
63 + {
64 + self::$instance = false;
55 65 }
56 66
57 67
58 68 public function init()
@@ -934,7 +944,22 @@
934 944 if ($this->cart->order) {
935 945 return $this->cart->order->manual_discount_total;
936 946 }
937 947
938 - return (int)Arr::get($this->cart->checkout_data, 'manual_discount.amount', 0);
948 + return (int)Arr::get($this->cart->checkout_data, 'manual_discount.amount', 0)
949 + + (int)Arr::get($this->cart->checkout_data, 'upgrade_discount.amount', 0)
950 + + $this->getProrateCreditAmount();
951 + }
952 +
953 + public function getProrateCreditAmount()
954 + {
955 + if (empty($this->cart)) {
956 + return 0;
957 + }
958 +
959 + if ($this->cart->order) {
960 + return (int) Arr::get($this->cart->order->config, 'prorate_credit', 0);
961 + }
962 +
963 + return (int) Arr::get($this->cart->checkout_data, 'prorate_credit.amount', 0);
939 964 }
940 965 }