Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issues #234, #217 #246

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion publishable/assets/css/pwa.css

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions publishable/assets/images/placeholder-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion publishable/assets/js/app.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions publishable/assets/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/js/app.js": "/js/app.js?id=f5b09c06997f60ebceb5",
"/js/app.js": "/js/app.js?id=270d0c19f697856bb1bf",
"/css/pwa-admin.css": "/css/pwa-admin.css?id=7073d876ccd90f556cb1",
"/css/pwa.css": "/css/pwa.css?id=47a878dd8a6be606f8b7"
"/css/pwa.css": "/css/pwa.css?id=222101973ee06ea9c222"
}
15 changes: 8 additions & 7 deletions src/Http/Controllers/Shop/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function __construct(

auth()->setDefaultDriver($this->guard);


// $this->middleware('auth:' . $this->guard);

$this->_config = request('_config');

$this->cartRepository = $cartRepository;
Expand All @@ -86,7 +86,7 @@ public function __construct(
public function saveAddress(CustomerAddressForm $request)
{
$data = request()->all();

$data['billing']['address1'] = implode(PHP_EOL, array_filter($data['billing']['address1']));
$data['shipping']['address1'] = implode(PHP_EOL, array_filter($data['shipping']['address1']));

Expand All @@ -103,11 +103,12 @@ public function saveAddress(CustomerAddressForm $request)
foreach(Cart::getCart()->items()->get() as $cartitem)
{
$product = $this->productRepository->find($cartitem->product_id);
if($product->type != 'booking' && $product->getTypeInstance()->totalQuantity() < $cartitem->quantity)

if($product->type != 'booking' && $product->type != 'downloadable' && $product->getTypeInstance()->totalQuantity() < $cartitem->quantity)
{
return response()->json([
'error'=>"qty_unavailable",
'message'=>"Requested Quantity for ".$product->product->name." is not Available"
'error'=>"qty_unavailable",
'message'=>"Requested Quantity for ".$product->product->name." is not Available"
]);
}
}
Expand Down Expand Up @@ -176,7 +177,7 @@ public function saveShipping()
public function isGuestCheckout()
{
$cart = Cart::getCart();

if (! auth()->guard('customer')->check()
&& ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) {
return response()->json([
Expand Down
76 changes: 76 additions & 0 deletions src/Http/Controllers/Shop/OrderController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace Webkul\PWA\Http\Controllers\Shop;

use Webkul\API\Http\Controllers\Shop\Controller;

class OrderController extends Controller
{
/**
* Contains current guard.
*
* @var array
*/
protected $guard;

/**
* Contains route related configuration.
*
* @var array
*/
protected $_config;

/**
* Repository instance.
*
* @var \Webkul\Core\Eloquent\Repository
*/
protected $repository;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->guard = request()->has('token') ? 'api' : 'customer';

$this->_config = request('_config');

if (isset($this->_config['authorization_required']) && $this->_config['authorization_required']) {
auth()->setDefaultDriver($this->guard);

$this->middleware('auth:' . $this->guard);
}

if ($this->_config) {
$this->repository = app($this->_config['repository']);
}
}

/**
* Cancel customer's order.
*
* @return \Illuminate\Http\Response
*/
public function cancel($id)
{
$order = auth()->guard($this->guard)->user()->all_orders()->find($id);

if ($order && $this->repository->cancel($order)) {

return response()->json([
'status' => true,
'message' => __('admin::app.response.cancel-success', [
'name' => 'Order'
]),
]);
}

return response()->json([
'status' => false,
'message' => __('shop::app.common.error'),
]);
}
}
33 changes: 26 additions & 7 deletions src/Http/Controllers/Shop/ReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Webkul\API\Http\Controllers\Shop\Controller;
use Webkul\Product\Repositories\ProductReviewRepository;
use Webkul\PWA\Http\Resources\Catalog\ProductReview as ProductReviewResource;
use Webkul\Product\Repositories\ProductReviewImageRepository;

/**
* Review controller
Expand All @@ -25,22 +26,35 @@ class ReviewController extends Controller
/**
* ProductReviewRepository object
*
* @var array
* @var object
*/
protected $reviewRepository;

/**
* ProductReviewImageRepository object
*
* @var \Webkul\Product\Repositories\ProductReviewImageRepository
*/
protected $productReviewImageRepository;

/**
* Controller instance
*
* @param Webkul\Product\Repositories\ProductReviewRepository $reviewRepository
* @param \Webkul\Product\Repositories\ProductReviewImageRepository $productReviewImageRepository
*/
public function __construct(ProductReviewRepository $reviewRepository)
public function __construct(
ProductReviewRepository $reviewRepository,
ProductReviewImageRepository $productReviewImageRepository
)
{
$this->guard = request()->has('token') ? 'api' : 'customer';

auth()->setDefaultDriver($this->guard);

$this->reviewRepository = $reviewRepository;

$this->productReviewImageRepository = $productReviewImageRepository;
}

/**
Expand All @@ -59,14 +73,19 @@ public function store(Request $request, $id)
'title' => 'required',
]);

$data = array_merge(request()->all(), [
$data = request()->all();

$productReview = $this->reviewRepository->create([
'customer_id' => $customer ? $customer->id : null,
'name' => $customer ? $customer->name : request()->input('name'),
'status' => 'pending',
'product_id' => $id
'name' => $customer ? $customer->name : $request->get('name'),
'status' => 'pending',
'product_id' => $id,
'comment' => $request->comment,
'rating' => $request->rating,
'title' => $request->title
]);

$productReview = $this->reviewRepository->create($data);
$this->productReviewImageRepository->uploadImages($data, $productReview);

return response()->json([
'message' => 'Your review submitted successfully.',
Expand Down
1 change: 1 addition & 0 deletions src/Http/Resources/Catalog/ProductReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function toArray($request)
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'images' => $this->images
];
}
}
23 changes: 23 additions & 0 deletions src/Http/Resources/Catalog/ProductReviewImage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Webkul\PWA\Http\Resources\Catalog;

use Illuminate\Http\Resources\Json\JsonResource;

class ProductReviewImage extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'path' => $this->path,
'review_id' => $this->review_id
];
}
}
1 change: 1 addition & 0 deletions src/Http/Resources/Sales/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function toArray($request)
'formated_base_tax_amount_refunded' => core()->formatBasePrice($this->base_tax_amount_refunded),
'formated_base_discount_refunded' => core()->formatBasePrice($this->base_discount_refunded),
'created_at' => $this->created_at,
'canCancel' => $this->canCancel()
];
}
}
27 changes: 22 additions & 5 deletions src/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@

Route::prefix('pwa/paypal/smart-button')->group(function () {
Route::get('/create-order', 'Webkul\PWA\Http\Controllers\Shop\SmartButtonController@createOrder')->name('paypal.smart-button.create-order.pwa');

Route::post('/capture-order', 'Webkul\PWA\Http\Controllers\Shop\SmartButtonController@captureOrder')->name('paypal.smart-button.capture-order.pwa');
});
});

Route::group(['prefix' => 'api'], function ($router) {

Route::group(['middleware' => ['locale', 'theme', 'currency']], function ($router) {

Route::namespace('Webkul\PWA\Http\Controllers\Shop')->group(function () {
Expand All @@ -86,7 +86,9 @@

Route::get('wishlist/add/{id}', 'WishlistController@create');

Route::post('reviews/{id}/create', 'ReviewController@store');
//product review create for pwa
Route::post('pwa/reviews/{id}/create', 'ReviewController@store');


Route::get('advertisements', 'API\APIController@fetchAdvertisementImages');

Expand All @@ -97,6 +99,14 @@

// Checkout routes
Route::group(['namespace' => 'Webkul\PWA\Http\Controllers\Shop', 'prefix' => 'pwa'], function ($router) {

// Order cancel Api
Route::post('orders/{id}/cancel', 'OrderController@cancel')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\OrderRepository',
'resource' => 'Webkul\PWA\Http\Resources\Sales\Order',
'authorization_required' => true
]);

Route::group(['prefix' => 'checkout'], function ($router) {
Route::get('cart', 'CartController@get');

Expand Down Expand Up @@ -126,7 +136,7 @@
'resource' => 'Webkul\API\Http\Resources\Sales\Invoice',
'authorization_required' => true
]);

Route::get('move-to-cart/{id}', 'WishlistController@moveToCart');

Route::get('categories', 'CategoryController@index');
Expand Down Expand Up @@ -158,6 +168,13 @@
});

Route::namespace('Webkul\API\Http\Controllers\Shop')->group(function () {

//Product Review routes for pwa
Route::get('/pwa/reviews', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Product\Repositories\ProductReviewRepository',
'resource' => 'Webkul\PWA\Http\Resources\Catalog\ProductReview'
]);

Route::get('pwa-reviews/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Product\Repositories\ProductReviewRepository',
'resource' => 'Webkul\PWA\Http\Resources\Catalog\ProductReview'
Expand Down Expand Up @@ -203,7 +220,7 @@
'resource' => 'Webkul\PWA\Http\Resources\Sales\Order',
'authorization_required' => true
]);

// Slider routes
Route::get('sliders', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Core\Repositories\SliderRepository',
Expand Down
28 changes: 28 additions & 0 deletions src/Resources/assets/images/placeholder-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading