You are here

interface CartInterface in Ubercart 8.4

Represents a shopping cart.

Hierarchy

Expanded class hierarchy of CartInterface

All classes that implement CartInterface

4 files declare their use of CartInterface
CartCheckoutTest.php in uc_cart/tests/src/Functional/CartCheckoutTest.php
CartForm.php in uc_cart/src/Form/CartForm.php
CheckoutController.php in uc_cart/src/Controller/CheckoutController.php
uc_cart.module in uc_cart/uc_cart.module
Handles all things concerning Ubercart's shopping cart.

File

uc_cart/src/CartInterface.php, line 8

Namespace

Drupal\uc_cart
View source
interface CartInterface {

  /**
   * Time in seconds after which a cart order is deemed abandoned.
   *
   * Default is 86400 seconds / 24 hours.
   */
  const ORDER_TIMEOUT = 86400;

  /**
   * Time in seconds after which the checkout page is deemed abandoned.
   *
   * Default is 1800 seconds / 30 minutes.
   */
  const CHECKOUT_TIMEOUT = 1800;

  /**
   * Returns the unique ID for the cart.
   *
   * @return string
   *   The cart ID.
   */
  public function getId();

  /**
   * Returns the items in the shopping cart.
   *
   * @return \Drupal\uc_cart\CartItemInterface[]
   *   The items.
   */
  public function getContents();

  /**
   * Adds an item to the cart.
   *
   * @param int $nid
   *   Node ID to add to cart.
   * @param int $qty
   *   Quantity to add to cart.
   * @param array $data
   *   Array of module-specific data to add to cart.
   * @param bool $msg
   *   Whether to display a message upon adding an item to the cart.
   *
   * @return \Drupal\Core\Url
   *   A URL to redirect to.
   */
  public function addItem($nid, $qty = 1, array $data = NULL, $msg = TRUE);

  /**
   * Empties a cart of its contents.
   */
  public function emptyCart();

  /**
   * Determines whether a cart contains shippable items or not.
   *
   * @return bool
   *   TRUE if the cart contains at least one shippable item, FALSE otherwise.
   */
  public function isShippable();

}

Members

Namesort descending Modifiers Type Description Overrides
CartInterface::addItem public function Adds an item to the cart. 1
CartInterface::CHECKOUT_TIMEOUT constant Time in seconds after which the checkout page is deemed abandoned.
CartInterface::emptyCart public function Empties a cart of its contents. 1
CartInterface::getContents public function Returns the items in the shopping cart. 1
CartInterface::getId public function Returns the unique ID for the cart. 1
CartInterface::isShippable public function Determines whether a cart contains shippable items or not. 1
CartInterface::ORDER_TIMEOUT constant Time in seconds after which a cart order is deemed abandoned.