Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.x' into pr/amit-webkul/7679
Browse files Browse the repository at this point in the history
  • Loading branch information
devansh-webkul committed Jun 22, 2023
2 parents e83dae5 + a4bd76c commit e3e88b8
Show file tree
Hide file tree
Showing 38 changed files with 674 additions and 486 deletions.
2 changes: 1 addition & 1 deletion packages/Webkul/Checkout/src/Traits/CartTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function moveToCart($wishlistItem)
if (! $wishlistItem->additional) {
$wishlistItem->additional = [
'product_id' => $wishlistItem->product_id,
'quantity' => 1,
'quantity' => request()->input('quantity'),
];
}

Expand Down
22 changes: 0 additions & 22 deletions packages/Webkul/Core/src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,28 +629,6 @@ public function currencySymbol($currency)
return $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
}

/**
* Format and convert price with currency symbol.
*
* @return array
*/
public function getAccountJsSymbols()
{
$formatter = new \NumberFormatter(app()->getLocale(), \NumberFormatter::CURRENCY);

$pattern = $formatter->getPattern();

$pattern = str_replace('¤', '%s', $pattern);

$pattern = str_replace('#,##0.00', '%v', $pattern);

return [
'symbol' => $this->currencySymbol($this->getCurrentCurrencyCode()),
'decimal' => $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL),
'format' => $pattern,
];
}

/**
* Format and convert price with currency symbol.
*
Expand Down
7 changes: 7 additions & 0 deletions packages/Webkul/Product/src/Type/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class Bundle extends AbstractType
*/
protected $isChildrenCalculated = true;

/**
* Show quantity box.
*
* @var bool
*/
protected $showQuantityBox = true;

/**
* Create a new product type instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function toArray($request)
'formatted_price' => core()->formatPrice($this->price),
'total' => $this->total,
'formatted_total' => core()->formatPrice($this->total),
'options' => $this->additional,
'options' => $this->resource->additional['attributes'] ?? [],
'base_image' => $this->product->getTypeInstance()->getBaseImage($this)
];
}
Expand Down
3 changes: 3 additions & 0 deletions packages/Webkul/Shop/src/Http/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function toArray($request)
{
$productTypeInstance = $this->getTypeInstance();

$reviewHelper = app('Webkul\Product\Helpers\Review');

return [
'id' => $this->id,
'name' => $this->name,
Expand All @@ -32,6 +34,7 @@ public function toArray($request)
'price_html' => $productTypeInstance->getPriceHtml(),
'base_image' => product_image()->getProductBaseImage($this),
'images' => product_image()->getGalleryImages($this),
'avg_ratings' => round($reviewHelper->getAverageRating($this)),
];
}
}
23 changes: 8 additions & 15 deletions packages/Webkul/Shop/src/Resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
*/
import.meta.glob(["../images/**", "../fonts/**"]);

/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
import axios from "axios";
window.axios = axios;
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";

/**
* Main vue bundler.
*/
Expand Down Expand Up @@ -89,16 +80,18 @@ window.app = createApp({
});

/**
* Global components registration;
* Global plugins registration.
*/
app.component('VForm', Form);
app.component('VField', Field);
app.component('VErrorMessage', ErrorMessage);
import Shop from "./plugins/shop";
import Axios from "./plugins/axios";
[Shop, Axios].forEach((plugin) => app.use(plugin));

/**
* Global properties registration.
* Global components registration;
*/
app.config.globalProperties.$axios = axios;
app.component("VForm", Form);
app.component("VField", Field);
app.component("VErrorMessage", ErrorMessage);

/**
* Load event, the purpose of using the event is to mount the application
Expand Down
16 changes: 16 additions & 0 deletions packages/Webkul/Shop/src/Resources/assets/js/plugins/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
import axios from "axios";
window.axios = axios;
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";

const Axios = {
install(app) {
app.config.globalProperties.$axios = axios;
},
};

export default Axios;
27 changes: 27 additions & 0 deletions packages/Webkul/Shop/src/Resources/assets/js/plugins/shop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const Shop = {
install(app) {
app.config.globalProperties.$shop = {
/**
* Generates a formatted price string using the provided price, localeCode, and currencyCode.
*
* @param {number} price - The price value to be formatted.
* @param {string} localeCode - The locale code specifying the desired formatting rules.
* @param {string} currencyCode - The currency code specifying the desired currency symbol.
* @returns {string} - The formatted price string.
*/
formatPrice: (price, localeCode = null, currencyCode = null) => {
if (! localeCode) {
localeCode = document.querySelector('meta[http-equiv="content-language"]').content ?? 'en';
}

if (! currencyCode) {
currencyCode = document.querySelector('meta[name="currency-code"]').content ?? 'USD';
}

return new Intl.NumberFormat(localeCode, { style: 'currency', currency: currencyCode }).format(price);
},
};
},
};

export default Shop;
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class="w-full text-[16px] text-gray-900 p-2 pl-0 cursor-pointer"
<template v-else>
<x-shop::range-slider
::key="refreshKey"
default-type="price"
::default-allowed-max-range="allowedMaxPrice"
::default-min-range="minRange"
::default-max-range="maxRange"
Expand Down
51 changes: 43 additions & 8 deletions packages/Webkul/Shop/src/Resources/views/categories/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,58 @@ class="rounded-[12px]"
@include('shop::categories.toolbar')

<!-- Product Card Container -->
<div class="grid grid-cols-3 gap-8 mt-[30px] max-sm:mt-[20px] max-1060:grid-cols-2 max-868:grid-cols-1 max-sm:justify-items-center">
<div v-if="filters.toolbar.mode === 'grid'">
<!-- Product Card Shimmer Effect -->
<template v-if="isLoading">
<x-shop::shimmer.products.cards.grid count="12"></x-shop::shimmer.products.cards.grid>
<div class="grid grid-cols-3 gap-8 mt-[30px] max-sm:mt-[20px] max-1060:grid-cols-2 max-868:grid-cols-1 max-sm:justify-items-center">
<x-shop::shimmer.products.cards.grid count="12"></x-shop::shimmer.products.cards.grid>
</div>
</template>

<!-- Product Card Listing -->
<template v-if="! isLoading && filters.toolbar.mode === 'grid'">
<x-shop::products.cards.grid v-for="product in products"></x-shop::products.cards.grid>
<template v-else>
<template v-if="products.length">
<div class="grid grid-cols-3 gap-8 mt-[30px] max-sm:mt-[20px] max-1060:grid-cols-2 max-868:grid-cols-1 max-sm:justify-items-center">
<x-shop::products.cards.grid v-for="product in products"></x-shop::products.cards.grid>
</div>
</template>

<template v-else>
<div class="grid items-center justify-items-center w-max m-auto h-[476px] place-content-center">
<img src="{{ bagisto_asset('images/thank-you.png') }}"/>

<!-- @translations -->
<p class="text-[20px]">@lang('No products available in this category')</p>
</div>
</template>
</template>
</div>

<div>
<template v-if="! isLoading && filters.toolbar.mode === 'list'">
<x-shop::products.cards.list v-for="product in products"></x-shop::products.cards.list>
<div
class="grid grid-cols-1 gap-[25px] mt-[30px] "
v-else
>
<!-- Product Card Shimmer Effect -->
<template v-if="isLoading">
<x-shop::shimmer.products.cards.list count="12"></x-shop::shimmer.products.cards.list>
</template>
</div

<!-- Product Card Listing -->
<template v-else>
<template v-if="products.length">
<x-shop::products.cards.list v-for="product in products"></x-shop::products.cards.list>
</template>

<template v-else>
<div class="grid items-center justify-items-center w-max m-auto h-[476px] place-content-center">
<img src="{{ bagisto_asset('images/thank-you.png') }}"/>

<!-- @translations -->
<p class="text-[20px]">@lang('No products available in this category')</p>
</div>
</template>
</template>
</div>

<!-- Load More Button -->
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,37 @@ class="w-[110px] h-[110px] rounded-[12px]"
>
</div>

<div class="grid gap-y-[10px]">
<div class="grid place-content-start gap-y-[10px]">
<p
class="text-[16px] font-medium"
v-text="item.name"
>
</p>

<div
class="grid gap-x-[10px] gap-y-[6px] select-none"
v-if="item.options.length"
>
<div class="grid gap-[8px]">
<div class="" v-for="option in item.options">
<p class="text-[14px] font-medium">
@{{ option.attribute_name + ':' }}
</p>

<p class="text-[14px]">
@{{ option.option_label }}
</p>
</div>

</div>
</div>

<span
class="text-[#4D7EA8] cursor-pointer"
class="text-[#0A49A7] cursor-pointer"
@click="removeItem(item.id)"
>
@lang('shop::app.checkout.cart.remove')
</span>
</span>
</div>
</div>

Expand Down Expand Up @@ -174,7 +192,7 @@ class="text-[16px] font-medium cursor-pointer"
>
<x-shop::modal>
<x-slot:toggle>
<span class="text-[#4D7EA8]">
<span class="text-[#0A49A7]">
@lang('shop::app.checkout.cart.coupon.apply')
</span>
</x-slot:toggle>
Expand Down Expand Up @@ -230,12 +248,12 @@ class="m-0 block bg-navyBlue text-white text-base w-max font-medium py-[11px] px
</div>

<div class="flex text-right justify-between">
<p class="text-[16px]">
<p class="text-[18px] font-semibold">
@lang('shop::app.checkout.cart.grand-total')
</p>

<p
class="text-[26px] font-medium"
class="text-[18px] font-semibold"
v-text="cart.formatted_grand_total"
>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
<script type="text/x-template" id="v-mini-cart-template">
<x-shop::drawer>
<x-slot:toggle>
<span class="icon-cart text-[24px] cursor-pointer"></span>
<span class="relative">
<span class="icon-cart text-[24px] cursor-pointer"></span>

<span
class="absolute py-[5px] px-[7px] top-[-15px] left-[18px] rounded-[44px] bg-[#060C3B] text-[#fff] text-[10px] font-semibold leading-[9px]"
v-if="cart?.items_count"
>
@{{ cart.items_count }}
</span>
</span>
</x-slot:toggle>

<x-slot:header>
Expand Down Expand Up @@ -47,6 +56,39 @@ class="text-[18px]"
>
</p>
</div>

<div
class="grid gap-x-[10px] gap-y-[6px] select-none"
v-if="item.options.length"
>
<div class="">
<p
class="flex gap-x-[15px] text-[16px] items-center cursor-pointer"
@click="item.option_show = ! item.option_show"
>
<!-- @translations -->
@lang('See Details')

<span
class="text-[24px]"
:class="{'icon-arrow-up': item.option_show, 'icon-arrow-down': ! item.option_show}"
></span>
</p>
</div>

<div class="grid gap-[8px]" v-show="item.option_show">
<div class="" v-for="option in item.options">
<p class="text-[14px] font-medium">
@{{ option.attribute_name + ':' }}
</p>

<p class="text-[14px]">
@{{ option.option_label }}
</p>
</div>

</div>
</div>

<div class="flex gap-[20px] items-center flex-wrap">
<x-shop::quantity-changer
Expand All @@ -59,7 +101,7 @@ class="gap-x-[20px] rounded-[54px] py-[5px] px-[14px] max-w-[150px] max-h-[36px]

<button
type="button"
class="text-[#4D7EA8]"
class="text-[#0A49A7]"
@click="removeItem(item.id)"
>
@lang('shop::app.checkout.cart.remove')
Expand All @@ -74,12 +116,7 @@ class="pb-[30px]"
v-else
>
<div class="grid gap-y-[20px] b-0 place-items-center">
<img
src="{{ bagisto_asset('images/thank-you.png') }}"
class=""
alt=""
title=""
>
<img src="{{ bagisto_asset('images/thank-you.png') }}">

<p class="text-[20px]">
@lang('shop::app.checkout.cart.empty-cart')
Expand Down Expand Up @@ -108,7 +145,7 @@ class="text-[30px] font-semibold"
class="m-0 ml-[0px] block mx-auto bg-navyBlue text-white text-base w-full font-medium py-[15px] px-[43px] rounded-[18px] text-center cursor-pointer max-sm:px-[20px]"
>
@lang('shop::app.checkout.cart.continue-to-checkout')
</div>
</a>

<div class="m-0 ml-[0px] block text-base py-[15px] text-center font-medium cursor-pointer">
<a href="{{ route('shop.checkout.cart.index') }}">
Expand Down
Loading

0 comments on commit e3e88b8

Please sign in to comment.