예제 #1
0
파일: helper.php 프로젝트: RemiCollin/merx
/**
 * @return Cart|null
 */
function merx_current_cart()
{
    $cartId = session("merx_cart_id");
    if (!$cartId) {
        return null;
    }
    return Cart::where("id", $cartId)->first();
}
예제 #2
0
파일: Merx.php 프로젝트: RemiCollin/merx
 /**
  * @return Cart
  */
 private function getCartOrCreateNew()
 {
     $cart = merx_current_cart();
     if (!$cart) {
         $cart = Cart::create();
         session()->put("merx_cart_id", $cart->id);
     }
     return $cart;
 }
예제 #3
0
파일: helper.php 프로젝트: dvlpp/merx
/**
 * @return Cart|null
 */
function merx_current_cart()
{
    if (!config("merx.uses_session", true)) {
        // If Merx can't use the session, there is no way
        // he could find the current Cart from nowhere
        return null;
    }
    $cartId = session("merx_cart_id");
    if (!$cartId) {
        return null;
    }
    return Cart::find($cartId);
}
예제 #4
0
파일: Order.php 프로젝트: dvlpp/merx
 /**
  * @param Cart $cart
  * @param bool $checkIfEmpty
  * @throws CartClosedException
  * @throws EmptyCartException
  * @throws NoCurrentCartException
  */
 private static function checkCartIsValid($cart, $checkIfEmpty = false)
 {
     if (!$cart) {
         throw new NoCurrentCartException();
     }
     if (!$cart->isOpened()) {
         throw new CartClosedException();
     }
     if ($checkIfEmpty && $cart->isEmpty()) {
         throw new EmptyCartException();
     }
 }
예제 #5
0
 protected function createCartAndClient()
 {
     $cart = Cart::create();
     session()->put("merx_cart_id", $cart->id);
     $cart->addItem(new CartItem($this->itemAttributes()));
     $this->loginClient();
 }
예제 #6
0
파일: CartTest.php 프로젝트: dvlpp/merx
 private function newCart()
 {
     return Cart::create();
 }
예제 #7
0
파일: Merx.php 프로젝트: dvlpp/merx
 /**
  * @return Cart
  */
 private function newCart()
 {
     $cart = Cart::create();
     if (config("merx.uses_session", true)) {
         session()->put("merx_cart_id", $cart->id);
     }
     return $cart;
 }