mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
This commit is contained in:
parent
fc785c4db3
commit
108b9f35d0
@ -198,9 +198,15 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
|
||||
public function addCart($item, $quantity = 1)
|
||||
{
|
||||
$cart = $this->dispatch(new GetCart());
|
||||
$cart->add($item, $quantity);
|
||||
return $this->dispatch(new GetCart());
|
||||
if(Auth::user())
|
||||
{
|
||||
$cart = $this->dispatch(new GetCart());
|
||||
$cart->add($item, $quantity);
|
||||
return $this->dispatch(new GetCart());
|
||||
} else {
|
||||
setcookie("cart[" . $item->id . "]", $quantity, time() + 3600, '/', NULL, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -812,9 +812,8 @@ class AdvsController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
public function advAddCart($id)
|
||||
public function advAddCart($id, $quantity = 1)
|
||||
{
|
||||
$quantity = 1;
|
||||
$thisModel = new AdvModel();
|
||||
$adv = $thisModel->isAdv($id);
|
||||
$response = array();
|
||||
@ -825,7 +824,7 @@ class AdvsController extends PublicController
|
||||
$response['status'] = "error";
|
||||
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
|
||||
}
|
||||
return redirect('/cart/');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function addCart(Request $request)
|
||||
|
||||
@ -2711,7 +2711,6 @@ a.verified i {
|
||||
}
|
||||
|
||||
.user-account input {
|
||||
height: 44px;
|
||||
margin-bottom: 30px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
@ -119,43 +119,48 @@
|
||||
|
||||
|
||||
{% if entries('advs').isEnabled('carts') %}
|
||||
{% set cart_items = entries('carts').getCart() %}
|
||||
{% set cart = entries('carts').get()[0] %}
|
||||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-shopping-cart"></i> {{ cart_items.quantity }}<span
|
||||
class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-cart" role="menu">
|
||||
<!--items cart-->
|
||||
{% for item_cart in cart_items.items(1) %}
|
||||
<li>
|
||||
<span class="cart-item">
|
||||
<a href="{{ item_cart.detail_url }}">
|
||||
<span class="cart-item-left">
|
||||
<img src="{{ item_cart.cover_photo }}" alt="{{ item_cart.name }}"
|
||||
height="50"
|
||||
width="70"
|
||||
class="item-cart-img">
|
||||
<span class="item-name">{{ item_cart.name }}</span>
|
||||
<span class="item-price">{{ item_cart.priceFormat(item_cart) }}</span>
|
||||
<span class="item-quantity">{{ trans('visiosoft.module.advs::field.quantity') }}: {{ item_cart.quantity }}</span>
|
||||
</span>
|
||||
{% if auth_check() %}
|
||||
{% set cart_items = entries('carts').getCart() %}
|
||||
{% set cart = entries('carts').get()[0] %}
|
||||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-shopping-cart"></i> {{ cart_items.quantity }}<span
|
||||
class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-cart" role="menu">
|
||||
<!--items cart-->
|
||||
{% for item_cart in cart_items.items(1) %}
|
||||
<li>
|
||||
<span class="cart-item">
|
||||
<a href="{{ item_cart.detail_url }}">
|
||||
<span class="cart-item-left">
|
||||
<img src="{{ item_cart.cover_photo }}" alt="{{ item_cart.name }}"
|
||||
height="50"
|
||||
width="70"
|
||||
class="item-cart-img">
|
||||
<span class="item-name">{{ item_cart.name }}</span>
|
||||
<span class="item-price">{{ item_cart.priceFormat(item_cart) }}</span>
|
||||
<span class="item-quantity">{{ trans('visiosoft.module.advs::field.quantity') }}: {{ item_cart.quantity }}</span>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li class="cart-footer">
|
||||
<span class="lighter-text">{{ trans('visiosoft.module.advs::field.total') }}:</span>
|
||||
<span class="total-color-text">{% if cart_items is null %}0{% else %}{{ cart.subtotal.currency }}{% endif %}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li class="cart-footer">
|
||||
<span class="lighter-text">{{ trans('visiosoft.module.advs::field.total') }}:</span>
|
||||
<span class="total-color-text">{% if cart_items is null %}0{% else %}{{ cart.subtotal.currency }}{% endif %}</span>
|
||||
</li>
|
||||
<!--items cart-->
|
||||
<li><span><a class="text-center cart-view-button"
|
||||
href="/cart">{{ trans('visiosoft.module.advs::field.view_cart') }}</a></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<!--items cart-->
|
||||
<li><span><a class="text-center cart-view-button"
|
||||
href="/cart">{{ trans('visiosoft.module.advs::field.view_cart') }}</a></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
{% include "visiosoft.module.carts::nav" %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
<li class="new-ads-navigation-field"><a href="/advs/create_adv"
|
||||
@ -192,4 +197,4 @@
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
</header>
|
||||
|
||||
@ -9,6 +9,9 @@ use Anomaly\UsersModule\User\Event\UserWasLoggedIn;
|
||||
use Anomaly\UsersModule\User\User;
|
||||
use Anomaly\UsersModule\User\UserPassword;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\AdvsModule\Http\Controller\AdvsController;
|
||||
use Visiosoft\CartsModule\Saleitem\Command\ProcessSaleitem;
|
||||
use Visiosoft\CartsModule\Saleitem\SaleitemModel;
|
||||
use Visiosoft\CloudsiteModule\Site\Event\CreateSite;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
@ -99,6 +102,15 @@ class UserAuthenticator
|
||||
if ($response = $this->authenticate($credentials)) {
|
||||
if ($response instanceof UserInterface) {
|
||||
$this->login($response, $remember);
|
||||
if(isset($_COOKIE['cart']))
|
||||
{
|
||||
foreach ($_COOKIE['cart'] as $adv => $quantity)
|
||||
{
|
||||
$advs = new AdvsController();
|
||||
$advs->advAddCart($adv,$quantity);
|
||||
setcookie("cart[" . $adv . "]", null, -1, '/');
|
||||
}
|
||||
}
|
||||
return Redirect::back();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user