Base sync

This commit is contained in:
Prashant Singh 2019-09-11 03:11:55 +05:30
commit 1e22e61282
18 changed files with 119 additions and 38 deletions

View File

@ -30,6 +30,7 @@ return [
'locale-based' => 'Locale based',
'channel-based' => 'Channel based',
'status' => 'Status',
'select-option' => 'Select option',
'common' => [
'no-result-found' => 'We could not find any records.',

View File

@ -188,7 +188,7 @@
<!-- Cart Attributes -->
<div class="control-container mt-20" v-for="(condition, index) in conditions_list" :key="index">
<select class="control" name="cart_attributes[]" v-model="conditions_list[index].attribute" title="You Can Make Multiple Selections Here" style="margin-right: 15px; width: 30%;" v-on:change="enableCondition($event, index)">
<option disabled="disabled">{{ __('admin::app.promotion.select-attribtue', ['attrbibute' => 'Option']) }}</option>
<option disabled="disabled">{{ __('admin::app.select-option') }}</option>
<option v-for="(cart_ip, index1) in cart_input" :value="cart_ip.code" :key="index1">@{{ cart_ip.name }}</option>
</select>
@ -199,7 +199,7 @@
<div v-if='conditions_list[index].attribute == "shipping_state"'>
<select class="control" v-model="conditions_list[index].value">
<option disabled="disabled">{{ __('admin::app.promotion.select-attribtue', ['attrbibute' => 'State']) }}</option>
<option disabled="disabled">{{ __('admin::app.select-option') }}</option>
<optgroup v-for='(state, code) in country_and_states.states' :label="code">
<option v-for="(stateObj, index) in state" :value="stateObj.code">@{{ stateObj.default_name }}</option>
</optgroup>
@ -208,7 +208,7 @@
<div v-if='conditions_list[index].attribute == "shipping_country"'>
<select class="control" v-model="conditions_list[index].value">
<option disabled="disabled">{{ __('admin::app.promotion.select-attribtue', ['attrbibute' => 'Country']) }}</option>
<option disabled="disabled">{{ __('admin::app.select-option']) }}</option>
<option v-for="(country, index) in country_and_states.countries" :value="country.code">@{{ country.name }}</option>
</select>
</div>

View File

@ -223,23 +223,18 @@
starts_from: null,
per_customer: 0,
status: 1,
use_coupon: null,
auto_generation: false,
usage_limit: 0,
action_type: null,
apply: null,
apply_amt: false,
apply_prct: false,
apply_to_shipping: 0,
disc_amount: null,
end_other_rules: 0,
all_conditions: [],
all_attributes: {
'categories' : null,
'attributes' : null
'categories' : [],
'attributes' : []
},
criteria: 'cart',

View File

@ -375,12 +375,10 @@
}
this.all_attributes.attributes = this.attribute_values;
this.all_conditions = JSON.stringify(this.all_attributes);
} else {
this.all_conditions = null;
}
this.all_conditions = JSON.stringify(this.all_attributes);
// this.all_conditions = JSON.stringify(this.conditions_list);
// if (this.conditions_list.length != 0) {

View File

@ -53,6 +53,6 @@ class CartItem extends Model implements CartItemContract
*/
public function child()
{
return $this->belongsTo(self::class, 'id', 'parent_id');
return $this->belongsTo(static::class, 'id', 'parent_id');
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Webkul\Customer\Helpers;
use Webkul\Customer\Repositories\WishlistRepository;
class Wishlist
{
/**
* WishlistRepository object
*
* @var array
*/
protected $wishlistRepository;
/**
* Create a new controller instance.
*
* @param Webkul\Customer\Repositories\WishlistRepository
* @return void
*/
public function __construct(WishlistRepository $wishlistRepository)
{
$this->wishlistRepository = $wishlistRepository;
}
/**
* Returns wishlist products for current customer.
*
* @param Product $product
* @return boolean
*/
public function getWishlistProduct($product)
{
$wishlist = false;
if (auth()->guard('customer')->user()) {
$wishlist = $this->wishlistRepository->findOneWhere([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $product->product_id,
'customer_id' => auth()->guard('customer')->user()->id
]);
}
if ($wishlist)
return true;
return false;
}
}

View File

@ -781,7 +781,7 @@ abstract class Discount
foreach ($conditions as $condition) {
$result = true;
if (! isset($condition->attribute) || ! isset($condition->condition) || ! isset($condition->value) || ! isset($condition->type) || $condition->value != []) {
if (! isset($condition->attribute) || ! isset($condition->condition) || ! isset($condition->value) || ! isset($condition->type) || ! $condition->value != []) {
$result = false;
continue;
@ -911,7 +911,7 @@ abstract class Discount
}
foreach ($conditions as $condition) {
if (!isset($condition->attribute) || ! isset($condition->condition) || !isset($condition->value)) {
if (! isset($condition->attribute) || ! isset($condition->condition) || ! isset($condition->value)) {
continue;
}

View File

@ -14,7 +14,7 @@ class Review extends AbstractProduct
public function getReviews($product)
{
static $reviews = [];
if(array_key_exists($product->id, $reviews))
return $reviews[$product->id];

View File

@ -79,6 +79,12 @@ class ProductForm extends FormRequest
$inputs = $this->all();
if (isset($inputs['variants'])) {
foreach ($inputs['variants'] as $key => $variant) {
$this->rules['variants'.'.'.$key.'.'.'sku'] = ['unique:products,sku,' . $key, new \Webkul\Core\Contracts\Validations\Slug];
}
}
$product = $this->product->find($this->id);
$attributes = $product->attribute_family->custom_attributes;
@ -131,4 +137,16 @@ class ProductForm extends FormRequest
return $this->rules;
}
/**
* Custom message for validation
*
* @return array
*/
public function messages()
{
return [
'variants.*.sku.unique' => 'The sku has already been taken.',
];
}
}

View File

@ -285,13 +285,15 @@ class ProductFlat
$productFlat->save();
}
} else {
$productFlat = $this->productFlatRepository->findOneWhere([
'product_id' => $product->id,
'channel' => $channel->code,
]);
if (request()->route()->getName() == 'admin.catalog.products.update') {
$productFlat = $this->productFlatRepository->findOneWhere([
'product_id' => $product->id,
'channel' => $channel->code,
]);
if ($productFlat) {
$this->productFlatRepository->delete($productFlat->id);
if ($productFlat) {
$this->productFlatRepository->delete($productFlat->id);
}
}
}
}

View File

@ -38,7 +38,7 @@ class Product extends Model implements ProductContract
*/
public function variants()
{
return $this->hasMany(self::class, 'parent_id');
return $this->hasMany(static::class, 'parent_id');
}
/**
@ -54,7 +54,7 @@ class Product extends Model implements ProductContract
*/
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
return $this->belongsTo(static::class, 'parent_id');
}
/**
@ -120,7 +120,7 @@ class Product extends Model implements ProductContract
*/
public function related_products()
{
return $this->belongsToMany(self::class, 'product_relations', 'parent_id', 'child_id')->limit(4);
return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id')->limit(4);
}
/**
@ -128,7 +128,7 @@ class Product extends Model implements ProductContract
*/
public function up_sells()
{
return $this->belongsToMany(self::class, 'product_up_sells', 'parent_id', 'child_id')->limit(4);
return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id')->limit(4);
}
/**
@ -136,7 +136,7 @@ class Product extends Model implements ProductContract
*/
public function cross_sells()
{
return $this->belongsToMany(self::class, 'product_cross_sells', 'parent_id', 'child_id')->limit(4);
return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id')->limit(4);
}
/**
@ -214,7 +214,7 @@ class Product extends Model implements ProductContract
*/
public function getAttribute($key)
{
if (! method_exists(self::class, $key) && ! in_array($key, ['parent_id', 'attribute_family_id']) && ! isset($this->attributes[$key])) {
if (! method_exists(static::class, $key) && ! in_array($key, ['parent_id', 'attribute_family_id']) && ! isset($this->attributes[$key])) {
if (isset($this->id)) {
$this->attributes[$key] = '';

View File

@ -34,7 +34,7 @@ class ProductFlat extends Model implements ProductFlatContract
*/
public function variants()
{
return $this->hasMany(self::class, 'parent_id');
return $this->hasMany(static::class, 'parent_id');
}
/**

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,4 +1,4 @@
{
"/js/shop.js": "/js/shop.js?id=ad1039174ce2c81c8805",
"/css/shop.css": "/css/shop.css?id=0647d577bed15c4b141e"
"/js/shop.js": "/js/shop.js?id=71f03d05d9690fe24784",
"/css/shop.css": "/css/shop.css?id=426d876808f107691dc6"
}

View File

@ -183,6 +183,14 @@ input {
}
}
.add-to-wishlist.already {
pointer-events: none;
.wishlist-icon {
background-image: url('../images/wishlist-added.svg') !important;
}
}
//product page price styles
.product-price {
margin-bottom: 14px;
@ -1717,6 +1725,9 @@ section.product-detail {
}
}
.add-to-wishlist.already {
background-image: url('../images/wishlist-added.svg') !important;
}
.share {
position: absolute;

View File

@ -1,4 +1,6 @@
@inject ('productImageHelper', 'Webkul\Product\Helpers\ProductImage')
@inject ('wishListHelper', 'Webkul\Customer\Helpers\Wishlist')
<?php $images = $productImageHelper->getGalleryImages($product); ?>
{!! view_render_event('bagisto.shop.products.view.gallery.before', ['product' => $product]) !!}
@ -41,7 +43,7 @@
<img :src="currentLargeImageUrl" id="pro-img" :data-image="currentOriginalImageUrl"/>
@auth('customer')
<a class="add-to-wishlist" href="{{ route('customer.wishlist.add', $product->product_id) }}">
<a @if ($wishListHelper->getWishlistProduct($product)) class="add-to-wishlist already" @else class="add-to-wishlist" @endif href="{{ route('customer.wishlist.add', $product->product_id) }}">
</a>
@endauth
</div>
@ -158,8 +160,10 @@
$('img#pro-img').data('zoom-image', $('img#pro-img').data('image')).ezPlus();
}
var wishlist = " <?php echo $wishListHelper->getWishlistProduct($product); ?> ";
$(document).mousemove(function(event) {
if ($('.add-to-wishlist').length) {
if ($('.add-to-wishlist').length && wishlist != 1) {
if (event.pageX > $('.add-to-wishlist').offset().left && event.pageX < $('.add-to-wishlist').offset().left+32 && event.pageY > $('.add-to-wishlist').offset().top && event.pageY < $('.add-to-wishlist').offset().top+32) {
$(".zoomContainer").addClass("show-wishlist");

View File

@ -1,7 +1,9 @@
@inject ('wishListHelper', 'Webkul\Customer\Helpers\Wishlist')
@auth('customer')
{!! view_render_event('bagisto.shop.products.wishlist.before') !!}
<a class="add-to-wishlist" href="{{ route('customer.wishlist.add', $product->product_id) }}" id="wishlist-changer">
<a @if ($wishListHelper->getWishlistProduct($product)) class="add-to-wishlist already" @else class="add-to-wishlist" @endif href="{{ route('customer.wishlist.add', $product->product_id) }}" id="wishlist-changer">
<span class="icon wishlist-icon"></span>
</a>