PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.4.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.4.0
1.6.6 1.6.5 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 All 49 releases
fluent-cart / app / Hooks / Handlers / TemplateLoader.php

TemplateLoader.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.4.0, at app/Hooks/Handlers/TemplateLoader.php

62 lines 1.8 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\Hooks\Handlers;
4
5 use FluentCart\App\CPT\FluentProducts;
6 use FluentCart\App\Models\ProductDetail;
7
8 class TemplateLoader
9 {
10 public function init()
11 {
12 add_action('fluent_cart/single_product_summary', [$this, 'showTitle'], 10);
13 add_action('fluent_cart/single_product_summary', [$this, 'showExcerpt'], 20);
14 add_action('fluent_cart/single_product_summary', [$this, 'showBuy'], 25);
15 }
16
17 public function showTitle()
18 {
19 global $post;
20 echo wp_kses_post('<h1>' . $post->post_title . '</h1>');
21 }
22
23 public function showExcerpt()
24 {
25 global $post;
26 $short_description = apply_filters('fluent_cart/product_short_description', $post->post_excerpt, []);
27 ?>
28 <div class="fct_product-details_short_description">
29 <?php echo wp_kses_post($short_description); // WPCS: XSS ok.
30 ?>
31 </div>
32 <?php
33 }
34
35 public function showBuy()
36 {
37 global $product_detail;
38
39 ?>
40 <p class="<?php echo esc_attr(apply_filters('fluent_cart/price_class', 'price')); ?>"><?php echo wp_kses_post($product_detail->getPriceHtml()); ?></p>
41 <button type="submit" name="add-to-cart" value="<?php echo esc_attr($product_detail->id); ?>"
42 class="single_add_to_cart_button button alt">Buy Now
43 </button>
44 <?php
45 }
46
47 // public function loadTemplate($template)
48 // {
49 // if (is_singular(FluentProducts::CPT_NAME)) {
50 // global $post;
51 // unset($GLOBALS['product_detail']);
52 // $product = ProductDetail::where('product_id', $post->ID)->first();
53
54 // $GLOBALS['product_detail'] = $product;
55
56 // return FLUENTCART_PLUGIN_PATH . 'templates/single-product.php';
57 // }
58
59 // return $template;
60 // }
61 }
62