PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Services / PrintService.php

PrintService.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Services/PrintService.php

64 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services;
4
5 use FluentCart\Api\Resource\OrderResource;
6 use FluentCart\App\Models\Meta;
7 use FluentCart\App\Services\ShortCodeParser\ShortcodeTemplateBuilder;
8 use FluentCart\Framework\Support\Arr;
9 use FluentCart\Framework\Support\Str;
10
11 class PrintService
12 {
13 public static function invoice($order)
14 {
15 return static::print('invoice_template', $order);
16 }
17
18 public static function packingSlip($order)
19 {
20 return static::print('packing_slip', $order);
21 }
22
23 public static function deliverySlip($order)
24 {
25 return static::print('delivery_slip', $order);
26 }
27
28 public static function shippingSlip($order)
29 {
30 return static::print('shipping_slip', $order);
31 }
32
33 public static function dispatchSlip($order)
34 {
35 return static::print('dispatch_slip', $order);
36 }
37
38 public static function print($key, $orderId)
39 {
40 $template = Meta::query()->where('meta_key', $key)->first();
41 if ($template) {
42 $template = $template->meta_value;
43 } else {
44 $template = TemplateService::getInvoicePackingTemplateByPathName($key);
45 }
46 $order = OrderResource::view($orderId)['order'];
47
48 $renderedTemplate = ShortcodeTemplateBuilder::make($template ?? '', [
49 'order' => $order
50 ]);
51
52 if (has_action('fluent_pdf_download')) {
53 do_action('fluent_pdf_download', [
54 'body' => $renderedTemplate,
55 ],
56 Str::of($key)->headline() . '-InvoiceNO-' . Arr::get($order, 'order.invoice_no')
57 );
58 die();
59 }
60 return FrontendView::renderForPrint($renderedTemplate);
61 }
62
63 }
64