PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / single-product / stock / config.php
shop-press / Elementor / widgets / single-product / stock Last commit date
config.php 2 years ago
config.php
108 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets;
3
4 defined( 'ABSPATH' ) || exit;
5
6 use ShopPress\Elementor\ShopPressWidgets;
7 use Elementor\Controls_Manager;
8
9 class Stock extends ShopPressWidgets {
10
11 public function get_name() {
12 return 'sp-stock';
13 }
14
15 public function get_title() {
16 return __( 'Product Stock', 'shop-press' );
17 }
18
19 public function get_icon() {
20 return 'sp-widget sp-eicon-product-stock';
21 }
22
23 public function get_categories() {
24 return array( 'sp_woo_single' );
25 }
26
27 public function setup_styling_options() {
28
29 $this->register_group_styler(
30 'wrapper',
31 __( 'Wrapper', 'shop-press' ),
32 array(
33 'wrapper' => array(
34 'label' => esc_html__( 'Wrapper', 'shop-press' ),
35 'type' => 'styler',
36 'selector' => '.sp-stock',
37 'wrapper' => '{{WRAPPER}}',
38 ),
39 )
40 );
41
42 $this->register_group_styler(
43 'stock',
44 __( 'Stock', 'shop-press' ),
45 array(
46 'label' => array(
47 'label' => esc_html__( 'Label', 'shop-press' ),
48 'type' => 'styler',
49 'selector' => '.sp-stock-label',
50 'wrapper' => '{{WRAPPER}}',
51 ),
52 'stock_value' => array(
53 'label' => esc_html__( 'Availability', 'shop-press' ),
54 'type' => 'styler',
55 'selector' => '.sp-stock-availability',
56 'wrapper' => '{{WRAPPER}}',
57 ),
58 )
59 );
60 }
61
62 protected function register_controls() {
63 $this->start_controls_section(
64 'section_content',
65 array(
66 'label' => __( 'General', 'shop-press' ),
67 )
68 );
69
70 $this->add_control(
71 'label',
72 array(
73 'type' => Controls_Manager::TEXT,
74 'label' => __( 'Label', 'shop-press' ),
75 'placeholder' => __( 'Availability:', 'shop-press' ),
76 )
77 );
78
79 $this->end_controls_section();
80 $this->setup_styling_options();
81
82 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
83 }
84
85 protected function render() {
86 $settings = $this->get_settings_for_display();
87
88 do_action( 'shoppress/widget/before_render', $settings );
89
90 $args = array(
91 'label' => $settings['label'],
92 );
93
94 if ( $this->editor_preview() ) {
95 sp_load_builder_template( 'single-product/product-stock', $args );
96 }
97 }
98
99 protected function content_template() {
100 ?>
101 <p class="sp-stock">
102 <span class="sp-stock-label">{{{ settings.label }}}</span>
103 <span class="sp-stock-availability">Out of stock</span>
104 </p>
105 <?php
106 }
107 }
108