category default limit

This commit is contained in:
merdan 2022-03-09 17:34:01 +05:00
parent 6328d86253
commit 4a83a21db8
3 changed files with 104 additions and 65 deletions

View File

@ -4,7 +4,6 @@ namespace Sarga\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
use Sarga\API\Http\Resources\Catalog\Product as ProductResource;
use Webkul\Marketplace\Repositories\ProductRepository;
class CartItemResource extends JsonResource
{
@ -18,26 +17,22 @@ class CartItemResource extends JsonResource
{
return [
'id' => $this->id,
'quantity' => $this->quantity,
'quantity' => (int)$this->quantity,
'name' => $this->name,
'base_total_weight' => $this->base_total_weight,
'price' => $this->price,
'base_total_weight' => (double)$this->base_total_weight,
'price' => (double)$this->price,
'formatted_price' => core()->formatPrice($this->base_price, $this->cart->cart_currency_code),
'custom_price' => $this->custom_price,
'formatted_custom_price' => core()->formatPrice($this->custom_price, $this->cart->cart_currency_code),
'total' => $this->total,
'custom_price' => (double)$this->custom_price,
'total' => (double)$this->total,
'formatted_total' => core()->formatPrice($this->base_total, $this->cart->cart_currency_code),
'tax_percent' => $this->tax_percent,
'tax_amount' => $this->tax_amount,
'formatted_tax_amount' => core()->formatPrice($this->base_tax_amount, $this->cart->cart_currency_code),
'discount_percent' => $this->discount_percent,
'discount_amount' => $this->discount_amount,
'discount_amount' => (double)$this->discount_amount,
'formatted_discount_amount' => core()->formatPrice($this->base_discount_amount, $this->cart->cart_currency_code),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'child' => new self($this->child),
'product' => $this->when($this->product_id, new CartItemProduct($this->product)),
'product' => $this->when($this->product_id, new ProductResource($this->product)),
];
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace Sarga\API\Http\Resources\Customer;
use Illuminate\Http\Resources\Json\JsonResource;
class OrderItemREsource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'sku' => $this->sku,
'type' => $this->type,
'name' => $this->name,
'product_id' => $this->product_id,
'coupon_code' => $this->coupon_code,
'weight' => (double) $this->weight,
'total_weight' => $this->total_weight,
'qty_ordered' => (int) $this->qty_ordered,
'qty_canceled' => (int) $this->qty_canceled,
'qty_invoiced' => (int) $this->qty_invoiced,
'qty_shipped' => (int) $this->qty_shipped,
'qty_refunded' => (int) $this->qty_refunded,
'price' => (double) $this->price,
'formated_price' => core()->formatPrice($this->base_price, $this->order->order_currency_code),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->base_total, $this->order->order_currency_code),
'total_invoiced' => $this->total_invoiced,
'formated_total_invoiced' => core()->formatPrice($this->base_total_invoiced, $this->order->order_currency_code),
'amount_refunded' => $this->amount_refunded,
'formated_amount_refunded' => core()->formatPrice($this->base_amount_refunded, $this->order->order_currency_code),
'discount_percent' => $this->discount_percent,
'discount_amount' => (double) $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->base_discount_amount, $this->order->order_currency_code),
'discount_invoiced' => $this->discount_invoiced,
'formated_discount_invoiced' => core()->formatPrice($this->base_discount_invoiced, $this->order->order_currency_code),
'discount_refunded' => $this->discount_refunded,
'formated_discount_refunded' => core()->formatPrice($this->base_discount_refunded, $this->order->order_currency_code),
'grant_total' => $this->total + $this->tax_amount,
'formated_grant_total' => core()->formatPrice($this->base_total + $this->base_tax_amount, $this->order->order_currency_code),
'downloadable_links' => $this->downloadable_link_purchased,
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'child' => new self($this->child),
'children' => Self::collection($this->children),
];
}
}

View File

@ -3,12 +3,10 @@
namespace Sarga\API\Http\Resources\Customer;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\RestApi\Http\Resources\V1\Admin\Customer\CustomerResource;
use Webkul\RestApi\Http\Resources\V1\Admin\Sale\InvoiceResource;
use Webkul\RestApi\Http\Resources\V1\Admin\Sale\OrderAddressResource;
use Webkul\RestApi\Http\Resources\V1\Admin\Sale\OrderItemResource;
use Webkul\RestApi\Http\Resources\V1\Admin\Sale\ShipmentResource;
use Webkul\RestApi\Http\Resources\V1\Admin\Setting\ChannelResource;
class OrderResource extends JsonResource
{
@ -38,73 +36,57 @@ class OrderResource extends JsonResource
'channel_currency_code' => $this->channel_currency_code,
'order_currency_code' => $this->order_currency_code,
'grand_total' => (double)$this->grand_total,
'formated_grand_total' => core()->formatPrice($this->grand_total, $this->order_currency_code),
'base_grand_total' => (double)$this->base_grand_total,
'formated_base_grand_total' => core()->formatBasePrice($this->base_grand_total),
'formated_grand_total' => core()->formatPrice($this->base_grand_total, $this->order_currency_code),
'grand_total_invoiced' => (double)$this->grand_total_invoiced,
'formated_grand_total_invoiced' => core()->formatPrice($this->grand_total_invoiced, $this->order_currency_code),
'base_grand_total_invoiced' => (double)$this->base_grand_total_invoiced,
'formated_base_grand_total_invoiced' => core()->formatBasePrice($this->base_grand_total_invoiced),
'formated_grand_total_invoiced' => core()->formatPrice($this->base_grand_total_invoiced, $this->order_currency_code),
'grand_total_refunded' => (double)$this->grand_total_refunded,
'formated_grand_total_refunded' => core()->formatPrice($this->grand_total_refunded, $this->order_currency_code),
'base_grand_total_refunded' => (double)$this->base_grand_total_refunded,
'formated_base_grand_total_refunded' => core()->formatBasePrice($this->base_grand_total_refunded),
'formated_grand_total_refunded' => core()->formatPrice($this->base_grand_total_refunded, $this->order_currency_code),
'sub_total' => (double)$this->sub_total,
'formated_sub_total' => core()->formatPrice($this->sub_total, $this->order_currency_code),
'base_sub_total' => (double)$this->base_sub_total,
'formated_base_sub_total' => core()->formatBasePrice($this->base_sub_total),
'formated_sub_total' => core()->formatPrice($this->base_sub_total, $this->order_currency_code),
'sub_total_invoiced' => (double)$this->sub_total_invoiced,
'formated_sub_total_invoiced' => core()->formatPrice($this->sub_total_invoiced, $this->order_currency_code),
'base_sub_total_invoiced' => (double)$this->base_sub_total_invoiced,
'formated_base_sub_total_invoiced' => core()->formatBasePrice($this->base_sub_total_invoiced),
'formated_sub_total_invoiced' => core()->formatPrice($this->base_sub_total_invoiced, $this->order_currency_code),
'sub_total_refunded' => (double)$this->sub_total_refunded,
'formated_sub_total_refunded' => core()->formatPrice($this->sub_total_refunded, $this->order_currency_code),
'discount_percent' => (double)$this->discount_percent,
// 'formated_sub_total_refunded' => core()->formatPrice($this->sub_total_refunded, $this->order_currency_code),
'discount_percent' => $this->discount_percent,
'discount_amount' => (double)$this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->order_currency_code),
'base_discount_amount' => (double)$this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'formated_discount_amount' => core()->formatPrice($this->base_discount_amount, $this->order_currency_code),
'discount_invoiced' => (double)$this->discount_invoiced,
'formated_discount_invoiced' => core()->formatPrice($this->discount_invoiced, $this->order_currency_code),
'base_discount_invoiced' => (double)$this->base_discount_invoiced,
'formated_base_discount_invoiced' => core()->formatBasePrice($this->base_discount_invoiced),
'formated_discount_invoiced' => core()->formatPrice($this->base_discount_invoiced, $this->order_currency_code),
'discount_refunded' => (double)$this->discount_refunded,
'formated_discount_refunded' => core()->formatPrice($this->discount_refunded, $this->order_currency_code),
'base_discount_refunded' => (double)$this->base_discount_refunded,
'formated_base_discount_refunded' => core()->formatBasePrice($this->base_discount_refunded),
'tax_amount' => (double)$this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->order_currency_code),
'base_tax_amount' => (double)$this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'tax_amount_invoiced' => (double)$this->tax_amount_invoiced,
'formated_tax_amount_invoiced' => core()->formatPrice($this->tax_amount_invoiced, $this->order_currency_code),
'base_tax_amount_invoiced' => (double)$this->base_tax_amount_invoiced,
'formated_base_tax_amount_invoiced' => core()->formatBasePrice($this->base_tax_amount_invoiced),
'tax_amount_refunded' => (double)$this->tax_amount_refunded,
'formated_tax_amount_refunded' => core()->formatPrice($this->tax_amount_refunded, $this->order_currency_code),
'base_tax_amount_refunded' => (double)$this->base_tax_amount_refunded,
'formated_base_tax_amount_refunded' => core()->formatBasePrice($this->base_tax_amount_refunded),
'formated_discount_refunded' => core()->formatPrice($this->base_discount_refunded, $this->order_currency_code),
'shipping_amount' => (double)$this->shipping_amount,
'formated_shipping_amount' => core()->formatPrice($this->shipping_amount, $this->order_currency_code),
'base_shipping_amount' => (double)$this->base_shipping_amount,
'formated_base_shipping_amount' => core()->formatBasePrice($this->base_shipping_amount),
'formated_shipping_amount' => core()->formatPrice($this->base_shipping_amount, $this->order_currency_code),
'shipping_invoiced' => $this->shipping_invoiced,
'formated_shipping_invoiced' => core()->formatPrice($this->shipping_invoiced, $this->order_currency_code),
'base_shipping_invoiced' => $this->base_shipping_invoiced,
'formated_base_shipping_invoiced' => core()->formatBasePrice($this->base_shipping_invoiced),
'formated_shipping_invoiced' => core()->formatPrice($this->base_shipping_invoiced, $this->order_currency_code),
'shipping_refunded' => $this->shipping_refunded,
'formated_shipping_refunded' => core()->formatPrice($this->shipping_refunded, $this->order_currency_code),
'base_shipping_refunded' => $this->base_shipping_refunded,
'formated_base_shipping_refunded' => core()->formatBasePrice($this->base_shipping_refunded),
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'channel' => $this->when($this->channel_id, new ChannelResource($this->channel)),
'formated_shipping_refunded' => core()->formatPrice($this->base_shipping_refunded, $this->order_currency_code),
'shipping_address' => new OrderAddressResource($this->shipping_address),
'billing_address' => new OrderAddressResource($this->billing_address),
'items' => OrderItemResource::collection($this->items),
'vendors' => $this->groupByVendors($this->items),
'invoices' => InvoiceResource::collection($this->invoices),
'shipments' => ShipmentResource::collection($this->shipments),
'updated_at' => $this->updated_at,
'created_at' => $this->created_at,
];
}
private function groupByVendors($items){
$data = array();
foreach($items as $item){
$seller = $this->sellerProductRepository->getSellerByProductId($item->product_id);
$data[$seller->shop_title ?? 'outlet'][] = OrderItemResource::make($item);
}
return $data;
}
}