<?php

namespace Drupal\bee\Resolvers;

use Drupal\commerce\Context;
use Drupal\commerce_cart\CartProviderInterface;
use Drupal\commerce\PurchasableEntityInterface;
use Drupal\commerce_price\Resolver\PriceResolverInterface;



use Drupal\Core\Access\AccessResult;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
use Drupal\commerce_cart\CartSession;
use Drupal\commerce_cart\CartSessionInterface;
use Drupal\commerce_checkout\CheckoutOrderManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;


/**
 * Resolve price for BEE nodes.
 *
 * @package Drupal\bee\Resolvers
 */
class SalepriceResolver implements PriceResolverInterface {



  /**
   * The cart provider.
   *
   * @var Drupal\commerce_cart\CartProviderInterface
   */
  protected $cartProvider;

  /**
   * Constructs a new CartController object.
   *
   * @param Drupal\commerce_cart\CartProviderInterface $cart_provider
   *   The cart provider.
   */
  // public function __construct(CartProviderInterface $cart_provider) {
  //   $this->cartProvider = $cart_provider;
  // }

  /**
    * {@inheritdoc}
    */
  // public static function create(ContainerInterface $container) {
  //   return new static(
  //     $container->get('commerce_cart.cart_provider'),
  //   );
  // }

  /**
   * {@inheritdoc}
   */
  public function resolve(PurchasableEntityInterface $entity, $quantity, Context $context) {

    if ($entity->bundle() != 'bee') {
      return;
    }

    $store = $context->getStore();

    // if ($cart = $this->cartProvider->getCart('default', $store)) {
    //   $order_items = $cart->getItems();
    //   foreach ($order_items as $order_item) {
    //     if ($order_item->bundle() == 'bee') {
    //       return $order_item->getUnitPrice();
    //     }
    //   }
    // }
  }

}
