resolve conflict in CartRule.php

This commit is contained in:
Steffen Mahler 2020-07-15 08:44:56 +02:00
commit 2b4615b9c0
13 changed files with 154 additions and 80 deletions

View File

@ -12,7 +12,7 @@ DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=bagisto_testing
DB_USERNAME=bagisto
DB_PASSWORD=secret
DB_PASSWORD=secretq
DB_PREFIX=
BROADCAST_DRIVER=log

View File

@ -408,12 +408,12 @@
<span class="locale"> [@{{ channel_locale }}] </span>
</label>
<select v-if="this.options.length" v-validate= "validations" class="control" :id = "name" :name = "name" v-model="this.result"
<select v-if="this.options.length" v-validate= "validations" class="control" :id = "name" :name = "name" v-model="savedValue"
:data-vv-as="field_name">
<option v-for='(option, index) in this.options' :value="option.value"> @{{ option.title }} </option>
</select>
<input v-else type="text" class="control" v-validate= "validations" :id = "name" :name = "name" v-model="this.result"
<input v-else type="text" class="control" v-validate= "validations" :id = "name" :name = "name" v-model="savedValue"
:data-vv-as="field_name">
<span class="control-error" v-if="errors.has(name)">
@ -436,12 +436,15 @@
return {
isRequire: false,
isVisible: false,
savedValue: "",
}
},
mounted: function () {
var this_this = this;
this_this.savedValue = this_this.result;
if (this_this.validations || (this_this.validations.indexOf("required") != -1)) {
this_this.isRequire = true;
}

View File

@ -197,13 +197,13 @@ class Booking extends Virtual
continue;
}
$cartProducts = parent::prepareForCart([
$cartProducts = parent::prepareForCart(array_merge($data, [
'product_id' => $data['product_id'],
'quantity' => $qty,
'booking' => [
'ticket_id' => $ticketId,
],
]);
]));
if (is_string($cartProducts)) {
return $cartProducts;
@ -283,4 +283,4 @@ class Booking extends Virtual
return app($this->bookingHelper->getTypeHelper($bookingProduct->type))->validateCartItem($item);
}
}
}

View File

@ -3,6 +3,7 @@
namespace Webkul\CartRule\Helpers;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Webkul\CartRule\Repositories\CartRuleRepository;
use Webkul\CartRule\Repositories\CartRuleCouponRepository;
use Webkul\CartRule\Repositories\CartRuleCouponUsageRepository;
@ -166,21 +167,22 @@ class CartRule
/**
* Check if cart rule can be applied
*
* @param \Webkul\CartRule\Contracts\CartRule $rule
* @param $cart
* @param \Webkul\CartRule\Contracts\CartRule $rule
*
* @return bool
*/
public function canProcessRule($rule): bool
public function canProcessRule($cart, $rule): bool
{
$cart = Cart::getCart();
if ($rule->coupon_type) {
if (strlen($cart->coupon_code)) {
$coupon = $this->cartRuleCouponRepository->findOneWhere([
'cart_rule_id' => $rule->id,
'code' => $cart->coupon_code,
]);
/** @var \Webkul\CartRule\Models\CartRule $rule */
if ($coupon) {
// Laravel relation is used instead of repository for performance
// reasons (cart_rule_coupon-relation is pre-loaded by self::getCartRuleQuery())
$coupon = $rule->cart_rule_coupon;
if ($coupon && $coupon->code === $cart->coupon_code) {
if ($coupon->usage_limit && $coupon->times_used >= $coupon->usage_limit) {
return false;
}
@ -231,8 +233,10 @@ class CartRule
$appliedRuleIds = [];
foreach ($this->getCartRules() as $rule) {
if (! $this->canProcessRule($rule)) {
$cart = Cart::getCart();
foreach ($rules = $this->getCartRules() as $rule) {
if (! $this->canProcessRule($cart, $rule)) {
continue;
}
@ -354,8 +358,10 @@ class CartRule
$appliedRuleIds = [];
$cart = Cart::getCart();
foreach ($this->getCartRules() as $rule) {
if (! $this->canProcessRule($rule)) {
if (! $this->canProcessRule($cart, $rule)) {
continue;
}
@ -436,8 +442,10 @@ class CartRule
$appliedRuleIds = [];
$cart = Cart::getCart();
foreach ($this->getCartRules() as $rule) {
if (! $this->canProcessRule($rule)) {
if (! $this->canProcessRule($cart, $rule)) {
continue;
}
@ -481,12 +489,14 @@ class CartRule
*/
public function calculateCartItemTotals($items)
{
$cart = Cart::getCart();
foreach ($this->getCartRules() as $rule) {
if ($rule->action_type == 'cart_fixed') {
$totalPrice = $totalBasePrice = $validCount = 0;
foreach ($items as $item) {
if (! $this->canProcessRule($rule, $item)) {
if (! $this->canProcessRule($cart, $rule)) {
continue;
}
@ -559,23 +569,30 @@ class CartRule
*/
public function getCartRuleQuery($customerGroupId, $channelId): \Illuminate\Database\Eloquent\Collection
{
$cartRules = $this->cartRuleRepository->scopeQuery(function ($query) use ($customerGroupId, $channelId) {
return $this->cartRuleRepository->scopeQuery(function ($query) use ($customerGroupId, $channelId) {
/** @var Builder $query */
return $query->leftJoin('cart_rule_customer_groups', 'cart_rules.id', '=',
'cart_rule_customer_groups.cart_rule_id')
->leftJoin('cart_rule_channels', 'cart_rules.id', '=', 'cart_rule_channels.cart_rule_id')
->where('cart_rule_customer_groups.customer_group_id', $customerGroupId)
->where('cart_rule_channels.channel_id', $channelId)
->where(function ($query1) {
/** @var Builder $query1 */
$query1->where('cart_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))
->orWhereNull('cart_rules.starts_from');
})
->where(function ($query2) {
/** @var Builder $query2 */
$query2->where('cart_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))
->orWhereNull('cart_rules.ends_till');
})
->with([
'cart_rule_customer_groups',
'cart_rule_channels',
'cart_rule_coupon'
])
->orderBy('sort_order', 'asc');
})->findWhere(['status' => 1]);
return $cartRules;
}
}

View File

@ -2,13 +2,11 @@
namespace Webkul\CartRule\Models;
// use Webkul\Core\Eloquent\TranslatableModel;
use Illuminate\Database\Eloquent\Model;
use Webkul\CartRule\Contracts\CartRule as CartRuleContract;
use Webkul\Core\Models\ChannelProxy;
use Webkul\Customer\Models\CustomerGroupProxy;
// class CartRule extends TranslatableModel implements CartRuleContract
class CartRule extends Model implements CartRuleContract
{
protected $fillable = [
@ -40,42 +38,80 @@ class CartRule extends Model implements CartRuleContract
'conditions' => 'array',
];
// public $translatedAttributes = ['name'];
/**
* Get the channels that owns the cart rule.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function channels()
public function cart_rule_channels(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(ChannelProxy::modelClass(), 'cart_rule_channels');
}
/**
* Get the customer groups that owns the cart rule.
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*
* @deprecated laravel standard should be used
*/
public function customer_groups()
public function channels(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->cart_rule_channels();
}
/**
* Get the customer groups that owns the cart rule.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function cart_rule_customer_groups(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(CustomerGroupProxy::modelClass(), 'cart_rule_customer_groups');
}
/**
* Get the coupons that owns the cart rule.
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*
* @deprecated laravel standard should be used
*/
public function coupons()
public function customer_groups(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->cart_rule_customer_groups();
}
/**
* Get the coupons that owns the cart rule.
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function cart_rule_coupon(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(CartRuleCouponProxy::modelClass());
}
/**
* Get primary coupon code for cart rule.
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*
* @deprecated laravel standard should be used
*/
public function coupon_code()
public function coupons(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->coupons()->where('is_primary', 1);
return $this->cart_rule_coupon();
}
/**
* Get primary coupon code for cart rule.
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function coupon_code(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->cart_rule_coupon()->where('is_primary', 1);
}
/**
* Get primary coupon code for cart rule.
*
* @return string|void
*/
public function getCouponCodeAttribute()
{

View File

@ -41,7 +41,7 @@ class BundleOption extends AbstractProduct
foreach ($this->product->bundle_options as $option) {
$data = $this->getOptionItemData($option);
if (! count($data['products'])) {
if (! $option->is_required && ! count($data['products'])) {
continue;
}

View File

@ -587,7 +587,14 @@ class Bundle extends AbstractType
$bundleOptionQuantities[$option->id] = $qty;
}
$labels[] = $qty . ' x ' . $optionProduct->product->name . ' ' . core()->currency($optionProduct->product->getTypeInstance()->getMinimalPrice());
$label = $qty . ' x ' . $optionProduct->product->name;
$price = $optionProduct->product->getTypeInstance()->getMinimalPrice();
if($price != 0){
$label .= ' ' . core()->currency($price);
}
$labels[] = $label;
}
if (count($labels)) {

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=b0ae98b46b290f0fca8b",
"/css/shop.css": "/css/shop.css?id=0664f52f2390473afc00"
"/js/shop.js": "/js/shop.js?id=d64fdfe9e3fe3e4b9ee4",
"/css/shop.css": "/css/shop.css?id=d5a7b8d843e219c2fa28"
}

View File

@ -815,7 +815,7 @@ section.slider-block {
img {
display: none;
}
input {
display: none;
}
@ -4566,4 +4566,52 @@ section.review {
}
}
}
}
//compare page
body {
overflow-x: hidden;
}
.comparison-component {
width: 100%;
padding-top: 20px;
}
.comparison-component > h1 {
display: inline-block;
}
td {
padding: 15px;
min-width: 250px;
max-width: 250px;
line-height: 30px;
vertical-align: top;
word-break: break-word;
}
.icon.remove-product {
top: 5px;
float: right;
cursor: pointer;
position: relative;
background-color: black;
}
.action > div {
display: inline-block;
}
.cart-wish-wrap .btn.btn-lg {
padding: 5px 10px;
}
.cart-wish-wrap {
display: flex;
}
.white-cross-sm-icon {
width: 24px;
height:24px;
}
.add-to-wishlist {
margin-left: 15px;
}

View File

@ -3,44 +3,6 @@
$comparableAttributes = $attributeRepository->findByField('is_comparable', 1);
@endphp
@push('css')
<style>
body {
overflow-x: hidden;
}
.comparison-component {
width: 100%;
padding-top: 20px;
}
.comparison-component > h1 {
display: inline-block;
}
td {
padding: 15px;
min-width: 250px;
max-width: 250px;
line-height: 30px;
vertical-align: top;
word-break: break-word;
}
.icon.remove-product {
top: 15px;
float: right;
cursor: pointer;
position: relative;
background-color: black;
}
.action > div {
display: inline-block;
}
</style>
@endpush
@push('scripts')
<script type="text/x-template" id="compare-product-template">
<section class="comparison-component">

View File

@ -387,6 +387,7 @@ class Helper extends Review
$productMetaDetails['slug'] = $product->url_key;
$productMetaDetails['image'] = $formattedProduct['image'];
$productMetaDetails['priceHTML'] = $formattedProduct['priceHTML'];
$productMetaDetails['new'] = $formattedProduct['new'];
$productMetaDetails['addToCartHtml'] = $formattedProduct['addToCartHtml'];
$productMetaDetails['galleryImages'] = $formattedProduct['galleryImages'];
$productMetaDetails['defaultAddToCart'] = $formattedProduct['defaultAddToCart'];
@ -397,7 +398,7 @@ class Helper extends Review
}
}
}
return $productCollection;
}
}