Merge pull request #2450 from shubhwebkul/velocity-updated

misc. updates
This commit is contained in:
Jitendra Singh 2020-02-13 12:41:58 +05:30 committed by GitHub
commit 92d50b76bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 221 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
{
"/js/velocity.js": "/js/velocity.js?id=7f746af03035ad1a9a1f",
"/js/velocity.js": "/js/velocity.js?id=384363a24374735154d8",
"/css/velocity-admin.css": "/css/velocity-admin.css?id=612d35e452446366eef7",
"/css/velocity.css": "/css/velocity.css?id=aa8d76055810af176fc3"
"/css/velocity.css": "/css/velocity.css?id=ad57fd83b1d077b91c24"
}

View File

@ -206,5 +206,20 @@ class Helper extends Review
return [];
}
public function formatCartItem($item)
{
$product = $item->product;
$images = $product->getTypeInstance()->getBaseImage($item);
return [
'images' => $images,
'itemId' => $item->id,
'name' => $item->name,
'url_key' => $product->url_key,
'quantity' => $item->quantity,
'baseTotal' => core()->currency($item->base_total),
];
}
}

View File

@ -2,8 +2,9 @@
namespace Webkul\Velocity\Http\Controllers\Shop;
use Webkul\Velocity\Helpers\Helper;
use Cart;
use Webkul\Velocity\Http\Shop\Controllers;
use Webkul\Checkout\Contracts\Cart as CartModel;
use Webkul\Product\Repositories\SearchRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRepository;
@ -231,4 +232,71 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
])->render(),
];
}
/**
* Function for guests user to add the product in the cart.
*
* @return Mixed
*/
public function addProductToCart()
{
try {
$cart = Cart::getCart();
$formattedBeforeItems = [];
$id = request()->get('product_id');
$velocityHelper = app('Webkul\Velocity\Helpers\Helper');
if ($cart) {
$beforeItems = $cart->items;
foreach ($beforeItems as $item) {
array_push($formattedBeforeItems, $velocityHelper->formatCartItem($item));
}
}
$cart = Cart::addProduct($id, request()->all());
if (is_array($cart) && isset($cart['warning'])) {
$response = [
'status' => 'warning',
'message' => $cart['warning'],
];
}
if ($cart instanceof CartModel) {
$items = $cart->items;
$formattedItems = [];
foreach ($items as $item) {
array_push($formattedItems, $velocityHelper->formatCartItem($item));
}
$response = [
'status' => 'success',
'totalCartItems' => sizeof($items),
'addedItems' => array_slice($formattedItems, sizeof($formattedBeforeItems)),
'message' => trans('shop::app.checkout.cart.item.success'),
];
if ($customer = auth()->guard('customer')->user())
$this->wishlistRepository->deleteWhere(['product_id' => $id, 'customer_id' => $customer->id]);
if (request()->get('is_buy_now'))
return redirect()->route('shop.checkout.onepage.index');
}
} catch(\Exception $exception) {
$product = $this->productRepository->find($id);
$response = [
'status' => 'false',
'message' => trans($exception->getMessage()),
'redirectionRoute' => route('shop.productOrCategory.index', $product->url_key),
];
}
return $response ?? [
'status' => 'error',
'message' => trans('velocity::app.error.something-went-wrong'),
];
}
}

View File

@ -14,5 +14,7 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
Route::get('/category-details', 'ShopController@categoryDetails')->name('velocity.category.details');
Route::get('/fancy-category-details/{slug}', 'ShopController@fetchFancyCategoryDetails')->name('velocity.fancy.category.details');
Route::post('/cart/add', 'ShopController@addProductToCart')->name('velocity.cart.add.product');
});
});

View File

@ -0,0 +1,90 @@
<template>
<form method="POST" @submit.prevent="addToCart">
<button
type="submit"
:disabled="isButtonEnable == 'false'"
:class="`btn btn-add-to-cart ${addClassToBtn}`">
<i class="material-icons text-down-3" v-if="showCartIcon">shopping_cart</i>
<span class="fs14 fw6 text-uppercase text-up-4" v-text="btnText"></span>
</button>
</form>
</template>
<script type="text/javascript">
export default {
props: [
'form',
'btnText',
'isEnable',
'csrfToken',
'productId',
'showCartIcon',
'addClassToBtn',
],
data: function () {
return {
'qtyText': this.__('checkout.qty'),
'isButtonEnable': this.isEnable,
}
},
methods: {
'addToCart': function () {
this.isButtonEnable = false;
let url = `${this.$root.baseUrl}/cart/add`;
this.$http.post(url, {
'quantity': 1,
'_token': this.csrfToken,
'product_id': this.productId,
})
.then(response => {
this.isButtonEnable = true;
if (response.data.status) {
response.data.addedItems.forEach(item => {
let cartItemHTML = `<div class="row small-card-container">
<div class="col-3 product-image-container mr15">
<a href="${this.$root.baseUrl}/checkout/cart/remove/${item.itemId}">
<span class="rango-close"></span>
</a>
<a
href="${this.$root.baseUrl}/${item.url_key}"
class="unset">
<div class="product-image"
style="background-image: url('${item.images['small_image_url']}');">
</div>
</a>
</div>
<div class="col-9 no-padding card-body align-vertical-top">
<div class="no-padding">
<div class="fs16 text-nowrap fw6">${item.name}</div>
<div class="fs18 card-current-price fw6">
<div class="display-inbl">
<label class="fw5">${this.qtyText}</label>
<input type="text" disabled value="${item.quantity}" class="ml5" />
</div>
<span class="card-total-price fw6">${item.baseTotal}</span>
</div>
</div>
</div>
</div>`;
$('#cart-modal-content .mini-cart-container').append(cartItemHTML);
$('.mini-cart-container .badge').text(response.data.totalCartItems);
});
}
})
.catch(error => {
console.log("something went wrong");
})
}
}
}
</script>

View File

@ -32,6 +32,7 @@ window.Carousel = VueCarousel;
// UI components
Vue.component("vue-slider", require("vue-slider-component"));
Vue.component('modal-component', require('./UI/components/modal'));
Vue.component("add-to-cart", require("./UI/components/add-to-cart"));
Vue.component('quantity-btn', require('./UI/components/quantity-btn'));
Vue.component('sidebar-component', require('./UI/components/sidebar'));
Vue.component("product-card", require("./UI/components/product-card"));

View File

@ -1005,6 +1005,25 @@
}
}
}
&.profile-page-content {
.table {
padding: 0;
width: 800px;
margin-bottom: 15px;
}
.table > table {
width:100%;
color: #5E5E5E;
border: 1px solid rgba(0,0,0,.125);
}
.table td {
border: unset;
padding: 6px 12px;
}
}
}
.account-items-list {
@ -1268,7 +1287,7 @@
}
button {
margin: 20px 0;
margin: 20px 0 30px 0;
}
.applied-coupon-details {
@ -1364,7 +1383,7 @@
.payment-form,
.review-checkout-conainer {
h3 {
margin-bottom: 30px;
margin-bottom: 20px;
}
.shipping-methods,

View File

@ -50,6 +50,7 @@ return [
'error' => [
'go-to-home' => 'الذهاب إلى المنزل',
'page-lost-short' => 'الصفحة فقدت المحتوى',
'something-went-wrong' => 'هناك خطأ ما',
'page-lost-description' => "الصفحة التي تبحث عنها غير متوفرة. حاول البحث مرة أخرى أو استخدم زر العودة للخلف أدناه.",
],

View File

@ -213,6 +213,7 @@ return [
'error' => [
'go-to-home' => 'Go to home',
'page-lost-short' => 'Page lost content',
'something-went-wrong' => 'something went wrong',
'page-lost-description' => "The page you're looking for isn't available. Try to search again or use the Go Back button below.",
],

View File

@ -49,6 +49,7 @@ return [
'error' => [
'go-to-home' => 'Vá para casa',
'something-went-wrong' => 'algo deu errado',
'page-lost-short' => 'Conteúdo perdido da página',
'page-lost-description' => "A página que você está procurando não está disponível. Tente pesquisar novamente ou use o botão Voltar atrás abaixo.",
],

View File

@ -140,7 +140,7 @@
:title="'{{ __('shop::app.checkout.onepage.shipping-address') }}'">
<div class="form-header mb-30" slot="header">
<h3 class="fw6 display-inbl mb-0">
<h3 class="fw6 display-inbl">
{{ __('shop::app.checkout.onepage.shipping-address') }}
</h3>
<i class="rango-arrow"></i>
@ -219,7 +219,7 @@
:title="'{{ __('shop::app.checkout.onepage.shipping-address') }}'">
<div class="form-header" slot="header">
<h3 class="fw6 display-inbl mb-0">
<h3 class="fw6 display-inbl">
{{ __('shop::app.checkout.onepage.shipping-address') }}
</h3>
<i class="rango-arrow"></i>

View File

@ -11,6 +11,7 @@
<input
type="text"
class="control"
style="width: unset;"
v-validate="'required'"
id="shipping[first_name]"
name="shipping[first_name]"

View File

@ -9,20 +9,6 @@
.account-head {
height: 50px;
}
.table {
width: 70%;
padding: 10px;
}
.table > table {
color: #5E5E5E;
width:100%;
border: 1px solid rgba(0,0,0,.125);
}
.table td {
padding: 5px;
border: unset;
display: table-cell !important;
}
.remove-icon {
right: 15px;
font-size: 22px;
@ -43,7 +29,7 @@
@section('page-detail-wrapper')
<div class="account-head">
<div class="account-head mb-0">
<span class="back-icon">
<a href="{{ route('customer.account.index') }}">
<i class="icon icon-menu-back"></i>
@ -64,7 +50,7 @@
{!! view_render_event('bagisto.shop.customers.account.profile.view.before', ['customer' => $customer]) !!}
<div class="account-table-content">
<div class="account-table-content profile-page-content">
<div class="table">
<table>
<tbody>

View File

@ -39,6 +39,16 @@
</span>
</button>
</form>
{{-- <add-to-cart
form="true"
csrf-token='{{ csrf_token() }}'
product-id="{{ $product->product_id }}"
add-class-to-btn="{{ $addToCartBtnClass ?? '' }}"
is-enable={{ ! $product->isSaleable() ? 'false' : 'true' }}
show-cart-icon={{ !(isset($showCartIcon) && !$showCartIcon) }}
btn-text="{{ $btnText ?? __('shop::app.products.add-to-cart') }}">
</add-to-cart> --}}
@endif
</div>