Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Model/Cart/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Model/Cart/Info.php
<?php

declare(strict_types=1);

namespace StripeIntegration\Payments\Model\Cart;

class Info
{
    private $checkoutFlow;
    private $subscriptionProductFactory;

    // Data
    private $quote = null;

    // State
    private $hasSubscriptions = false;
    private $hasTrialSubscriptions = false;
    private $hasFutureStartDateSubscriptions = false;
    private $hasRegularProducts = false;

    // True when no payment will be collected today, regardless of whether the cart includes subscriptions or not
    private $isZeroTotal = true;

    public function __construct(
        \StripeIntegration\Payments\Model\Checkout\Flow $checkoutFlow,
        \StripeIntegration\Payments\Model\SubscriptionProductFactory $subscriptionProductFactory
    )
    {
        $this->checkoutFlow = $checkoutFlow;
        $this->subscriptionProductFactory = $subscriptionProductFactory;
    }

    private function reset()
    {
        $this->hasSubscriptions = false;
        $this->hasTrialSubscriptions = false;
        $this->hasFutureStartDateSubscriptions = false;
        $this->hasRegularProducts = false;
        $this->isZeroTotal = true;
    }

    public function setQuote($quote)
    {
        if ($quote == $this->quote)
        {
            return;
        }
        else
        {
            $this->quote = $quote;
            $this->reset();
        }

        foreach ($quote->getAllItems() as $item)
        {
            $subscriptionProductModel = $this->subscriptionProductFactory->create()->fromQuoteItem($item);
            if ($subscriptionProductModel->isSubscriptionProduct())
            {
                $this->hasSubscriptions = true;

                if ($subscriptionProductModel->hasTrialPeriod())
                {
                    $this->hasTrialSubscriptions = true;
                }

                if ($subscriptionProductModel->startsOnStartDate() && !$subscriptionProductModel->startDateIsToday())
                {
                    $this->hasFutureStartDateSubscriptions = true;
                    $this->checkoutFlow->isFutureSubscriptionSetup = true;
                }

                if (!$subscriptionProductModel->hasZeroInitialOrderPrice())
                {
                    // todo: a subscription's price could be zero
                    $this->isZeroTotal = false;
                }
            }
            else
            {
                $this->hasRegularProducts = true;

                if ($item->getRowTotal() > 0)
                {
                    $this->isZeroTotal = false;
                }
            }
        }
    }

    public function hasSubscriptions()
    {
        return $this->hasSubscriptions;
    }

    public function hasTrialSubscriptions()
    {
        return $this->hasTrialSubscriptions;
    }

    public function hasFutureStartDateSubscriptions()
    {
        return $this->hasFutureStartDateSubscriptions;
    }

    public function hasRegularProducts()
    {
        return $this->hasRegularProducts;
    }

    public function isZeroTotal()
    {
        return $this->isZeroTotal;
    }

    public function isZeroTotalSubscriptionSetup()
    {
        return $this->isZeroTotal &&
            ($this->hasTrialSubscriptions || $this->hasFutureStartDateSubscriptions);
    }
}

Spamworldpro Mini